Showing posts with label move. Show all posts
Showing posts with label move. Show all posts

Saturday, June 12, 2021

Move PDB to a Different ASM Disk Group

This post shows the steps for moving PDB related data files from one disk group to another. Currently the PDB data files reside in a disk group called +DATA and data file path is
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/
TESTCDB is the CDB name and 9CBA2DF91A8C7012E053F4071FAC36E9 is the PDBs GUID.
The PDB will be moved to a ASM disk group called PDBDG.
1. Run a RMAN backup as copy to create data files copies in the destination diskgroup.
RMAN> backup as copy pluggable database testpdb2 format '+pdbdg';

Starting backup at 08-FEB-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=141 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=877 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=13 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=137 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00045 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/system.301.1063988727
channel ORA_DISK_2: starting datafile copy
input datafile file number=00046 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/sysaux.300.1063988727
channel ORA_DISK_3: starting datafile copy
input datafile file number=00047 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/undotbs1.299.1063988727
channel ORA_DISK_4: starting datafile copy
input datafile file number=00049 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/oradbaudit.304.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/sysaux.257.1063989107 tag=TAG20210208T163145 RECID=1 STAMP=1063989121
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_2: starting datafile copy
input datafile file number=00050 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/box.303.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/system.256.1063989107 tag=TAG20210208T163145 RECID=3 STAMP=1063989121
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile file number=00051 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lobs.306.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/box.260.1063989121 tag=TAG20210208T163145 RECID=5 STAMP=1063989122
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_2: starting datafile copy
input datafile file number=00052 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/indexes.309.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/undotbs1.258.1063989111 tag=TAG20210208T163145 RECID=4 STAMP=1063989121
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_3: starting datafile copy
input datafile file number=00053 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/repos.308.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/oradbaudit.259.1063989117 tag=TAG20210208T163145 RECID=2 STAMP=1063989121
channel ORA_DISK_4: datafile copy complete, elapsed time: 00:00:18
channel ORA_DISK_4: starting datafile copy
input datafile file number=00054 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audits.307.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lobs.261.1063989123 tag=TAG20210208T163145 RECID=6 STAMP=1063989124
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting datafile copy
input datafile file number=00055 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audindexes.310.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/indexes.262.1063989123 tag=TAG20210208T163145 RECID=7 STAMP=1063989124
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_2: starting datafile copy
input datafile file number=00056 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audlobs.282.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/repos.263.1063989125 tag=TAG20210208T163145 RECID=8 STAMP=1063989125
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_3: starting datafile copy
input datafile file number=00057 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/tbs.280.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audits.264.1063989125 tag=TAG20210208T163145 RECID=9 STAMP=1063989125
channel ORA_DISK_4: datafile copy complete, elapsed time: 00:00:02
channel ORA_DISK_4: starting datafile copy
input datafile file number=00058 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/cheindexes.281.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audindexes.265.1063989125 tag=TAG20210208T163145 RECID=10 STAMP=1063989127
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting datafile copy
input datafile file number=00059 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/abs.283.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audlobs.266.1063989127 tag=TAG20210208T163145 RECID=11 STAMP=1063989127
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_2: starting datafile copy
input datafile file number=00060 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/nstbs.297.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/tbs.267.1063989127 tag=TAG20210208T163145 RECID=12 STAMP=1063989128
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_3: starting datafile copy
input datafile file number=00061 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lkstbs.298.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/cheindexes.268.1063989129 tag=TAG20210208T163145 RECID=13 STAMP=1063989129
channel ORA_DISK_4: datafile copy complete, elapsed time: 00:00:02
channel ORA_DISK_4: starting datafile copy
input datafile file number=00048 name=+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/users.305.1063988727
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/abs.269.1063989129 tag=TAG20210208T163145 RECID=14 STAMP=1063989129
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/nstbs.270.1063989129 tag=TAG20210208T163145 RECID=15 STAMP=1063989130
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:02
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lkstbs.271.1063989131 tag=TAG20210208T163145 RECID=16 STAMP=1063989131
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:02
output file name=+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/users.272.1063989131 tag=TAG20210208T163145 RECID=17 STAMP=1063989131
channel ORA_DISK_4: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-FEB-21

Starting Control File and SPFILE Autobackup at 08-FEB-21
piece handle=+FRA/TESTCDB/AUTOBACKUP/2021_02_08/s_1063989132.284.1063989133 comment=NONE
Finished Control File and SPFILE Autobackup at 08-FEB-21

2. As system tablespaces are also moved the switch to new location cannot be done while PDB is open.
RMAN> switch pluggable database testpdb2 to copy;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch to copy command at 02/08/2021 16:32:29
RMAN-06572: database is open and datafile 45 is not offline
So the PDB must be closed (downtime) and then switch to the data file copies.
RMAN> alter pluggable database testpdb2 close;

Statement processed

RMAN>  switch pluggable database testpdb2 to copy;

datafile 45 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/system.256.1063989107"
datafile 46 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/sysaux.257.1063989107"
datafile 47 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/undotbs1.258.1063989111"
datafile 48 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/users.272.1063989131"
datafile 49 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/oradbaudit.259.1063989117"
datafile 50 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/box.260.1063989121"
datafile 51 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lobs.261.1063989123"
datafile 52 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/indexes.262.1063989123"
datafile 53 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/repos.263.1063989125"
datafile 54 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audits.264.1063989125"
datafile 55 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audindexes.265.1063989125"
datafile 56 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audlobs.266.1063989127"
datafile 57 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/tbs.267.1063989127"
datafile 58 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/cheindexes.268.1063989129"
datafile 59 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/abs.269.1063989129"
datafile 60 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/nstbs.270.1063989129"
datafile 61 switched to datafile copy "+PDBDG/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lkstbs.271.1063989131"




3. Recover the PDB
RMAN> recover pluggable database testpdb2;

Starting recover at 08-FEB-21
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 08-FEB-21
4. Open the PDB
RMAN> alter pluggable database testpdb2 open;

Statement processed
Related Posts
Moving 11gR2 RAC to New Set of ASM Diskgroups
Moving non-RAC Database and ASM Between Servers

Thursday, March 7, 2019

Changing ORACLE_BASE, ORACLE_HOME and GI_HOME in a Oracle Restart Setup

This post gives the steps for changing the location of ORACLE_BASE, ORACLE_HOME, oracle Inventory and Grid Infrastructure in a Oracle restart setup. The current and new paths for these items are given in the table below.

ItemCurrent LocationFuture Location
ORACLE_BASE/opt/app/oracle/u01/app/oracle
ORACLE_HOME/opt/app/oracle/product/11.2.0/dbhome_1/u01/app/oracle/product/11.2.0/dbhome_1
GI_HOME/opt/app/oracle/product/12.1.0/grid/u01/app/oracle/product/12.1.0/grid
Oracle Inventory/opt/app/oraInventory/u01/app/oraInventory

As could be seen from the locations the GI home is a 12.1 while the DB runs out of a 11.2 (11.2.0.4) home.

1. It is assumed the mount point /u01 exists. Create the two base directories first, that is the Oracle base and oracle inventory directories and set the necessary permissions.
# cd /u01/

# mkdir -p app/oracle
# mkdir -p app/oraInventory

# chmod 775 oracle
# chmod 770 oraInventory

# chown oracle:oinstall oracle
# chown grid:oinstall oraInventory
2. Stop the database and the HA service.
srvctl stop database -d westdb
crsctl stop has
3. Detach the current GI home from the inventory.
[grid@west bin]$ ./runInstaller -silent -waitforcompletion -detachHome ORACLE_HOME='/opt/app/oracle/product/12.1.0/grid'
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
'DetachHome' was successful.
Check the GI home was removed from the inventory by checking in the inventory.xml
<HOME NAME="OraGI12Home1" LOC="/opt/app/oracle/product/12.1.0/grid" TYPE="O" IDX="1" REMOVED="T"/>
4. Create the future GI Home location.
mkdir -p /u01/app/oracle/product/12.1.0/
Copy the current grid folder to the future location.
cd /opt/app/oracle/product/12.1.0
cp -pR grid /u01/app/oracle/product/12.1.0/
5. Clone the GI Home in the new location. Pass the new Oracle base, GI home and oracle inventory locations to the clone script.
cd /u01/app/oracle/product/12.1.0/grid/clone/bin
$ perl clone.pl -silent ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid 
ORACLE_HOME_NAME=OraGI12Home1 INVENTORY_LOCATION=/u01/app/oraInventory CRS=true

./runInstaller -clone -waitForCompletion  "ORACLE_BASE=/u01/app/oracle" "ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid" "ORACLE_HOME_NAME=OraGI12Home1" "INVENTORY_LOCATION=/u01/app/oraInventory" -silent -paramFile /u01/app/oracle/product/12.1.0/grid/clone/clone_oraparam.ini
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 17853 MB    Passed
Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-03-07_06-42-57PM. Please wait ...You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2019-03-07_06-42-57PM.log
..................................................   5% Done.
..................................................   10% Done.
..................................................   15% Done.
..................................................   20% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   35% Done.
..................................................   40% Done.
..................................................   45% Done.
..................................................   50% Done.
..................................................   55% Done.
..................................................   60% Done.
..................................................   65% Done.
..................................................   70% Done.
..................................................   75% Done.
..................................................   80% Done.
..................................................   85% Done.
..........Could not backup file /u01/app/oracle/product/12.1.0/grid/root.sh to /u01/app/oracle/product/12.1.0/grid/root.sh.ouibak
Could not backup file /u01/app/oracle/product/12.1.0/grid/rootupgrade.sh to /u01/app/oracle/product/12.1.0/grid/rootupgrade.sh.ouibak

Copy files in progress.

Copy files successful.

Link binaries in progress.

Link binaries successful.

Setup files in progress.

Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.

Finish Setup successful.
The cloning of OraGI12Home1 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2019-03-07_06-42-57PM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.
..................................................   95% Done.

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/12.1.0/grid/root.sh



..................................................   100% Done.
You have new mail in /var/spool/mail/grid
6. After running the orainstRoot.sh the inventory location gets updated in the /etc/oraInst.loc
/u01/app/oraInventory/orainstRoot.sh

cat /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
7. Running the root.sh will generate a log file which will have commands to run to create a Oracle restart setup or a cluster setup.
Check /u01/app/oracle/product/12.1.0/grid/install/root_west.domain.net_2019-03-07_18-45-23.log for the output of root script

# tail -f /u01/app/oracle/product/12.1.0/grid/install/root_west.domain.net_2019-03-07_18-45-23.log
Now product-specific root actions will be performed.

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/u01/app/oracle/product/12.1.0/grid/perl/bin/perl -I/u01/app/oracle/product/12.1.0/grid/perl/lib -I/u01/app/oracle/product/12.1.0/grid/crs/install /u01/app/oracle/product/12.1.0/grid/crs/install/roothas.pl
8. Before running the command mentioned in the log file, the existing Oracle restart configuration need to be de-configured. If not following error will occur.
Using configuration parameter file: /u01/app/oracle/product/12.1.0/grid/crs/install/crsconfig_params
2019/03/07 18:46:12 CLSRSC-350: Cannot configure two CRS instances on the same cluster

