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