2019/03/07 18:46:14 CLSRSC-352: CRS is already configured on this node for the CRS home location /opt/app/oracle/product/12.1.0/grid
To de-configure run the following command.
# /u01/app/oracle/product/12.1.0/grid/perl/bin/perl roothas.pl -deconfig -force
Using configuration parameter file: ./crsconfig_params
2019/03/07 18:47:50 CLSRSC-337: Successfully deconfigured Oracle Restart stack
9. Run the command to create the Oracle restart setup.
# /u01/app/oracle/product/12.1.0/grid/perl/bin/perl -I/u01/app/oracle/product/12.1.0/grid/perl/lib -I/u01/app/oracle/product/12.1.0/grid/crs/install /u01/app/oracle/product/12.1.0/grid/crs/install/roothas.pl
Using configuration parameter file: /u01/app/oracle/product/12.1.0/grid/crs/install/crsconfig_params
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node west successfully pinned.
2019/03/07 18:48:26 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'

west     2019/03/07 13:18:58     /u01/app/oracle/product/12.1.0/grid/cdata/west/backup_20190307_131858.olr     459864538
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'west'
CRS-2673: Attempting to stop 'ora.evmd' on 'west'
CRS-2677: Stop of 'ora.evmd' on 'west' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'west' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.
2019/03/07 18:50:11 CLSRSC-327: Successfully configured Oracle Restart for a standalone server
10. Check the GI home added to inventory in new inventory location.
<HOME NAME="OraGI12Home1" LOC="/u01/app/oracle/product/12.1.0/grid" TYPE="O" IDX="1" CRS="true"/>
11. Add listener and ASM to the Oracle restart config.
srvctl add listener -l listener -o /u01/app/oracle/product/12.1.0/grid -p 1521
srvctl start listener -l listener
srvctl add asm -l listener -p +data/asm/ASMPARAMETERFILE/REGISTRY.253.881942589 -d "/dev/sd*"
srvctl start asm

 crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       west                     STABLE
ora.FLASH.dg
               ONLINE  ONLINE       west                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       west                     STABLE
ora.asm
               ONLINE  ONLINE       west                     Started,STABLE
ora.ons
               OFFLINE OFFLINE      west                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       west                     STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       west                     STABLE
--------------------------------------------------------------------------------


12. Next step is to move the Oracle home to new location. As this is a role separated setup, write permission must be granted to oracle user for admin and diag directories inside Oracle base.
cd $ORACLE_BASE
chmod 775 admin diag
Create the new Oracle home location and copy the current Oracle home (dbhome_1) to new location.
# cd /u01/app/oracle/product
# mkdir -p 11.2.0

# cd /opt/app/oracle/product/11.2.0
# cp -pR dbhome_1 /u01/app/oracle/product/11.2.0/
13. Clone the DB Home
$ cd /u01/app/oracle/product/11.2.0/dbhome_1/clone/

/u01/app/oracle/product/11.2.0/dbhome_1/perl/bin/perl clone.pl ORACLE_BASE="/u01/app/oracle/" ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" OSDBA_GROUP=dba OSOPER_GROUP=oper -defaultHomeName

./runInstaller -clone -waitForCompletion  "ORACLE_BASE=/u01/app/oracle/" "ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1" "oracle_install_OSDBA=dba" "oracle_install_OSOPER=oper" -defaultHomeName  -defaultHomeName "CRS=true" -silent -noConfig -nowait
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4097 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-03-07_07-21-14PM. Please wait ...Oracle Universal Installer, Version 11.2.0.4.0 Production
Copyright (C) 1999, 2013, Oracle. All rights reserved.

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2019-03-07_07-21-14PM.log
.................................................................................................... 100% Done.

Installation in progress (Thursday, 7 March 2019 19:21:31 o'clock IST)
...........................................................................                                                     75% Done.
Install successful

Linking in progress (Thursday, 7 March 2019 19:21:43 o'clock IST)
Link successful

Setup in progress (Thursday, 7 March 2019 19:22:43 o'clock IST)
Setup successful

End of install phases.(Thursday, 7 March 2019 19:23:08 o'clock IST)
WARNING:
The following configuration scripts need to be executed as the "root" user.
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts

The cloning of OraHome1 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2019-03-07_07-21-14PM.log' for more details.
Check the inventory is updated with new DB home location.
<HOME NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="2"/>
14. Update the /etc/oratab with the new Oracle home location. Add the database to the Oracle restart configuration.
srvctl add database -d westdb -o /u01/app/oracle/product/11.2.0/dbhome_1 -p +DATA/westdb/spfilewestdb.ora -a "data,flash"
srvctl start database -d westdb
Certain init parameters will refer to paths under previous Oracle base. Change them to reflect the current Oracle base.
show parameter diagnostic_dest
diagnostic_dest                      string      /opt/app/oracle

alter system set diagnostic_dest='/u01/app/oracle' scope=both;
alter system set audit_file_dest='/u01/app/oracle/admin/westdb/adump' scope=spfile;

mkdir -p u01/app/oracle/admin/westdb/adump
15. Stop the database and the Oracle restart stack. Rename the old base location (/opt/app/) to something temporary (/opt/appx/) and start the database. If all steps are followed there shouldn't be any references to previous location. Current oracle base directory could also be found out with orabase.
$ orabase
/u01/app/oracle
Once certain no references to old locations remain those could be removed.

Sunday, April 8, 2018

Plugging non-CDB as a PDB into a CDB in the Same Host

This post shows the steps of plugging a non-CDB into a CDB when both DBs reside on the same host. Both DBs run out of the same Oracle home and has the same database options (non-CDB must have either same or subset of the CDBs options).
1. Non-CDB is as follows
SQL> select cdb from v$database;

CDB
---
NO

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
beast

SQL> select name from v$datafile;

NAME
-------------------------------------------------------------------
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_system_f902ycxw_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_sysaux_f902ypt8_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_undotbs1_f902yxqx_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_users_f902zgb3_.dbf
2. Shutdown the non-CDB and open it in read only mode. Once open in read only mode connect to the non-CDB and create a non-cdb descriptor file. Once the descriptor file is created shutdown the non-CDB.
shutdown imemdiate;
startup mount;
alter database open read only;

exec dbms_pdb.describe(pdb_descr_file=>'/home/oracle/beast_non_cdb.xml');

shutdown immediate;
3. The CDB details are as follows.
SQL> select instance_name from v$instance;

INSTANCE_NAME
-------------
parakum

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         5 PDBAPP1                        READ WRITE NO
4. Connect to the CDB and run CHECK_PLUG_COMPATIBILITY to test the compatibility of the non-CDB. Following PL/SQL code could be used for this.
SQL> show con_name

CON_NAME
---------
CDB$ROOT

set serveroutput on
declare
    compa boolean;
    begin
    compa := dbms_pdb.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/home/oracle/beast_non_cdb.xml');
 if compa = true then
      dbms_output.put_line('compatible');
 else
    dbms_output.put_line('not compatible');
 end if;
end;
/

compatible
5. As the non-CDB is compatible, it could be safely plugged into the CDB. In preparation of this, shutdown the non-CDB.
SQL> show con_name

CON_NAME
---------
beast

SQL> shutdown immediate;


6. PDB could be created either with copy command or move. With copy command the files will be copied from non-CDB OMF locations to CDB OMF locations. At the end of the copy the non-CDB could be opened as before and copy of it will be available inside the CDB as a PDB. If the host server doesn't have enough space for a full copy of the non-CDB then move options could be used where files will be moved from non-CDB to CDB. At the end of the move, non-CDB will not be available for use since files are moved out. Following shows the use of copy command
Since non-CDB uses OMF, the file_name_convert cannot be used during the PDB creation. Using of file_name_convert will result in error (refer MOS 1912436.1 as well)
SQL> CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
COPY
FILE_NAME_CONVERT = ('/opt/app/oracle/oradata/BEAST/datafile/', '/opt/app/oracle/oradata/PARAKUM/');  2    3
CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
*
ERROR at line 1:
ORA-01276: Cannot add file
/opt/app/oracle/oradata/PARAKUM/o1_mf_system_f902ycxw_.dbf.  File has an Oracle
Managed Files file name.
One of the solutions is to omit file name conversion and let OMF to take care of it.
SQL>  CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml' copy;
Alternatively source_file_name_convert could be used by specifying current location of the datafiles into the two string mappings.
CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
COPY
source_file_name_convert = ('/opt/app/oracle/oradata/BEAST/datafile/', '/opt/app/oracle/oradata/BEAST/datafile/');
The first parameter in the source_file_name_convert refers to the location of the datafiles listed in the descriptor file while second location refers to the actual location of the files. Either way the result is the same.
Following command shows the use of move option and using a different name other than the non-CDB name during the PDB creation processes.
CREATE PLUGGABLE DATABASE pdbdev USING '/home/oracle/beast_non_cdb.xml' move;
At the end of the PDB creation it will be in mount mode. Do not open it until noncdb-to-pdb script is run.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 BEAST                          MOUNTED
         5 PDBAPP1                        READ WRITE NO
7. Once the PDB is created switch to it and verify all relevant datafiles are copied. (Following outputs from PDB created with copy above).
SQL> alter session set container=beast;
Session altered.

SQL> show con_name

CON_NAME
------------------------------
BEAST

SQL> select name from v$datafile;

NAME
------------------------------------------------------------------------------------------------------
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_system_f90fmmrn_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_sysaux_f90fmmt2_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_undotbs1_f90fmmt3_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_users_f90fmmt5_.dbf
8. Before opening run the noncdb-to-pdb script from within the newly created PDB
@?/rdbms/admin/noncdb_to_pdb.sql
9. Once the script finishes, open the PDB
SQL> alter pluggable database open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         6 BEAST                          READ WRITE NO
10. Check alert log and PDB_PLUG_IN_VIOLATIONS view for any PDB violation during the opening. Finally backup the CDB with the newly created PDB.

Related Posts
Plugging a Non-CDB (pre-12c) into CDB Using Transportable DB (TDB) / Tablespaces (TTS)
Plugging a SE2 non-CDB as an EE PDB Using File Copying and Remote Link

Saturday, October 1, 2016

Moving PDB from RAC CDB to Single Instance CDB

The RAC CDB and the non-RAC CDB are both 12.1.0.2 SE2 instances. Currently the single instance CDB doesn't have any PDB plugged on it. SE2 CDBs only support single tenancy due to license restriction. The RAC CDB has a PDB available on both instances.
INSTANCE     NAME         OPEN_MODE  STATUS    RES
------------ ------------ ---------- --------- ---
stdcdb1      PDB$SEED     READ ONLY  NORMAL    NO
stdcdb1      STDPDB       READ WRITE NORMAL    NO
stdcdb2      PDB$SEED     READ ONLY  NORMAL    NO
stdcdb2      STDPDB       READ WRITE NORMAL    NO
Both CDBs has same components except for RAC components which is set not available on the single instance CDB. DB registry of the RAC CDB
SQL> select comp_name,status from dba_registry order by 1;

COMP_NAME                                STATUS
---------------------------------------- -----------
JServer JAVA Virtual Machine             VALID
Oracle Application Express               VALID
Oracle Database Catalog Views            VALID
Oracle Database Java Packages            VALID
Oracle Database Packages and Types       VALID
Oracle Multimedia                        VALID
Oracle Real Application Clusters         VALID
Oracle Text                              VALID
Oracle Workspace Manager                 VALID
Oracle XDK                               VALID
Oracle XML Database                      VALID
DB Registry of the non-RAC CDB
SQL> select comp_name,status from dba_registry order by 1;

COMP_NAME                                STATUS
---------------------------------------- -----------
JServer JAVA Virtual Machine             VALID
Oracle Application Express               VALID
Oracle Database Catalog Views            VALID
Oracle Database Java Packages            VALID
Oracle Database Packages and Types       VALID
Oracle Multimedia                        VALID
Oracle Real Application Clusters         OPTION OFF
Oracle Text                              VALID
Oracle Workspace Manager                 VALID
Oracle XDK                               VALID
Oracle XML Database                      VALID
Process of moving the PDB is similar to earlier post except for few RAC and ASM related tasks. To summarize, before the PDB could be moved from currently plugged in CDB, it must be stopped, unplugged and dropped. The unplugging will create a PDB descriptor file and on in the DB file names will appear in lower case while rest of the path appear upper case.
cat stdpdb_desc.xml | grep path
      +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/DATAFILE/system.291.894734477
      +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/DATAFILE/sysaux.292.894734481
      +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/TEMPFILE/temp.295.922121143
      +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/DATAFILE/users.293.894734495
      +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/DATAFILE/tapp.294.894734495
However when data files are copied out of ASM using asmcmd they will have the names in upper case (e.g. SYSTEM.291.894734477). As a result plugging will fail as it is unable to identify the file name
create pluggable database stdpdb as clone using '/home/oracle/stdcdb/datafiles/stdpdb_desc.xml'
*
ERROR at line 1:
ORA-19505: failed to identify file "/home/oracle/stdcdb/datafiles/system.291.894734477"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory

SQL> ! ls "/home/oracle/stdcdb/datafiles/system.291.894734477"
ls: /home/oracle/stdcdb/datafiles/system.291.894734477: No such file or directory

SQL> ! ls -l /home/oracle/stdcdb/datafiles/*
-rw-r--r-- 1 oracle oinstall      6925 Sep 12 10:47 /home/oracle/stdcdb/datafiles/stdpdb_desc.xml
-rw-r----- 1 oracle oinstall 550510592 Sep 12 10:44 /home/oracle/stdcdb/datafiles/SYSAUX.292.894734481
-rw-r----- 1 oracle oinstall 293609472 Sep 12 10:45 /home/oracle/stdcdb/datafiles/SYSTEM.291.894734477
-rw-r----- 1 oracle oinstall  20979712 Sep 12 10:45 /home/oracle/stdcdb/datafiles/TAPP.294.894734495
-rw-r----- 1 oracle oinstall   5251072 Sep 12 10:45 /home/oracle/stdcdb/datafiles/USERS.293.894734495
So before the plugging rename the file names same as on descriptor file.
 mv SYSTEM.291.894734477 system.291.894734477
 mv SYSAUX.292.894734481 sysaux.292.894734481
 mv TAPP.294.894734495 tapp.294.894734495
 mv USERS.293.894734495 users.293.894734495
Also in ASM datafiles and tempfiles have separate paths, as a result the tempfile location must also specified in the source_file_name convert even though file itself is not necessary to be copied to new location. Temp file get dropped when the PDB is dropped even though keep data file options is used.
drop pluggable database stdpdb keep datafiles
Deleted Oracle managed file +DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/TEMPFILE/temp.295.922364799
Completed: drop pluggable database stdpdb keep datafiles


So the final command to plug the PDB into single instance will have two file name convert entires, one for data files and another for temp files
create pluggable database stdpdb as clone using '/home/oracle/stdcdb/datafiles/stdpdb_desc.xml' 
source_file_name_convert=(
'+DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/DATAFILE','/home/oracle/stdcdb/datafiles',
'+DATA/STDCDB/238FA674AFE26E9DE0535E00A8C0F5A1/TEMPFILE','/home/oracle/stdcdb/datafiles') move;
Once the PDB is plugged open it
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 STDPDB                         MOUNTED

SQL> alter pluggable database stdpdb open;

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 STDPDB                         READ WRITE NO

SQL> select name from v$datafile;

NAME
-----------------------------------------------------------------------------------------------
/ssdoracle/oradata/STDCDB/datafile/o1_mf_undotbs1_cx2j8d05_.dbf
/ssdoracle/oradata/STDCDB/3C4F4864ACAE0C3DE0534200A8C05C7A/datafile/o1_mf_system_cxf6fp5g_.dbf
/ssdoracle/oradata/STDCDB/3C4F4864ACAE0C3DE0534200A8C05C7A/datafile/o1_mf_sysaux_cxf6fp5h_.dbf
/ssdoracle/oradata/STDCDB/3C4F4864ACAE0C3DE0534200A8C05C7A/datafile/o1_mf_users_cxf6fp5j_.dbf
/ssdoracle/oradata/STDCDB/3C4F4864ACAE0C3DE0534200A8C05C7A/datafile/o1_mf_tapp_cxf6fp5k_.dbf
Looking at the PDB violation view will show the warning related to missing RAC option.
SQL> select name,status,action,message from PDB_PLUG_IN_VIOLATIONS where cause='OPTION';

NAME     STATUS    ACTION                                             MESSAGE
-------- --------- -------------------------------------------------- -------------------------------------------------------------------------------------------
STDPDB   PENDING   Fix the database option in the PDB or the CDB      Database option RAC mismatch: PDB installed version 12.1.0.2.0. CDB installed version NULL.
Login into the PDB and turn off the RAC options
SQL> alter session set container=stdpdb;

SQL> show con_name

CON_NAME
---------
STDPDB

SQL> select comp_name,status from dba_registry order by 1;

COMP_NAME                                STATUS
---------------------------------------- -----------
JServer JAVA Virtual Machine             VALID
Oracle Application Express               VALID
Oracle Database Catalog Views            VALID
Oracle Database Java Packages            VALID
Oracle Database Packages and Types       VALID
Oracle Multimedia                        VALID
Oracle Real Application Clusters         VALID
Oracle Text                              VALID
Oracle Workspace Manager                 VALID
Oracle XDK                               VALID
Oracle XML Database                      VALID

11 rows selected.

SQL> exec dbms_registry.OPTION_OFF('RAC');

SQL> select comp_name,status from dba_registry order by 1;

COMP_NAME                                STATUS
---------------------------------------- -----------
JServer JAVA Virtual Machine             VALID
Oracle Application Express               VALID
Oracle Database Catalog Views            VALID
Oracle Database Java Packages            VALID
Oracle Database Packages and Types       VALID
Oracle Multimedia                        VALID
Oracle Real Application Clusters         OPTION OFF
Oracle Text                              VALID
Oracle Workspace Manager                 VALID
Oracle XDK                               VALID
Oracle XML Database                      VALID
Close and open the PDB. The PDB violation view will show the issue has been resolved.
SQL> select name,status,action,message from PDB_PLUG_IN_VIOLATIONS where cause='OPTION';

NAME     STATUS    ACTION                                             MESSAGE
-------- --------- -------------------------------------------------- -------------------------------------------------------------------------------------------
STDPDB   RESOLVED  Fix the database option in the PDB or the CDB      Database option RAC mismatch: PDB installed version 12.1.0.2.0. CDB installed version NULL.
This concludes the moving of PDB from RAC CDB to single instance CDB.

Related Posts
Move a PDB Between Servers
Plugging a SE2 non-CDB as an EE PDB Using File Copying and Remote Link

Thursday, September 1, 2016

Move a PDB Between Servers

This post list the steps for moving a PDB from it's current CDB to another CDB on a different server. The detonation CDB and the PDB are patched to the same level.
Destination CDB patches
SQL> select con_id,patch_id,action,status,description from cdb_registry_sqlpatch where con_id = 1 order by action_time;

    CON_ID   PATCH_ID ACTION          STATUS          DESCRIPTION
---------- ---------- --------------- --------------- ----------------------------------------------------------------------------------------------------
         1   21555660 APPLY           SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         1   21359755 APPLY           SUCCESS         Database Patch Set Update : 12.1.0.2.5 (21359755)
         1   21555660 ROLLBACK        SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         1   22674709 APPLY           SUCCESS         Database PSU 12.1.0.2.160419, Oracle JavaVM Component (Apr2016)
         1   22291127 APPLY           SUCCESS         Database Patch Set Update : 12.1.0.2.160419 (22291127)
PBD patches
SQL> select con_id,patch_id,action,status,description from cdb_registry_sqlpatch where con_id = 5 order by action_time;

    CON_ID   PATCH_ID ACTION          STATUS          DESCRIPTION
---------- ---------- --------------- --------------- ----------------------------------------------------------------------------------------------------
         5   21555660 APPLY           SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         5   21359755 APPLY           SUCCESS         Database Patch Set Update : 12.1.0.2.5 (21359755)
         5   21555660 ROLLBACK        SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         5   22674709 APPLY           SUCCESS         Database PSU 12.1.0.2.160419, Oracle JavaVM Component (Apr2016)
         5   22291127 APPLY           SUCCESS         Database Patch Set Update : 12.1.0.2.160419 (22291127)
As seen from above outputs both destination CDB and PDB has gone through the same set of patches and are currently at the same patch level.
The source CDB has three PDBs and the PDB called "PDBTHREE" will be moved.
SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONEPDB                         READ WRITE NO
         4 TWOPDB                         READ WRITE NO
         5 PDBTHREE                       READ WRITE NO
Close the PBD and unplug it from the source CDB by specifying the metadata xml file.
SQL> alter pluggable database pdbthree close immediate;
Pluggable database altered.

SQL> alter pluggable database pdbthree unplug into '/home/oracle/backup/pdbthree_desc.xml';
Pluggable database altered.

SQL> select pdb_name, status from cdb_pdbs;

PDB_NAME   STATUS
---------- ---------
PDBTHREE   UNPLUGGED
PDB$SEED   NORMAL
ONEPDB     NORMAL
TWOPDB     NORMAL

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONEPDB                         READ WRITE NO
         4 TWOPDB                         READ WRITE NO
         5 PDBTHREE                       MOUNTED
Drop the PDB with keep file option (default)
SQL> drop pluggable database pdbthree keep datafiles;
Pluggable database dropped.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONEPDB                         READ WRITE NO
         4 TWOPDB                         READ WRITE NO
Copy the files over to the destination server. The location of the file is not the same as source location.
[oracle@hpc5 datafile]$ pwd
/opt/app/oracle/oradata/APCDB/3AE6245AE81713AFE0536300A8C02D00/datafile

[oracle@hpc5 datafile]$ scp -C * hpc1:/home/oracle/backup/pdbthree/
oracle@192.168.0.66's password:
o1_mf_pdbthree_cvy3w4f7_.dbf                                                                                                                                100%   10MB  10.0MB/s   00:00
o1_mf_sysaux_cvxvnvnw_.dbf                                                                                                                                  100%  580MB  24.2MB/s   00:24
o1_mf_system_cvxvnvnl_.dbf                                                                                                                                  100%  260MB  18.6MB/s   00:14
On the destination CDB run the compatibility check. In this case the output says that PDB is not compatible.
SQL> SET SERVEROUTPUT ON
DECLARE
SQL>   2  compatible CONSTANT VARCHAR2(3) :=
  3   CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(  pdb_descr_file => '/home/oracle/backup/pdbthree_desc.xml',  pdb_name => 'PDBTHREE')
  4    WHEN TRUE THEN 'YES'
  5    ELSE 'NO'
  6    END;
  7     BEGIN
  8     DBMS_OUTPUT.PUT_LINE(compatible);
  9     END;
 10     /
NO
Checking the plugin violation view shows the following (last two lines has been shortened)
SQL> select name,cause,status,type,action from PDB_PLUG_IN_VIOLATIONS;

NAME       CAUSE           STATUS    TYPE      ACTION
---------- --------------- --------- --------- --------------------------------------------------
PDBTHREE   SQL patch error PENDING   ERROR     Call datapatch to reinstall
PDBTHREE   SQL patch error PENDING   ERROR     Call datapatch to reinstall
PDBTHREE   SQL Patch       PENDING   ERROR     Call datapatch to install in the PDB or the CDB
PDBTHREE   SQL Patch       PENDING   ERROR     Call datapatch to install in the PDB or the CDB

SQL> select status,message from PDB_PLUG_IN_VIOLATIONS;

STATUS    MESSAGE
--------- ------------------------------------------------------------------------------------------------------------------------------------------------------
PENDING    (PSU bundle patch 160419 (Database Patch Set Update : 12.1.0.2.160419 (22291127)): APPLY SUCCESS):  with status  in the PDB.
PENDING    (SQL patch ID/UID 22674709/20057886 (Database PSU 12.1.0.2.160419, Oracle JavaVM Component (Apr2016)): APPLY SUCCESS):  with status  in the PDB.
PENDING   ... Update : 12.1.0.2.160419 (22291127)): Installed in the CDB but not in the PDB.
PENDING   ... Oracle JavaVM Component (Apr2016)): Installed in the CDB but not in the PDB.
Since it has been confirmed that both destination CDB and PDB being plugged in are both patched to same level this violation is ignored.



The destination uses OMF but different paths for PDBs and the root container files. This path is also different from the OMF path at the source CDB. Login to the CDB and set the db_create_file_dest used for PDBs (if a separate OMF path is used for PDBs) and create the PDB with clone and move clause. source_file_name_convert has been used to specify the file mapping where ('/opt/app/oracle/oradata/APCDB/3AE6245AE81713AFE0536300A8C02D00/datafile') refers to PDB data file path at source and ('/home/oracle/backup/pdbthree') refers to the location where data files were copied into.
SQL> alter system set db_create_file_dest='/ssdoracle/oradata/pdbs' scope=memory;
System altered.

SQL> create pluggable database pdbthree as clone using '/home/oracle/backup/pdbthree_desc.xml' 
source_file_name_convert=('/opt/app/oracle/oradata/APCDB/3AE6245AE81713AFE0536300A8C02D00/datafile','/home/oracle/backup/pdbthree') move;
Pluggable database created.

SQL> select pdb_name, status from cdb_pdbs;

PDB_NAME        STATUS
--------------- ---------
PDBTHREE        NEW
PDB$SEED        NORMAL
ONEPDB          NORMAL
TWOPDB          NORMAL

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONEPDB                         READ WRITE NO
         4 TWOPDB                         READ WRITE NO
         5 PDBTHREE                       MOUNTED

SQL> select con_id,name from v$datafile where con_id=5;

    CON_ID NAME
---------- ----------------------------------------------------------------------------------------------------
         5 /ssdoracle/oradata/pdbs/APCDB/3AE70A7E4DC630F7E0534200A8C0F281/datafile/o1_mf_system_cvxzo517_.dbf
         5 /ssdoracle/oradata/pdbs/APCDB/3AE70A7E4DC630F7E0534200A8C0F281/datafile/o1_mf_sysaux_cvxzo529_.dbf
         5 /ssdoracle/oradata/pdbs/APCDB/3AE70A7E4DC630F7E0534200A8C0F281/datafile/o1_mf_pdbthree_cvxzo52b_.dbf
Finally open the PDB
SQL> alter pluggable database pdbthree open;
Pluggable database altered.

SQL>  select pdb_name, status from cdb_pdbs;

PDB_NAME        STATUS
--------------- ---------
PDBTHREE        NORMAL
PDB$SEED        NORMAL
ONEPDB          NORMAL
TWOPDB          NORMAL

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONEPDB                         READ WRITE NO
         4 TWOPDB                         READ WRITE NO
         5 PDBTHREE                       READ WRITE NO
The CDB doesn't list any more plugin violations
SQL> select name,cause,status,type,action from PDB_PLUG_IN_VIOLATIONS;
no rows selected
Verify the patch levels are reflected
SQL> alter session set container=pdbthree;
Session altered.

SQL> select con_id,patch_id,action,status,description from cdb_registry_sqlpatch where con_id = 5 order by action_time;

    CON_ID   PATCH_ID ACTION     STATUS          DESCRIPTION
---------- ---------- ---------- --------------- ----------------------------------------------------------------------------------------------------
         5   21555660 APPLY      SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         5   21359755 APPLY      SUCCESS         Database Patch Set Update : 12.1.0.2.5 (21359755)
         5   21555660 ROLLBACK   SUCCESS         Database PSU 12.1.0.2.5, Oracle JavaVM Component (Oct2015)
         5   22674709 APPLY      SUCCESS         Database PSU 12.1.0.2.160419, Oracle JavaVM Component (Apr2016)
         5   22291127 APPLY      SUCCESS         Database Patch Set Update : 12.1.0.2.160419 (22291127)
This concludes the steps for moving a PDB between servers.

Related Posts
Remote Cloning of a PDB
Plugging a SE2 non-CDB as an EE PDB Using File Copying and Remote Link

Friday, August 14, 2015

Moving non-RAC Database and ASM Between Servers

There are many strategies to moving a database from one server to another. Backup/duplication, exports base solutions are most common. This post list steps for moving a non-RAC database and ASM (standlone) by way of attaching the underlying storage to the new server. The steps here has been tested using Amazon EC2/ESB combination and using Oracle VirtualBox. As stated in title the current setup includes a standalone non-RAC database using ASM.
1. To able to use ASM in the new sever, install grid infrastructure with software only option. This allow installation of GI without having to create ASM disk groups.

2. When prompted run the root scripts.
# /opt/app/oracle/product/11.2.0/grid_1/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /opt/app/oracle/product/11.2.0/grid_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/opt/app/oracle/product/11.2.0/grid_1/perl/bin/perl -I/opt/app/oracle/product/11.2.0/grid_1/perl/lib -I/opt/app/oracle/product/11.2.0/grid_1/crs/install /opt/app/oracle/product/11.2.0/grid_1/crs/install/roothas.pl


To configure Grid Infrastructure for a Cluster execute the following command:
/opt/app/oracle/product/11.2.0/grid_1/crs/config/config.sh
This command launches the Grid Infrastructure Configuration Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media.


# /opt/app/oracle/product/11.2.0/grid_1/perl/bin/perl -I/opt/app/oracle/product/11.2.0/grid_1/perl/lib -I/opt/app/oracle/product/11.2.0/grid_1/crs/install /opt/app/oracle/product/11.2.0/grid_1/crs/install/roothas.pl
Using configuration parameter file: /opt/app/oracle/product/11.2.0/grid_1/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node rhel6m1 successfully pinned.
Adding Clusterware entries to upstart

rhel6m1     2015/03/10 16:40:10     /opt/app/oracle/product/11.2.0/grid_1/cdata/rhel6m1/backup_20150310_164010.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
3. GI will have following resources created at this stage
$ crsctl stat res
NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.diskmon
TYPE=ora.diskmon.type
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.evmd
TYPE=ora.evm.type
TARGET=ONLINE
STATE=ONLINE on rhel6m1

NAME=ora.ons
TYPE=ora.ons.type
TARGET=OFFLINE
STATE=OFFLINE
4. Install database software with software only option. Patch both GI and database software to the same patch level as the current database setup where database being moved from.
5. If role separation being used them some directory locations ($ORACLE_BASE/admin, $ORACLE_BASE/cfgtoollogs) may not have write permissions for Oracle user, permissions might be set as 755 grid : oinstall. Change permissions as 775 to allow oracle user the write access to these location. Also manually create the audit file location
mkdir -p /opt/app/oracle/admin/ent11g2/adump
6. Copy the listener file from current setup to new server's $GI_HOME/network/admin. Change all reference to the hostname to reflect the new hostname.



7. Attach the storage device(s) to the new server. Depending on the storage type this may require server to shutdown. Once the server is restarted verify the disks that will be used by ASM are visible.Also HA services are running
# crsctl stat res

NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=ONLINE
STATE=ONLINE on rhel6m1
8. With storage attached its only a matter of configuring listener,ASM and database so HAS manage them. First add the listener as grid user.
$ srvctl add listener -l listener -o /opt/app/oracle/product/11.2.0/grid_1 -p 1521
$ srvctl start listener -l listener
$ srvctl status listener -l listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): rhel6m1
9. Secondly add the ASM as grid user. The ASM pfile is located in the local server as opposed to ASM itself.
$ srvctl add asm -l listener -p /opt/app/oracle/product/11.2.0/grid_1/dbs/spfile+ASM.ora -d "/dev/sd*"
$ srvctl start asm
$ srvctl config asm
ASM home: /opt/app/oracle/product/11.2.0/grid_1
ASM listener: LISTENER
Spfile: /opt/app/oracle/product/11.2.0/grid_1/dbs/spfile+ASM.ora
ASM diskgroup discovery string: /dev/sd*
10. Finally as oracle user add the database and modify the auto start options of the resources
srvctl add database -d ent11g2 -o /opt/app/oracle/product/11.2.0/dbhome_1 -p +DATA/ent11g2/spfileent11g2.ora -a "data,flash,apps"
srvctl start database -d ent11g2

crsctl modify resource ora.DATA.dg -attr "AUTO_START"="always"
crsctl modify resource ora.FLASH.dg -attr "AUTO_START"="always"  
crsctl modify resource ora.LISTENER.lsnr -attr "AUTO_START"="always"  
crsctl modify resource ora.ent11g2.db -attr "AUTO_START"="always"
This concludes the steps for moving non-RAC database and ASM by way of attaching storage from one server to another.

Monday, March 18, 2013

Moving 11gR2 RAC to New Set of ASM Diskgroups

This post is for a situation that require moving the RAC components from current set of ASM disk groups to new set of ASM disk group. Situation could arise in the form of moving to higher redundancy disk group than current ASM disk group redundancy or migrating to a new SAN. The steps required to move are actually a collection of previous posts and will be referenced throughout. The post uses setup created with11gR2 RAC installation on RHEL6.
The current setup has 3 ASM diskgroups CLUSTER_DG (Quorum disk group), DATA and FLASH. The new diskgroups are named NEWCLUSTERDG, NEWDATA and NEWFLASH. If the asm_diskstring is different for example if old asm_diskstring is /dev/emcpower* and new asm_diskstring is /dev/mapper/mpath* then asm_diskstring must be edited to include both (old and new) asm_diskstring until all relevant files are moved out of the old set of ASM diskgroup. Once completed asm_diskstring could be edited to include only the currently valid set of disks. If ASMLib is used then this step could be omitted as asm_diskstring would not change (ORCL:* for all). This step is not shown and it is assumed that ASM disk groups could be created without any issue.
The main steps include
1. Moving cluster related files that are in ASM to new ASM diskgroup
2. Moving database related files to new ASM diskgroup

1. Moving cluster related files that are in ASM to new ASM diskgroup
This could be further itemized as follows
1.1. Moving OCR to new ASM diskgroup
1.2. Moving Vote disks to new ASM diskgroup
1.3. Moving server side ASM SPfile to new ASM diskgroup
Same diskgroup will be used for all these files types (OCR,Vote and ASM SPfile) and this disk group is created with a quorum disk.
create diskgroup newclusterdg quorum 
failgroup fail1 disk '/dev/sdg1' 
failgroup fail2 disk '/dev/sdh1' 
failgroup fail3 disk '/dev/sdi1' 
attribute 'compatible.asm'='11.2';

SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
CLUSTER_DG                     MOUNTED
DATA                           MOUNTED
FLASH                          MOUNTED
NEWCLUSTERDG                   MOUNTED   <-- used for moving the cluster files
Once created the diskgroup is only mounted on the node it's created.
crsctl status resource ora.NEWCLUSTERDG.dg
NAME=ora.NEWCLUSTERDG.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE           , OFFLINE
STATE=ONLINE on rhel6m1, OFFLINE
It must be mounted on other nodes as well before continuing with the cluster file moving. Run the following on each node to mount the new diskgroup
 alter diskgroup NEWCLUSTERDG mount;
or mount it accross the cluster with
# crsctl start resource ora.NEWCLUSTERDG.dg
CRS-2672: Attempting to start 'ora.NEWCLUSTERDG.dg' on 'rhel6m2'
CRS-2676: Start of 'ora.NEWCLUSTERDG.dg' on 'rhel6m2' succeeded

crsctl status resource ora.NEWCLUSTERDG.dg
NAME=ora.NEWCLUSTERDG.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE           , ONLINE
STATE=ONLINE on rhel6m1, ONLINE on rhel6m2
or by instance using srvctl
srvctl start diskgroup  -g newclusterdg -n rhel6m2

srvctl status diskgroup  -g newclusterdg -n "rhel6m1,rhel6m2" -a
Disk Group data is running on rhel6m1,rhel6m2
Disk Group data is enabled on rhel6m1,rhel6m2

1.1. Moving OCR to new ASM diskgroup
OCR could be moved to new ASM disk either using the add/delete method or replace option. However when there's only one OCR file (no OCR mirror) then replace option cannot be used. OCR add/delete must be run as root.
ocrcheck  (# current configuration)
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3328
         Available space (kbytes) :     258792
         ID                       : 1487892601
         Device/File Name         : +CLUSTER_DG
                                    Device/File integrity check succeeded

# ocrconfig -replace +CLUSTER_DG -replacement +NEWCLUSTERDG
PROT-28: Cannot delete or replace the only configured Oracle Cluster Registry location
First the new ASM diskgroup must be added and this will appear as the OCRMirror. Afterwards OCR location in the old diskgroup is removed (this will make the ocrmirror to become the ocr).
# ocrconfig -add +NEWCLUSTERDG

# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3344
         Available space (kbytes) :     258776
         ID                       : 1487892601
         Device/File Name         : +CLUSTER_DG
                                    Device/File integrity check succeeded
         Device/File Name         : +NEWCLUSTERDG
                                    Device/File integrity check succeeded


# ocrconfig -delete +CLUSTER_DG

# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3344
         Available space (kbytes) :     258776
         ID                       : 1487892601
         Device/File Name         : +NEWCLUSTERDG
                                    Device/File integrity check succeeded
This concludes the moving of OCR to new ASM diskgroup.
Related Post: Migrating OCR to ASM in 11gR2 Clusterware
Related metalink note : OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE) [ID 428681.1]

1.2. Moving Vote disks to new ASM diskgroup
The vote disk could be moved with the replace option using crsctl. Unlike previous versions (10.2, 11.1) in 11.2 the vote disk replace could be run as grid user. Current vote disk configuration
$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   2c90c4f4a0fb4faebfb264244a836b96 (/dev/sdb1) [CLUSTER_DG]
 2. ONLINE   1d7890a346284fa4bf0e278b2f3b1d3d (/dev/sdc1) [CLUSTER_DG]
 3. ONLINE   433f41571bf44fcebfe636a97d94777a (/dev/sdd1) [CLUSTER_DG]
Located 3 voting disk(s).
Run replace command
$ crsctl replace votedisk +NEWCLUSTERDG
Successful addition of voting disk 58e2e7ab4cdc4fc1bf98b745437a5082.
Successful addition of voting disk 1fb2f493ec644ffdbfaca24bbbf41864.
Successful addition of voting disk 74048ba14f1b4f8dbf677abb76f929c1.
Successful deletion of voting disk 2c90c4f4a0fb4faebfb264244a836b96.
Successful deletion of voting disk 1d7890a346284fa4bf0e278b2f3b1d3d.
Successful deletion of voting disk 433f41571bf44fcebfe636a97d94777a.
Successfully replaced voting disk group with +NEWCLUSTERDG.
CRS-4266: Voting file(s) successfully replaced
New vote disk configuration
$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   58e2e7ab4cdc4fc1bf98b745437a5082 (/dev/sdg1) [NEWCLUSTERDG]
 2. ONLINE   1fb2f493ec644ffdbfaca24bbbf41864 (/dev/sdh1) [NEWCLUSTERDG]
 3. ONLINE   74048ba14f1b4f8dbf677abb76f929c1 (/dev/sdi1) [NEWCLUSTERDG]
Located 3 voting disk(s).
That concludes the moving of vote disk to new ASM diskgroup
Related Post: Migrating Voting Disk to ASM in 11gR2 Clusterware
Related metalink note : OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE) [ID 428681.1]

1.3. Moving server side ASM SPfile to new ASM diskgroup
In 11gR2 RAC and Standalone (Restart) the ASM SPfile reside in the ASM disk group itself. Current location of the ASM Spfile could be obtained in number of ways. Show parameter command (running it on ASM instance)
SQL> show parameter spfile;

NAME      TYPE        VALUE
--------- ----------- ------------------------------------------------------------------
spfile    string      +CLUSTER_DG/rhel6m-cluster/asmparameterfile/registry.253.785350531
It's also visible in the ASM alert log
Machine:        x86_64
Using parameter settings in server-side spfile +CLUSTER_DG/rhel6m-cluster/asmparameterfile/registry.253.785350531
System parameters with non-default values
and with spget on ASMCMD
ASMCMD> spget
+CLUSTER_DG/rhel6m-cluster/asmparameterfile/registry.253.785350531
To move the ASM SPfile to new ASM diskgroup create ASM pfile from the current spfile
SQL> create pfile='/home/grid/asmpfile.ora' from spfile;
Create ASM SPfile in the new ASM diskgroup location using the earlier created pfile
SQL> create spfile='+newclusterdg' from pfile='/home/grid/asmpfile.ora';
New SPfile location will be logged on the ASM alert log
NOTE: updated gpnp profile ASM SPFILE to +NEWCLUSTERDG/rhel6m-cluster/asmparameterfile/registry.253.806083655
This commands update the gpnp profile and during the next restart ASM will use the new SPFile. This could be verified using the ASM alert log or asmcmd spget command. To explicitly set the SPFile location use ASMCMD's spset command (this step is not necessary)
ASMCMD> spset +NEWCLUSTERDG/rhel6m-cluster/asmparameterfile/registry.253.806083655
Using parameter settings in server-side spfile +NEWCLUSTERDG/rhel6m-cluster/asmparameterfile/registry.253.806083655
This concludes the moving of ASM SPfile to new ASM diskgroup
Related metalink note : How to move ASM spfile to a different disk group [ID 1082943.1]

The ASM diskgroup that stores cluster files could be dropped now. However since copies of various files (OCR, ASMSPfile) still reside in it trying to drop without content clause would throw an error
SQL> drop diskgroup cluster_dg;
drop diskgroup cluster_dg
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15053: diskgroup "CLUSTER_DG" contains existing files
It is also important that before dropping the diskgroup is dismounted from all other ASM instances in the cluster, if not an error will be thrown
SQL> drop diskgroup cluster_dg including contents;
drop diskgroup cluster_dg including contents
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15073: diskgroup CLUSTER_DG is mounted by another ASM instance

SQL> alter diskgroup cluster_dg dismount;  <-- run on all ASM instances except one
At times trying to dismount could throw the following error
SQL> alter diskgroup newclusterdg dismount;
alter diskgroup newclusterdg dismount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup "CLUSTER_DG" precludes its dismount
This could be due to file reference still opened even though they are not used. In such cases restart of OHAS on the nodes where dismount fails could resolve this issue.
Once dismounted drop the ASM diskgroup.
SQL> drop diskgroup cluster_dg including contents;
Diskgroup dropped.


2. Moving database related files to new ASM diskgroup

This step could be further itemized as
2.1. Moving control files to new ASM diskgroup
2.2. Moving SPfile to new ASM diskgroup
2.3. Moving data files to new ASM diskgroup
2.4. Moving temp files to new ASM diskgroup
2.5. Moving online redo log files to new ASM diskgroup
2.6. Moving backup files to new ASM diskgroup
Create new disk groups used for data files and fast recovery area and mount them across all the ASM instances
SQL> create diskgroup newdata external redundancy disk '/dev/sdj1';
Diskgroup created.

SQL> create diskgroup newflash external redundancy disk '/dev/sdk1';
Diskgroup created.

SQL> alter diskgroup newdata mount;
Diskgroup altered.

SQL> alter diskgroup newflash mount;
Diskgroup altered.
Metalink note How To Move The Database To Different Diskgroup (Change Diskgroup Redundancy) [ID 438580.1] shows how to move a database from one diskgroup to another using backup database as copy. This is also a valid option to move the database from asm-to-asm. In this post steps are shown to move each individual file type related to the database from one asm disk to another.

2.1. Moving control files to new ASM diskgroup
Currently the system has two control files in two diskgroups
SQL> show parameter control

NAME          TYPE   VALUE
------------- ------ ------------------------------
control_files string +DATA/std11g2/controlfile/current.256.785694741,
                     +FLASH/std11g2/controlfile/current.256.785694743
Before cloning the control files create a pfile from the current SPFile. This pfile will also be used for moving the SPFile as well.
SQL> create pfile='/home/oracle/pfile.ora' from spfile;
File created.
Update the control file locations on the SPFile by specifying the new ASM diskgroups.
SQL> alter system set control_files='+NEWDATA','+NEWFLASH' scope=spfile sid='*';
System altered.
Stop the database and start one instance in nomount mode.
srvctl stop database -d std11g2
srvctl start instance -d std11g2 -i std11g22 -o nomount
Restore control files to new location using the current control file.
rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jan 30 16:56:16 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: STD11G2 (not mounted)

RMAN> restore controlfile from '+DATA/std11g2/controlfile/current.256.785694741';

Starting restore at 30-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=141 instance=std11g22 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+NEWDATA/std11g2/controlfile/current.256.806086607
output file name=+NEWFLASH/std11g2/controlfile/current.256.806086609
Finished restore at 30-JAN-13
Mount and open the database and verify the new control file locations
SQL> alter database mount;
Database altered.

SQL> alter database open;
Database altered.


SQL> show parameter control

NAME          TYPE   VALUE
------------- ------ ------------------------------
control_files string +NEWDATA/std11g2/controlfile/current.256.806086607,
                     +NEWFLASH/std11g2/controlfile/current.256.806086609
This concludes the moving of control files to new ASM disk groups.
Related Post : Cloning/Duplicating controlfile between ASM diskgroups
Related metalink note : How to duplicate a controlfile when ASM is involved [ID 345180.1]
Useful metalink note : How To Move The Database To Different Diskgroup (Change Diskgroup Redundancy) [ID 438580.1]

2.2. Moving SPfile to new ASM diskgroup
If the earlier created pfile is used for creating the spfile in this section modify the control_files parameter value in the pfile to reflect the new locations, otherwise create a new pfile from the spfile which will have the new control files location. Create a spfile in the new asm disk using the pfile (again it's important that control file locations reflect the new values. Modify pfile before creating spfile)
SQL> create spfile='+newdata' FROM PFILE='/home/oracle/pfile.ora';
File created.
Replacing the SPFile involves creating a alias to new spfile and updating the database configuration. Loging to ASM using ASMCMD (as grid user) and create the spfile alias
ASMCMD> mkalias +NEWDATA/STD11G2/PARAMETERFILE/spfile.257.806088197 spfilestd11g2.ora
ASMCMD> ls -l
Type           Redund  Striped  Time             Sys  Name
                                                 Y    CONTROLFILE/
                                                 Y    PARAMETERFILE/
                                                 N    spfilestd11g2.ora => +NEWDATA/STD11G2/PARAMETERFILE/spfile.257.806088197

srvctl config database -d std11g2
Database unique name: std11g2
Database name: std11g2
Oracle home: /opt/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/std11g2/spfilestd11g2.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: std11g2
Database instances: std11g21,std11g22
Disk Groups: DATA,FLASH,NEWDATA,NEWFLASH
Mount point paths:
Services: myservice
Type: RAC
Database is administrator managed

$ srvctl modify database -d std11g2 -p +NEWDATA/std11g2/spfilestd11g2.ora

$ srvctl config database -d std11g2
Database unique name: std11g2
Database name: std11g2
Oracle home: /opt/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +NEWDATA/std11g2/spfilestd11g2.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: std11g2
Database instances: std11g21,std11g22
Disk Groups: DATA,FLASH,NEWDATA,NEWFLASH
Mount point paths:
Services: myservice
Type: RAC
Database is administrator managed
Modify the pfiles that give reference to the SPFile in $ORACLE_HOME/dbs
cat /opt/app/oracle/product/11.2.0/dbhome_1/dbs/initstd11g22.ora

SPFILE='+NEWDATA/std11g2/spfilestd11g2.ora'
Restart the database and SPFile parameter will reflect the new SPFile location.
SQL> show parameter spfile

NAME     TYPE         VALUE 
-------- -----------  --------------------------------
spfile    string      +DATA/std11g2/spfilestd11g2.ora
After DB restart
SQL> show parameter spfile

NAME     TYPE         VALUE 
-------- -----------  --------------------------------
spfile    string      +NEWDATA/std11g2/spfilestd11g2.ora
This concludes the moving of SPFile to new ASM diskgroup.
Related Post : Replacing spfile in ASM
Related Post : Oracle 11gR2 RAC SPfile Issue

2.3. Moving data files to new ASM diskgroup
Moving data files from one ASM disk group to another involves creating a backup of the data file as a copy in the new asm diskgroup and switching to the data file copy. Following SQL could be used to generate the backup as copy rman commands for all the data files
SQL> select 'backup as copy datafile '||file#||' format ''+NEWDATA'';' from v$datafile;
Run a RMAN session using the commands generated above (output is truncated)
RMAN> run{
2> backup as copy datafile 1 format '+NEWDATA';
3> backup as copy datafile 2 format '+NEWDATA';
4> backup as copy datafile 3 format '+NEWDATA';
5> backup as copy datafile 4 format '+NEWDATA';
6> backup as copy datafile 5 format '+NEWDATA';
7> backup as copy datafile 6 format '+NEWDATA';
8> backup as copy datafile 7 format '+NEWDATA';
9> }

Starting backup at 31-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 instance=std11g21 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/std11g2/datafile/system.259.785694749
output file name=+NEWDATA/std11g2/datafile/system.258.806151043 tag=TAG20130131T105042 RECID=2 STAMP=806151061
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
Finished backup at 31-JAN-13
...
...
Shutdown all database instances and start one instance in mount mode
srvctl stop database -d std11g2
srvctl start instance -d std11g2 -i std11g21 -o mount
Use this instance to run the switch to copy command. Following SQL could be used to generate the switch command for all the data files
SQL> select 'switch datafile '||file#||' to copy;' from v$datafile;
Run the switch command from a RMAN session (output is truncated)
switch datafile 1 to copy;
switch datafile 2 to copy;
switch datafile 3 to copy;
switch datafile 4 to copy;
switch datafile 5 to copy;
switch datafile 6 to copy;
switch datafile 7 to copy;

RMAN>datafile 1 switched to datafile copy "+NEWDATA/std11g2/datafile/system.258.806151043"

RMAN>datafile 2 switched to datafile copy "+NEWDATA/std11g2/datafile/sysaux.259.806151073"
...
...
Recover each datafile. Following SQL could be used to generate the recover commands
select 'recover datafile '||file#||';' from v$datafile;
Run a RMAN session to recover the datafiles (output is truncated)
recover datafile 1;
recover datafile 2;
recover datafile 3;
recover datafile 4;
recover datafile 5;
recover datafile 6;
recover datafile 7;

RMAN>
Starting recover at 31-JAN-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 31-JAN-13
...
...
Once the recovery is completed open the database and bring up the other instances
SQL> alter database open;
Take a full backup of the database and delete the data file copies
RMAN> delete datafilecopy all;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 instance=std11g21 device type=DISK
List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time
------- ---- - --------------- ---------- ---------------
9       1    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/system.259.785694749

10      2    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/sysaux.260.785694765

11      3    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/undotbs1.261.785694779

12      4    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/undotbs2.263.785694797

13      5    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/users.264.785694801

14      6    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/example.268.785857285

15      7    A 31-JAN-13       36408130   31-JAN-13
        Name: +DATA/std11g2/datafile/test.269.785857289


Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=+DATA/std11g2/datafile/system.259.785694749 RECID=9 STAMP=806151523
deleted datafile copy
datafile copy file name=+DATA/std11g2/datafile/sysaux.260.785694765 RECID=10 STAMP=806151524
deleted datafile copy
...
...
This concludes the moving of data files to new ASM diskgroup.
Related Post : Moving Datafiles Between ASM Disk Groups
Related Post : Moving Datafiles to new location
Useful metalink note : How to move a datafile from ASM to the file system [ID 390416.1]

2.4. Moving temp files to new ASM diskgroup
To move the temp file, add a new temp file to the temporary tablespace by giving the new asm diskgroup as the location. Once the new temp file is in place remove the existing temp file.
SQL> alter tablespace temp add tempfile '+newdata(tempfile)';
Tablespace altered.

SQL> alter tablespace temp drop tempfile '+DATA/std11g2/tempfile/temp.262.785694783';
Tablespace altered.
This concludes the moving of temp file to new asm diskgroup.

2.5. Moving online redo log files to new ASM diskgroup
Moving online diskgroups could be done in two ways. One is to drop the current online redo log groups and add new online redo log groups in the new disks groups. Second option is to add new log files with new ASM diskgroup locations into the existing diskgroups and then removing log files that reside in the current (about to be removed) location. The second option is shown below. Current log files
SQL> select group#,member from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         1 +DATA/std11g2/onlinelog/group_1.257.785694743
         1 +FLASH/std11g2/onlinelog/group_1.257.785694745
         2 +DATA/std11g2/onlinelog/group_2.258.785694747
         2 +FLASH/std11g2/onlinelog/group_2.258.785694747
         3 +DATA/std11g2/onlinelog/group_3.265.785696921
         3 +FLASH/std11g2/onlinelog/group_3.259.785696923
         4 +DATA/std11g2/onlinelog/group_4.266.785696925
         4 +FLASH/std11g2/onlinelog/group_4.260.785696927
Add log file members using the new ASM diskgroups
SQL> alter database add logfile member '+newdata','+newflash' to group 1;

SQL> select group#,member from v$logfile order by 1;

    GROUP# MEMBER
---------- --------------------------------------------------
         1 +DATA/std11g2/onlinelog/group_1.257.785694743
         1 +FLASH/std11g2/onlinelog/group_1.257.785694745
         1 +NEWDATA/std11g2/onlinelog/group_1.266.806152613
         1 +NEWFLASH/std11g2/onlinelog/group_1.257.806152615
         2 +FLASH/std11g2/onlinelog/group_2.258.785694747
         2 +DATA/std11g2/onlinelog/group_2.258.785694747
         3 +DATA/std11g2/onlinelog/group_3.265.785696921
         3 +FLASH/std11g2/onlinelog/group_3.259.785696923
         4 +FLASH/std11g2/onlinelog/group_4.260.785696927
         4 +DATA/std11g2/onlinelog/group_4.266.785696925
Group 1 now has 4 log files. Add log files to all other groups as well. Switch through all the groups so that newly created log files members also get written to by executing "archive current logs"
SQL> alter system archive log current;
This has to be done until all the log files groups have done a switch and an archive. If not trying to remove the second log file member will result in an error.
SQL> alter database drop logfile member '+DATA/std11g2/onlinelog/group_1.257.785694743';
Database altered.   <--- first member removed without an issue

SQL> alter database drop logfile member '+FLASH/std11g2/onlinelog/group_1.257.785694745';
alter database drop logfile member '+FLASH/std11g2/onlinelog/group_1.257.785694745' <--- trying remove second member gives an error.
*
ERROR at line 1:
ORA-00362: member is required to form a valid logfile in group 1
ORA-01517: log member: '+FLASH/std11g2/onlinelog/group_1.257.785694745'
This is because newly added log files are missing the redo records of the existing log files. If both of them were dropped prior to archive recovery will not find required redo records therefore a full log switch must be performed for all the log file groups before issuing the drop redo command. Once removed only redo log files with the new location will remain
SQL> select group#,member from v$logfile order by 1;

    GROUP# MEMBER
---------- --------------------------------------------------
         1 +NEWFLASH/std11g2/onlinelog/group_1.257.806152615
         1 +NEWDATA/std11g2/onlinelog/group_1.266.806152613
         2 +NEWFLASH/std11g2/onlinelog/group_2.258.806152855
         2 +NEWDATA/std11g2/onlinelog/group_2.267.806152853
         3 +NEWDATA/std11g2/onlinelog/group_3.268.806152859
         3 +NEWFLASH/std11g2/onlinelog/group_3.259.806152859
         4 +NEWDATA/std11g2/onlinelog/group_4.269.806152863
         4 +NEWFLASH/std11g2/onlinelog/group_4.260.806152863
This concludes the moving of online redo log files to new location.
Useful metalink notes : How To Move The Database To Different Diskgroup (Change Diskgroup Redundancy) [ID 438580.1]
Useful metalink notes : How to Change The Location Of Redo Log Files [ID 395062.1]

Related to data files, online redo files there are several database parameters that must be changed. Change db_recovery_file_dest (used as an archive log location among other things)and db_create_file_dest (default datafile location)
NAME      TYPE     VALUE
----------------------- -------- -------
db_recovery_file_dest   string   +FLASH
db_create_file_dest     string   +DATA

SQL> alter system set db_recovery_file_dest='+NEWFLASH' scope=both sid='*';
System altered.

SQL> alter system set db_create_file_dest='+newdata' scope=both sid='*';
System altered.

NAME      TYPE     VALUE
----------------------- -------- -------
db_recovery_file_dest   string   +NEWFLASH
db_create_file_dest     string   +NEWDATA
Change the db_create_online_log_dest* location as well
SQL> alter system set db_create_online_log_dest_1='+newdata' SCOPE=BOTH SID='*';
System altered.

SQL> alter system set db_create_online_log_dest_2='+newflash' SCOPE=BOTH SID='*';
System altered.
Archive the current log files and verify they archive to new location (if only recovery file dest is used for archive logs)
SQL> alter system archive log current;
SQL> select max(sequence#),thread# from v$archived_log  group by thread#;

MAX(SEQUENCE#)    THREAD#
-------------- ----------
           200          1
           151          2

SQL> select name from v$archived_log where (sequence#=200 and thread#=1) or (sequence#=151 and thread#=2);

NAME
----------------------------------------------------------------------
+NEWFLASH/std11g2/archivelog/2013_01_31/thread_1_seq_200.261.806153191
+NEWFLASH/std11g2/archivelog/2013_01_31/thread_2_seq_151.262.806153193
Create a tablespace without specifying the datafile clause and see if db create file dest uses new location
SQL> create tablespace abc;
Tablespace created.

SQL> select tablespace_name,file_name from dba_data_files where tablespace_name='ABC';

TABLESPACE_NAME                FILE_NAME
------------------------------ --------------------------------------------------
ABC                            +NEWDATA/std11g2/datafile/abc.270.806153661
Query following views v$controlfile,v$datafile,v$tempfile,v$logfile (also v$block_change_tracking if block tracking is enabled) to verify that no file exists in the ASM diskgroup about to be dropped. Querying ASM views show what type of files remain in the ASM diskgroups
SQL> select ag.name,af.type from v$asm_diskgroup ag,v$asm_file af where ag.group_number=af.group_number and af.group_number=2;

NAME  TYPE
----- ---------------
DATA  CONTROLFILE
DATA  PARAMETERFILE
Since control file and SPFile both moved out this ASM diskgroup could be dropped. Unmount the diskgroup from all nodes except one and drop it from there.
SQL> alter diskgroup data dismount;
Diskgroup altered.

SQL> drop diskgroup data including contents;
Diskgroup dropped.

2.6. Moving backup files to new ASM diskgroup
In this setup the only backup related parameter was the db_recovery_file_dest parameter which was modified in the 2.5 to reflect the new ASM diskgroup name. Therefore subsequent backups will use this new ASM diskgroup. If the existing backups could be discarded then there's no more steps required and the old ASM diskgroup could be dropped. However if the existing backups need to be moved to the new ASM diskgroup location then further steps are needed.
To clear any archive logs that still remains in the ASM diskgroup that will be dropped, backup and delete the archive logs with
backup archivelog all delete input;
Find out the file types that are in the backup related disk group (in this case flash).
SQL> select distinct af.type,ag.name from v$asm_diskgroup ag,v$asm_file af where ag.group_number=af.group_number and af.group_number=3;

NAME                 TYPE
-------------------- --------------------
FLASH                CONTROLFILE
FLASH                BACKUPSET
FLASH                AUTOBACKUP
Using ASMCMD create a new directory structure in the new ASM diskgroup similar to existing backup files directory structure.
ASMCMD> cd +newflash/std11g2/
ASMCMD> mkdir backupset
ASMCMD> cd backupset
ASMCMD> mkdir 2013_01_31
Remember to copy the files without file number of incarnation. (Explained in ASMCMD cp command fails with ORA-15046 [ID 452158.1])
ASMCMD> cp +flash/std11g2/backupset/2013_01_31/annnf0_TAG20130131T114145_0.266.806154115 +newflash/std11g2/backupset/2013_01_31/annnf0_TAG20130131T114145
copying +flash/std11g2/backupset/2013_01_31/annnf0_TAG20130131T114145_0.266.806154115 -> +newflash/std11g2/backupset/2013_01_31/annnf0_TAG20130131T114145
ASMCMD> ls +newflash/std11g2/backupset/2013_01_31
annnf0_TAG20130131T114145
...
ASMCMD> cp +flash/std11g2/autobackup/2013_01_31/s_806158183.279.806158185 +newflash/std11g2/autobackup/2013_01_31/s_806158183
Once all the backup files are copied over catalog the recovery area
RMAN> catalog recovery area;

using target database control file instead of recovery catalog
searching for all files in the recovery area

List of Files Unknown to the Database
=====================================
File Name: +newflash/STD11G2/backupset/2013_01_31/annnf0_TAG20130131T114145
File Name: +newflash/STD11G2/AUTOBACKUP/2013_01_31/s_806158183

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: +newflash/STD11G2/backupset/2013_01_31/annnf0_TAG20130131T114145
File Name: +newflash/STD11G2/AUTOBACKUP/2013_01_31/s_806158183

List of files in Recovery Area not managed by the database
==========================================================
File Name: +NEWFLASH/std11g2/controlfile/current.256.806086609
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter
File Name: +NEWFLASH/std11g2/onlinelog/group_1.257.806152615
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter
File Name: +NEWFLASH/std11g2/onlinelog/group_2.258.806152855
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter
File Name: +NEWFLASH/std11g2/onlinelog/group_3.259.806152859
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter
File Name: +NEWFLASH/std11g2/onlinelog/group_4.260.806152863
  RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter

number of files not managed by recovery area is 5, totaling 217.84MB
Message "RMAN-07527: Reason: File was not created using DB_RECOVERY_FILE_DEST initialization parameter" has been explained in Ora-19816 raised in alert log after creating new log group in FRA [ID 1100416.1]
Delete backup files in the ASM diskgroup to be removed with
RMAN> delete backup COMPLETED BEFORE 'sysdate -2';
or using backup file specific tag.
RMAN> delete backup tag 'TAG20130131T114145';
It is also possible to drop the backup related files along with the disk group if removing backups files one at a time is not convenient. Verify the types of files in the ASM diskgroup all have been migrated to new ASM diskgroups
SQL> select distinct af.type,ag.name from v$asm_diskgroup ag,v$asm_file af where ag.group_number=af.group_number and af.group_number=3;

TYPE            NAME
--------------- ------------------------------
AUTOBACKUP      FLASH
BACKUPSET       FLASH
CONTROLFILE     FLASH
In this case controflile was migrated and backup files were copied over and remaining files will be dropped along with the disk group. Dismount the disk group being dropped from all ASM instances except one.
SQL> alter diskgroup flash dismount;
Diskgroup altered.
Drop the ASM diskgroup from the ASM instance where it is still mounted
SQL> drop diskgroup flash including contents;
Diskgroup dropped.
With this step the entire RAC is now running on the new set of ASM diskgroups
SQL> select name from v$asm_diskgroup;

NAME
-------------
NEWCLUSTERDG
NEWDATA
NEWFLASH

Monday, July 2, 2012

Moving ASMLib disk to block devices (Non-ASMLib) in 11gR2 RAC

This post list the steps to migrate from ASMLib to block devices in a 11gR2 RAC environment. There's an earlier post which list the step to migrate from ASMLib to block devices in a 11gR2 standalone system.
The cluster users ASM for the vote disk and OCR and current configuration is
crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   6d44155fe5054fb5bfd2abd3dee8a5b2 (ORCL:CLUS1) [CLUSTERDG]
 2. ONLINE   05233de65ba64fbebf13238219316963 (ORCL:CLUS2) [CLUSTERDG]
 3. ONLINE   84202daea6964f1ebf0af8c38e5a88f5 (ORCL:CLUS3) [CLUSTERDG]
Located 3 voting disk(s).
All the ASMLib disks in the system are
kfod disk=all
--------------------------------------------------------------------------------
 Disk          Size Path                                     User     Group
================================================================================
   1:       5114 Mb ORCL:CLUS1                                
   2:       5114 Mb ORCL:CLUS2                                
   3:       5114 Mb ORCL:CLUS3                                
   4:      10236 Mb ORCL:DATA                                 
   5:      10236 Mb ORCL:FLASH                                
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME
================================================================================
     +ASM1 /opt/app/11.2.0/grid3
     +ASM2 /opt/app/11.2.0/grid3
ASM instances
SQL> select inst_id,name,path,label from gv$asm_disk order by 1;

   INST_ID NAME       PATH       LABEL
---------- ---------- ---------- ----------
         1 DATA       ORCL:DATA  DATA
         1 CLUS3      ORCL:CLUS3 CLUS3
         1 CLUS2      ORCL:CLUS2 CLUS2
         1 CLUS1      ORCL:CLUS1 CLUS1
         1 FLASH      ORCL:FLASH FLASH
         2 DATA       ORCL:DATA  DATA
         2 CLUS3      ORCL:CLUS3 CLUS3
         2 CLUS2      ORCL:CLUS2 CLUS2
         2 CLUS1      ORCL:CLUS1 CLUS1
         2 FLASH      ORCL:FLASH FLASH
1. The ASMLib to block device migration could be done in a rolling fashion. Before proceeding shutdown the database instance on the node that's being worked on.
srvctl stop instance -d rac11g2 -i rac11g21
2. Unlike in the previous cases it was not possible to test the migration on a one node and one a single disk group.
/etc/init.d/oracleasm querydisk -d FLASH
Disk "FLASH" is a valid ASM disk on device [8, 81]

ls -l /dev/sd*
...
brw-r----- 1 root disk 8, 80 Jun 25 13:03 /dev/sdf
brw-r----- 1 root disk 8, 81 Jun 25 13:04 /dev/sdf1
brw-r----- 1 root disk 8, 96 Jun 25 13:03 /dev/sdg
brw-r----- 1 root disk 8, 97 Jun 25 13:04 /dev/sdg1

chown oracle:asmadmin /dev/sdf1

SQL> alter diskgroup flash dismount;

Diskgroup altered.

SQL> alter system set asm_diskstring='/dev/sdf1','ORCL:CLUS1','ORCL:CLUS2','ORCL:CLUS3','ORCL:DATA' scope=memory sid='+ASM1';

System altered.
It is important to set the parameter change instance level (sid='+ASM1') otherwise following error will be thrown
SQL> alter system set asm_diskstring='ORCL:CLUS*','ORCL:DATA*','/dev/sdf1' scope=memory;
alter system set asm_diskstring='ORCL:CLUS*','ORCL:DATA*','/dev/sdf1' scope=memory
*
ERROR at line 1:
ORA-32008: error while processing parameter update at instance +ASM2
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-15014: path 'ORCL:FLASH' is not in the discovery set
Mounting the diskgroup again results in diskgroup using the ASMLib disk not the value set on the ASM diskstring parameter, which was happening in non-rac 11gR2 and 11gR1 RAC environments.
Mon Jun 25 13:44:38 2012
SQL> alter diskgroup flash dismount
NOTE: cache dismounting (clean) group 3/0x9A384CBC (FLASH)
NOTE: messaging CKPT to quiesce pins Unix process pid: 6170, image: oracle@rac4.code.net (TNS V1-V3)
Mon Jun 25 13:44:38 2012
NOTE: LGWR doing clean dismount of group 3 (FLASH)
NOTE: LGWR closing thread 1 of diskgroup 3 (FLASH) at ABA 58.1895
NOTE: LGWR released thread recovery enqueue
...
...
Mon Jun 25 13:44:38 2012
NOTE: diskgroup resource ora.FLASH.dg is offline
NOTE: diskgroup resource ora.FLASH.dg is updated
ALTER SYSTEM SET asm_diskstring='/dev/sdf1','ORCL:CLUS1','ORCL:CLUS2','ORCL:CLUS3','ORCL:DATA' SCOPE=MEMORY SID='+ASM1';
SQL> alter diskgroup flash mount
NOTE: cache registered group FLASH number=3 incarn=0xa6c84cc2
NOTE: cache began mount (first) of group FLASH number=3 incarn=0xa6c84cc2
NOTE: Assigning number (3,0) to disk (ORCL:FLASH)
Mon Jun 25 13:44:51 2012
NOTE: GMON heartbeating for grp 3
GMON querying group 3 at 50 for pid 27, osid 6170
3. Therefore all the ASMLib disk in the ASM instance were migrated to block devices
# /etc/init.d/oracleasm querydisk -d FLASH
Disk "FLASH" is a valid ASM disk on device [8, 81]
# /etc/init.d/oracleasm querydisk -d data
Disk "DATA" is a valid ASM disk on device [8, 65]
# /etc/init.d/oracleasm querydisk -d clus1
Disk "CLUS1" is a valid ASM disk on device [8, 17]
# /etc/init.d/oracleasm querydisk -d clus2
Disk "CLUS2" is a valid ASM disk on device [8, 33]
# /etc/init.d/oracleasm querydisk -d clus3
Disk "CLUS3" is a valid ASM disk on device [8, 49]

# chown oracle:asmadmin /dev/sdb1
# chown oracle:asmadmin /dev/sdc1
# chown oracle:asmadmin /dev/sdd1
# chown oracle:asmadmin /dev/sde1

# ls -l /dev/sd*
...
brw-r----- 1 root   disk     8, 16 Jun 25 13:03 /dev/sdb
brw-r----- 1 oracle asmadmin 8, 17 Jun 25 13:04 /dev/sdb1
brw-r----- 1 root   disk     8, 32 Jun 25 13:03 /dev/sdc
brw-r----- 1 oracle asmadmin 8, 33 Jun 25 13:04 /dev/sdc1
brw-r----- 1 root   disk     8, 48 Jun 25 13:03 /dev/sdd
brw-r----- 1 oracle asmadmin 8, 49 Jun 25 13:04 /dev/sdd1
brw-r----- 1 root   disk     8, 64 Jun 25 13:03 /dev/sde
brw-r----- 1 oracle asmadmin 8, 65 Jun 25 13:04 /dev/sde1
brw-r----- 1 root   disk     8, 80 Jun 25 13:03 /dev/sdf
brw-r----- 1 oracle asmadmin 8, 81 Jun 25 13:04 /dev/sdf1
brw-r----- 1 root   disk     8, 96 Jun 25 13:03 /dev/sdg
brw-r----- 1 root   disk     8, 97 Jun 25 13:04 /dev/sdg1
4. Change the asm_diskstring on the ASM instance
SQL> alter system set asm_diskstring='/dev/sdb1','/dev/sdc1','/dev/sdd1','/dev/sde1','/dev/sdf1' scope=spfile sid='+ASM1';

System altered.
5. Create udev rules file in the node
# ASM OCR VOTE
KERNEL=="sdb[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
KERNEL=="sdc[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
KERNEL=="sdd[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"

# ASM DATA
KERNEL=="sde[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"

# ASM FLASH
KERNEL=="sdf[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
6. Shutdown the clusterware stack on the node. Unlike in 11gR1 RAC since clusterware is also dependent on ASM diskgroup a database instance shutdown alone is not enough to complete the migration. A full clusterware stack shutdown on the node that's being worked on is required. Other node can remain open.
# crsctl stop crs


7. Unload the oracleasm module
# /sbin/lsmod  | grep oracleasm
oracleasm              84136  1

# /etc/init.d/oracleasm stop
Dropping Oracle ASMLib disks:                              [  OK  ]
Shutting down the Oracle ASMLib driver:                    [  OK  ]

# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: done
Dropping Oracle ASMLib disks:                              [  OK  ]
Shutting down the Oracle ASMLib driver:                    [  OK  ]

# /sbin/chkconfig oracleasm off
8. Start the crs and verify the new block devices are in use by monitoring the ASM alert log
# crsctl start crs

crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   6d44155fe5054fb5bfd2abd3dee8a5b2 (/dev/sdb1) [CLUSTERDG]
 2. ONLINE   05233de65ba64fbebf13238219316963 (/dev/sdc1) [CLUSTERDG]
 3. ONLINE   84202daea6964f1ebf0af8c38e5a88f5 (/dev/sdd1) [CLUSTERDG]
Located 3 voting disk(s).

SQL> ALTER DISKGROUP ALL MOUNT /* asm agent call crs *//* {0:0:2} */
NOTE: Diskgroups listed in ASM_DISKGROUPS are
         DATA
         FLASH
NOTE: Diskgroup used for Voting files is:
         CLUSTERDG
Diskgroup with spfile:CLUSTERDG
Diskgroup used for OCR is:CLUSTERDG
NOTE: cache registered group CLUSTERDG number=1 incarn=0xeadcf7b1
NOTE: cache began mount (not first) of group CLUSTERDG number=1 incarn=0xeadcf7b1
NOTE: cache registered group DATA number=2 incarn=0xeaecf7b2
NOTE: cache began mount (not first) of group DATA number=2 incarn=0xeaecf7b2
NOTE: cache registered group FLASH number=3 incarn=0xa6ccf7b3
NOTE: cache began mount (not first) of group FLASH number=3 incarn=0xa6ccf7b3
NOTE: Assigning number (1,0) to disk (/dev/sdb1)
NOTE: Assigning number (1,1) to disk (/dev/sdc1)
NOTE: Assigning number (1,2) to disk (/dev/sdd1)
NOTE: Assigning number (2,0) to disk (/dev/sde1)
NOTE: Assigning number (3,0) to disk (/dev/sdf1)
GMON querying group 1 at 4 for pid 23, osid 7880
NOTE: cache opening disk 0 of grp 1: CLUS1 path:/dev/sdb1
NOTE: F1X0 found on disk 0 au 2 fcn 0.0
NOTE: cache opening disk 1 of grp 1: CLUS2 path:/dev/sdc1
NOTE: F1X0 found on disk 1 au 2 fcn 0.0
NOTE: cache opening disk 2 of grp 1: CLUS3 path:/dev/sdd1
NOTE: F1X0 found on disk 2 au 2 fcn 0.0
NOTE: cache mounting (not first) normal redundancy group 1/0xEADCF7B1 (CLUSTERDG)
...
NOTE: cache mounting group 1/0xEADCF7B1 (CLUSTERDG) succeeded
NOTE: cache ending mount (success) of group CLUSTERDG number=1 incarn=0xeadcf7b1
GMON querying group 2 at 5 for pid 23, osid 7880
NOTE: cache opening disk 0 of grp 2: DATA path:/dev/sde1
NOTE: F1X0 found on disk 0 au 2 fcn 0.0
NOTE: cache mounting (not first) external redundancy group 2/0xEAECF7B2 (DATA)
...
NOTE: cache mounting group 2/0xEAECF7B2 (DATA) succeeded
NOTE: cache ending mount (success) of group DATA number=2 incarn=0xeaecf7b2
GMON querying group 3 at 6 for pid 23, osid 7880
NOTE: cache opening disk 0 of grp 3: FLASH path:/dev/sdf1
NOTE: F1X0 found on disk 0 au 2 fcn 0.0
NOTE: cache mounting (not first) external redundancy group 3/0xA6CCF7B3 (FLASH)
9. From the data views
SQL> select inst_id,name,path,label from gv$asm_disk order by 1;

   INST_ID NAME       PATH       LABEL
---------- ---------- ---------- ----------
         1 DATA       /dev/sde1
         1 CLUS3      /dev/sdd1
         1 CLUS2      /dev/sdc1
         1 CLUS1      /dev/sdb1
         1 FLASH      /dev/sdf1
         2 DATA       ORCL:DATA  DATA
         2 CLUS3      ORCL:CLUS3 CLUS3
         2 CLUS2      ORCL:CLUS2 CLUS2
         2 CLUS1      ORCL:CLUS1 CLUS1
         2 FLASH      ORCL:FLASH FLASH

10 rows selected.
10. Since it's verified that ASMLib to block device migration is working make the changes applicable to all ASM instances in the cluster by removing the instance specific asm_diskstring entry and changing the entry applicable to all instances
SQL> alter system reset asm_diskstring scope=spfile sid='+ASM1';

System altered.

SQL> alter system set asm_diskstring='/dev/sdb1','/dev/sdc1','/dev/sdd1','/dev/sde1','/dev/sdf1' scope=spfile;

System altered.
11. Make udev rules file on all the remaining nodes
# ASM OCR VOTE
KERNEL=="sdb[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
KERNEL=="sdc[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
KERNEL=="sdd[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"

# ASM DATA
KERNEL=="sde[1]", OWNER="oracle", GROUP="dba", MODE="660"

# ASM FLASH
KERNEL=="sdf[1]", OWNER="oracle", GROUP="asmadmin", MODE="660"
12. Stop the cluster stack and unload and disable the oracleasm module starting on reboot and start the cluster stack
crsctl stop crs

# /sbin/lsmod  | grep oracleasm
oracleasm              84136  1
# /etc/init.d/oracleasm stop
Dropping Oracle ASMLib disks:                              [  OK  ]
Shutting down the Oracle ASMLib driver:                    [  OK  ]

# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: done
Dropping Oracle ASMLib disks:                              [  OK  ]
Shutting down the Oracle ASMLib driver:                    [  OK  ]

# /sbin/chkconfig oracleasm off

crsctl start crs
13. Remove oracleasm libraries
# rpm -e oracleasmlib-2.0.4-1.el5
# rpm -e oracleasm-2.6.18-194.el5-2.0.5-1.el5
# rpm -e oracleasm-support-2.1.3-1.el5
This concludes the ASMLib to block device migration.

If the correct permission and ownership setting are not set on the block devices the start of the clusterware stack will fail and following could be observed in the ocssd.log
2012-06-25 14:03:35.314: [    CSSD][1093900608]clssnmReadDiscoveryProfile: voting file discovery string(/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1,/dev/sdf1)
2012-06-25 14:03:35.314: [    CSSD][1093900608]clssnmvDDiscThread: using discovery string /dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1,/dev/sdf1 for initial discovery
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Discovery with str:/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1,/dev/sdf1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]UFS discovery with :/dev/sdb1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Fetching UFS disk :/dev/sdb1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]OSS discovery with :/dev/sdb1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Discovery advancing to nxt string :/dev/sdc1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]UFS discovery with :/dev/sdc1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Fetching UFS disk :/dev/sdc1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]OSS discovery with :/dev/sdc1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Discovery advancing to nxt string :/dev/sdd1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]UFS discovery with :/dev/sdd1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Fetching UFS disk :/dev/sdd1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]OSS discovery with :/dev/sdd1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Discovery advancing to nxt string :/dev/sde1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]UFS discovery with :/dev/sde1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]Fetching UFS disk :/dev/sde1:
2012-06-25 14:03:35.314: [   SKGFD][1093900608]OSS discovery with :/dev/sde1:
2012-06-25 14:03:35.315: [   SKGFD][1093900608]Discovery advancing to nxt string :/dev/sdf1:
2012-06-25 14:03:35.315: [   SKGFD][1093900608]UFS discovery with :/dev/sdf1:
2012-06-25 14:03:35.315: [   SKGFD][1093900608]Fetching UFS disk :/dev/sdf1:
2012-06-25 14:03:35.315: [   SKGFD][1093900608]OSS discovery with :/dev/sdf1:
2012-06-25 14:03:35.315: [    CSSD][1093900608]clssnmvDiskVerify: Successful discovery of 0 disks
Setting the correct permission and ownership and restarting the clusterware stack will resolve this issue.

Related Posts
Migrating block devices using ASM instance to ASMLib
Moving ASMLib disk to block devices (Non-ASMLib) in 11gR2 Standalone
Moving ASMLib disk to block devices (Non-ASMLib) in 11gR1 RAC

Useful Metalink Notes
How To Migrate ASMLIB Devices To Block Devices (Non-ASMLIB)? [ID 567508.1]