This method takes advantage of a new feature of RMAN in 12c allowing you to clone database files and apply incrementals to those files from an active database without requiring staging areas. In addition, the source non-CDB application activity can continue while the cloning and incremental applies are being performed. When ready to perform the actual migration, the source non-CDB must be put into READ ONLY mode. At this time, application activity should stop and a final incremental apply performed.
To get the datafiles in the correct ASM directory for the destination PDB, you perform an RMAN BACKUP AS COPY from the source non-CDB while also connected to the destination CDB in the same RMAN session. When using OMF or ASM on the destination, this will ensure that the datafile copies are written to the correct location. The incremental apply is also performed across the network and applied to the datafiles in their destination location.
This operation requires a temporary instance to be used for the incremental apply. When the datafile copies are created, they aren’t known to any databases on the new environment, by using the temporary instance we create a copy of the source non-CDB controlfile on the destination environment and catalog the newly created datafile copies in the temporary instance. We now have an instance that is aware of the files and can perform recovery on them. The temporary instance is used only for this purpose and can be discarded once the migration process is complete. The temporary instance should only be started in either nomount or mount mode, it should never be opened.
If you have an Active Data Guard phyiscal standby in place on the destination, perform the RMAN BACKUP AS COPY and incremental apply process on both the primary and standby destination environments. This will place the files in the correct location on the destination standby environment so that media recovery of the plugin operation can continue without stopping. You must run the process separately for each destination environment, e.g. you will run an RMAN process to copy the files to your destination primary site and also run an RMAN process to copy the files to your destination standby site, you will create a temporary instance on your destination primary site and your destination standby site, etc. Once the final incremental apply is completed on both the destination primary and standby sites, you can plugin the new PDB on the primary with no further action needing to be taken on the standby site.
The example below documents the process with ASM in use for file storage and with an Active Data Guard physical standby database in place.
1. On both the destination primary and standby database environments create a TNS entry to point to the source non-CDB to be migrated. This will be used by RMAN to connect to the source and create the datafile copies on the destination environments and to perform incremental applies across the network with no need for staging area. This connection can use SCAN host.
NONCDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [source-noncdb-scan])(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = [noncdb]) ) )
2. Ensure that there are TNS entries on both the destination primary and standby environments that point to the respective destination instances. In other words, on the destination primary server, there must be a TNS entry pointing to the destination primary database and on the destination standby server, there must be a TNS entry pointing to the destination standby database. These TNS entries can use SCAN hosts.
Destination Primary:
CONT3 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [target-prim-scan])(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = [CONT3]) ) )
Destination Standby:
CONT3STBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [target-stby-scan])(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cont3stby) ) )
3. Copy the TNS entries pointing to the destination primary and standby environments to the source non-CDB environment. These are required to allow the source database to connect to the destinations as part of the BACKUP AS COPY process. These TNS entries can use SCAN hosts. If you used SCAN hosts for the TNS entry pointing to the non-CDB source in the destination environment (first step above) and the source non-CDB is a Real Application Cluster database, these TNS entries pointing to the destination should be on ALL the nodes where the non-CDB database has instances running.
4. Backup as copy the source non-CDB to the destination primary and standby environments connecting to the destination primary and standby database instances. This will create datafile copies of the source non-CDB in the correct directories of ASM, these file copies will not be known to the databases at this point. A TNS connection is needed to both the RMAN target (source 12c non-CDB) and destination (12c CDB). In the RMAN session, connect to the ROOT of the container database you will be migrating to as the clone instance. The source non-CDB can continue application activity while the copies are occurring.
Create a command file similar to the following. The target is the source non-CDB to be migrated, the clone is the destination CDB in which the new PDB will be created.
Primary:
connect target sys@noncdb connect auxiliary sys@cont3 backup as copy database auxiliary format '+data';
Standby:
connect target sys@noncdb connect auxiliary sys@cont3stby backup as copy database auxiliary format '+datad1';
Ensure backup compression on the disk device type is not enabled on the primary database. Backup as copy is not allowed with compression enabled.
RMAN> show device type;
RMAN configuration parameters for database with db_unique_name NONCDB are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
Run the code blocks just created on both the destination primary site and the destination standby site to copy the files from the source non-CDB to destination environments. Note the directory structure for the output files on both the primary and the standby environments (lines starting with “output file name”). These directories will be needed in a later step.
Primary:
$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Wed Sep 4 12:23:17 2013 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> @backup.cmd RMAN> connect target * target database Password: connected to target database: NONCDB (DBID=1643045589) RMAN> connect auxiliary * auxiliary database Password: connected to auxiliary database: CONT3 (DBID=1783201232) RMAN> backup as copy database auxiliary format '+data'; Starting backup at 04-SEP-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=319 device type=DISK ... channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=+DATAD1/NONCDB/DATAFILE/undotbs1.441.825151103 channel ORA_DISK_2: starting datafile copy input datafile file number=00005 name=+DATAD1/NONCDB/DATAFILE/soets.438.825151965 channel ORA_DISK_3: starting datafile copy input datafile file number=00006 name=+DATAD1/NONCDB/DATAFILE/soets2.436.825151971 channel ORA_DISK_4: starting datafile copy input datafile file number=00007 name=+DATAD1/NONCDB/DATAFILE/soets3.451.825151981 ... input datafile file number=00001 name=+DATAD1/NONCDB/DATAFILE/system.455.825151099 output file name=+DATA/CONT3/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.387.825251193 tag=TAG20130904T102613 # Save this directory name to be used later channel ORA_DISK_8: datafile copy complete, elapsed time: 00:01:05 channel ORA_DISK_8: starting datafile copy input datafile file number=00004 name=+DATAD1/NONCDB/DATAFILE/users.288.825151109 output file name=+DATA/CONT3/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.386.825251261 tag=TAG20130904T102613 channel ORA_DISK_8: datafile copy complete, elapsed time: 00:00:05 ... output file name=+DATA/CONT3/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/undotbs1.272.825251181 tag=TAG20130904T102613 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:30 Finished backup at 04-SEP-13 RMAN> **end-of-file**
Standby:
$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Wed Sep 4 10:26:51 2013 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> @backup.cmd RMAN> connect target * target database Password: connected to target database: NONCDB (DBID=1643045589) RMAN> connect auxiliary * auxiliary database Password: connected to auxiliary database: CONT3 (DBID=1783201232) RMAN> backup as copy database auxiliary format '+datad1'; Starting backup at 04-SEP-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=556 device type=DISK ... input datafile file number=00001 name=+DATAD1/NONCDB/DATAFILE/system.455.825151099 output file name=+DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.528.825244029 tag=TAG20130904T102706 # Save this directory name to be used later channel ORA_DISK_7: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_7: starting datafile copy input datafile file number=00004 name=+DATAD1/NONCDB/DATAFILE/users.288.825151109 output file name=+DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.517.825244029 tag=TAG20130904T102706 channel ORA_DISK_8: datafile copy complete, elapsed time: 00:00:16 output file name=+DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.510.825244043 tag=TAG20130904T102706 channel ORA_DISK_7: datafile copy complete, elapsed time: 00:00:01 output file name=+DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/undotbs1.516.825244027 tag=TAG20130904T102706 ... output file name=+DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.515.825244029 tag=TAG20130904T102706 channel ORA_DISK_6: datafile copy complete, elapsed time: 00:00:51 Finished backup at 04-SEP-13 RMAN> RMAN> **end-of-file**
5. Copy the password file from the source non-CDB to the destination sites (both primary and standby) for the temporary instances. The following example shows the password file stored in ASM for the source CDB. The password file is extracted from ASM on the source and written to a local filesystem, then remote copied to the destination environment (both primary and standby). For ease of use, the files should be copied to the $ORACLE_HOME/dbs directory (default location) being used by the temporary instance on the destination environments and should be given a default name of orapw[$ORACLE_SID of the temporary instance].
[oracle@source]$ asmcmd -p ASMCMD [+] > cd datad1/noncdb ASMCMD [+datad1/noncdb] > cp orapwnoncdb /home/oracle/temp/orapwtemp copying +datad1/noncdb/orapwnoncdb -> /home/oracle/temp/orapwtemp
[oracle@source]$ scp /home/oracle/temp/orapwtemp oracle@destination-prim:[ORACLE_HOME]/dbs [oracle@source]$ scp /home/oracle/temp/orapwtemp oracle@destination-stby:[ORACLE_HOME]/dbs/orapwtempstby
6. Create a small pfile for the temporary instances. Although not required to be different for the destination primary and standby environments, for clarity they are different in this example with each temporary instance getting a different DB_UNIQUE_NAME. Note the comments for each initialization parameter setting.
Primary:
db_name=cont4 # MUST match db_name of source CDB/non-CDB db_unique_name=junk # ONLY specify if the source db is on the same system as the TEMP instance control_files='/home/oracle/temp/control1.ctl','/home/oracle/temp/control2.ctl' # Just use local files compatible='12.1.0.0.0' # required if compatible is not set to default value # Since the source is a non-CDB, we do not use the enable_pluggable_database parameter
Standby:
db_name=cont4 # MUST match db_name of source CDB/non-CDB db_unique_name=junkstby # ONLY specify if the source db is on the same system as the TEMP instance control_files='/home/oracle/temp/control1.ctl','/home/oracle/temp/control2.ctl' # Just use local files compatible='12.1.0.0.0' # required if compatible is not set to default value # Since the source is a non-CDB, we do not use the enable_pluggable_database parameter
7. Create a TNS alias for the destination temporary instances. This should be done on the environment you will be running RMAN (in this example, the destination primary and standby environments). If you needed to specify DB_UNIQUE_NAME, the same value must also be specified for the SERVICE_NAME in the TNS address. Do not use the SCAN address for the host as the temporary instances will not be registered with the SCAN listener. (UR = A ) is required to allow you to connect to the service while the database is in mount/nomount mode.
Primary:
TEMP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [primhostdb01])(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = junk) (UR = A) ) )
Standby:
TEMPSTBY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = [stbyhostdb01])(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = junkstby) (UR = A) ) )
8. Startup nomount the temporary instances on the destination primary and standby environments using the pfiles created above.
Primary:
$ export ORACLE_SID=[temp] $ sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Wed Sep 4 12:51:52 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount pfile='/home/oracle/demo/pfile.ora' ORACLE instance started. Total System Global Area 384200704 bytes Fixed Size 2288536 bytes Variable Size 322962536 bytes Database Buffers 50331648 bytes Redo Buffers 8617984 bytes
Standby:
$ export ORACLE_SID=[tempstby] $ sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Wed Sep 4 10:53:06 2013 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount pfile='/home/oracle/demo/pfile.ora' ORACLE instance started. Total System Global Area 634732544 bytes Fixed Size 2291424 bytes Variable Size 524290336 bytes Database Buffers 100663296 bytes Redo Buffers 7487488 bytes
9. Restore the controlfile from the source non-CDB to both the destination primary and standby environment temporary instances. Connect to the temporary instances using TNS (e.g. rman target sys@temp).
The FROM SERVICE clause in the RESTORE command provides the connection to the source non-CDB. The clause in the example uses the TNS alias for the source non-CDB created above. This is the only connection used and required for the source non-CDB in these commands.
Primary:
$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Wed Sep 4 13:32:03 2013 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> connect target sys@[temp] target database Password: connected to target database: NONCDB (not mounted) RMAN> restore controlfile from service noncdb; Starting restore at 04-SEP-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=790 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service noncdb channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 output file name=/home/oracle/demo/control1.ctl output file name=/home/oracle/demo/control2.ctl Finished restore at 04-SEP-13
Standby:
$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Wed Sep 4 11:33:33 2013 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> connect target sys@[tempstby] target database Password: connected to target database: NONCDB (not mounted) RMAN> restore controlfile from service noncdb; Starting restore at 04-SEP-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=514 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: using network backup set from service noncdb channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/home/oracle/demo/control1.ctl output file name=/home/oracle/demo/control2.ctl Finished restore at 04-SEP-13
10. Mount the temporary instances on the destination primary and standby environments to allow for cataloging the cloned database files.
RMAN> alter database mount; Statement processed
Catalog the datafiles in the temporary instances on the destination primary and standby environments using “START WITH” to locate the datafile copies restored above. The directory location can be found in the BACKUP AS COPY screen output in lines starting with “output file name”.
Primary:
RMAN> catalog start with '+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE'; searching for all files that match the pattern +DATA/CONT3/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE List of Files Unknown to the Database ===================================== File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.283.825173903 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.388.825182125 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.259.825200151 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.272.825251181 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS.384.825251183 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS2.390.825251185 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS3.374.825251187 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS4.389.825251189 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS5.373.825251191 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSAUX.385.825251191 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSTEM.387.825251193 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/USERS.386.825251261 Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done List of Cataloged Files ======================= File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.283.825173903 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.388.825182125 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.259.825200151 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.272.825251181 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS.384.825251183 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS2.390.825251185 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS3.374.825251187 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS4.389.825251189 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS5.373.825251191 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSAUX.385.825251191 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSTEM.387.825251193 File Name: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/USERS.386.825251261
Standby:
RMAN> catalog start with '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE'; searching for all files that match the pattern +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE List of Files Unknown to the Database ===================================== File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.516.825244027 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS.511.825244027 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS2.513.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS3.529.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS4.514.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSAUX.528.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS5.515.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSTEM.517.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/USERS.510.825244043 Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done List of Cataloged Files ======================= File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/UNDOTBS1.516.825244027 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS.511.825244027 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS2.513.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS3.529.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS4.514.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSAUX.528.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS5.515.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSTEM.517.825244029 File Name: +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/USERS.510.825244043
11. Switch the files in temporary instances on the destination primary and standby environments to the datafile copies just cataloged
Primary:
RMAN> switch database to copy; datafile 1 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.387.825251193" datafile 2 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.385.825251191" datafile 3 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/undotbs1.272.825251181" datafile 4 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.386.825251261" datafile 5 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets.384.825251183" datafile 6 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets2.390.825251185" datafile 7 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets3.374.825251187" datafile 8 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets4.389.825251189" datafile 9 switched to datafile copy "+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.373.825251191"
Standby:
RMAN> switch database to copy; datafile 1 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.517.825244029" datafile 2 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.528.825244029" datafile 3 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/undotbs1.516.825244027" datafile 4 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.510.825244043" datafile 5 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets.511.825244027" datafile 6 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets2.513.825244029" datafile 7 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets3.529.825244029" datafile 8 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets4.514.825244029" datafile 9 switched to datafile copy "+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.515.825244029"
12. Set RMAN parallelism in the temporary instances on both destination primary and standby environments:
RMAN> configure device type disk parallelism 8; old RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 8 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored
At periodic intervals, perform incremental applies from the source non-CDB to the temporary instances on the destination primary and standby environments to keep the destination datafiles somewhat current. This can be done as many times as necessary until you are ready to perform the migration. The incremental process will compare the files in the temporary instances with the files in the source non-CDB and determine which files need recovery applied, thus the recovery work that is done can be different in each of the primary environment temporary instance and the standby temporary instance, depending on the states of their respective files. The source non-CDB can continue application activity while the incremental applies are occurring.
The FROM SERVICE clause in the RECOVER command provides the connection to the source non-CDB. The clause in the example uses the TNS alias for the source non-CDB created above. This is the only connection used and required for the source non-CDB in these commands.
Primary:
RMAN> connect target sys@[temp] target database Password: connected to target database: NONCDB (mounted)
RMAN> recover database noredo from service noncdb; Starting recover at 04-SEP-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=136 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=529 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=660 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=791 device type=DISK allocated channel: ORA_DISK_5 channel ORA_DISK_5: SID=922 device type=DISK allocated channel: ORA_DISK_6 channel ORA_DISK_6: SID=6 device type=DISK allocated channel: ORA_DISK_7 channel ORA_DISK_7: SID=137 device type=DISK allocated channel: ORA_DISK_8 channel ORA_DISK_8: SID=268 device type=DISK channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: using network backup set from service noncdb destination for restore of datafile 00001: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.387.825251193 channel ORA_DISK_2: starting incremental datafile backup set restore channel ORA_DISK_2: using network backup set from service noncdb destination for restore of datafile 00002: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.385.825251191 channel ORA_DISK_3: starting incremental datafile backup set restore channel ORA_DISK_3: using network backup set from service noncdb destination for restore of datafile 00003: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/undotbs1.272.825251181 channel ORA_DISK_4: starting incremental datafile backup set restore channel ORA_DISK_4: using network backup set from service noncdb destination for restore of datafile 00004: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.386.825251261 channel ORA_DISK_5: starting incremental datafile backup set restore channel ORA_DISK_5: using network backup set from service noncdb destination for restore of datafile 00005: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets.384.825251183 channel ORA_DISK_6: starting incremental datafile backup set restore channel ORA_DISK_6: using network backup set from service noncdb destination for restore of datafile 00006: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets2.390.825251185 channel ORA_DISK_7: starting incremental datafile backup set restore channel ORA_DISK_7: using network backup set from service noncdb destination for restore of datafile 00007: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets3.374.825251187 channel ORA_DISK_8: starting incremental datafile backup set restore channel ORA_DISK_8: using network backup set from service noncdb destination for restore of datafile 00008: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets4.389.825251189 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: using network backup set from service noncdb destination for restore of datafile 00009: +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.373.825251191 channel ORA_DISK_4: restore complete, elapsed time: 00:00:08 channel ORA_DISK_6: restore complete, elapsed time: 00:00:15 channel ORA_DISK_7: restore complete, elapsed time: 00:00:15 channel ORA_DISK_8: restore complete, elapsed time: 00:00:14 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_DISK_2: restore complete, elapsed time: 00:00:33 channel ORA_DISK_5: restore complete, elapsed time: 00:01:43 channel ORA_DISK_3: restore complete, elapsed time: 00:02:23 Finished recover at 04-SEP-13
Standby:
RMAN> connect target sys@[tempstby] target database Password: connected to target database: NONCDB (mounted)
RMAN> recover database noredo from service noncdb; Starting recover at 04-SEP-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=770 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=834 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=898 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=961 device type=DISK allocated channel: ORA_DISK_5 channel ORA_DISK_5: SID=1026 device type=DISK allocated channel: ORA_DISK_6 channel ORA_DISK_6: SID=1090 device type=DISK allocated channel: ORA_DISK_7 channel ORA_DISK_7: SID=1154 device type=DISK allocated channel: ORA_DISK_8 channel ORA_DISK_8: SID=1218 device type=DISK skipping datafile 1; already restored to SCN 7688784 skipping datafile 2; already restored to SCN 7688782 skipping datafile 3; already restored to SCN 7688777 skipping datafile 5; already restored to SCN 7688778 skipping datafile 6; already restored to SCN 7688779 skipping datafile 7; already restored to SCN 7688780 skipping datafile 8; already restored to SCN 7688781 skipping datafile 9; already restored to SCN 7688783 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: using network backup set from service noncdb destination for restore of datafile 00004: +DATAD1/CONT3STBY/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.510.825244043 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 04-SEP-13
13. Build the plugin statement to be executed on the destination primary database. use the SOURCE_FILE_DIRECTORY clause to point to the location the files were restored to on the destination CDB primary database environment. Note that the plugin process will search for files in the SOURCE_FILE_DIRECTORY that match the information contained in the manifest XML file created by the DBMS_PDB.DESCRIBE execution. Use the NOCOPY clause as the files are already in their intended location. This statement can be pre-created outside of the outage window.
create pluggable database my_pdb using '/home/oracle/noncdb/noncdb_unplug.xml' source_file_directory= '+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE' nocopy;
14. Shutdown the source non-CDB and restart it read only. The shutdown must not be done ABORT. At this time, application activity should cease.
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 3206836224 bytes Fixed Size 3079928 bytes Variable Size 922747144 bytes Database Buffers 2264924160 bytes Redo Buffers 16084992 bytes Database mounted. SQL> alter database open read only; Database altered.
15. On the source non-CDB, using DBMS_PDB.DESCRIBE(), create the xml manifest for the source non-CDB:
SQL> exec dbms_pdb.describe('/home/oracle/demo/noncdb_unplug.xml'); PL/SQL procedure successfully completed.
16. Leave the source non-CDB running and perform a final incremental apply through the temporary instances on the destination primary and standby environments.
Primary:
recover database noredo from service noncdb;
Standby:
recover database noredo from service noncdb;
17. Shutdown the temporary instances.
18. Copy the xml manifest file to the destination primary host.
19. If your diskgroup names are different between your destination primary and standby, ensure that you have db_file_name_convert set on the standby specifying only the diskgroup names.
Standby:
SQL> show parameter db_file_name_convert NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string +DATA, +DATAC1
20. Login to the destination CDB primary and plugin the non-CDB as a PDB using the plugin statement created above. As long as the files already exist on the standby prior to the plugin, are in the correct directory ([dgname]/[dbuniqname]/[guid]/DATAFILE for ASM) and are current on the destination standby environment, no additional steps are needed for the standby. Media recovery will find the files and continue processing.
SQL> set echo on SQL> @plugin_mypdb SQL> create pluggable database my_pdb using '/home/oracle/demo/noncdb_unplug.xml' 2 source_file_directory= '+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE' 3 nocopy; Pluggable database created.
Here is sample output from the alert log on the primary for finding the files:
Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/system.455.825151099 with afn -1 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSTEM.384.825258561 for original file-+DATAD1/NONCDB/DATAFILE/system.455.825151099 with afn-1 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/sysaux.317.825151101 with afn -2 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SYSAUX.390.825258559 for original file-+DATAD1/NONCDB/DATAFILE/sysaux.317.825151101 with afn-2 Creating new file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/temp.444.825151103 for original file-+DATAD1/NONCDB/TEMPFILE/temp.444.825151103 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/users.288.825151109 with afn -4 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/USERS.272.825258627 for original file-+DATAD1/NONCDB/DATAFILE/users.288.825151109 with afn-4 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/soets.438.825151965 with afn -5 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS.387.825258551 for original file-+DATAD1/NONCDB/DATAFILE/soets.438.825151965 with afn-5 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/soets2.436.825151971 with afn -6 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS2.385.825258553 for original file-+DATAD1/NONCDB/DATAFILE/soets2.436.825151971 with afn-6 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/soets3.451.825151981 with afn -7 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS3.373.825258555 for original file-+DATAD1/NONCDB/DATAFILE/soets3.451.825151981 with afn-7 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/soets4.452.825151987 with afn -8 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS4.389.825258557 for original file-+DATAD1/NONCDB/DATAFILE/soets4.452.825151987 with afn-8 Scanning source datafile directory - +DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for file originally created as +DATAD1/NONCDB/DATAFILE/soets5.443.825151993 with afn -9 Using file-+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/SOETS5.374.825258557 for original file-+DATAD1/NONCDB/DATAFILE/soets5.443.825151993 with afn-9
Here is sample output from the alert log on the standby for finding the file:
Wed Sep 04 12:43:07 2013 Recovery scanning directory +DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE for any matching files Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/system.384.825258561 Successfully added datafile 37 to media recovery Datafile #37: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.511.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/sysaux.390.825258559 Successfully added datafile 38 to media recovery Datafile #38: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.528.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/users.272.825258627 Successfully added datafile 39 to media recovery Datafile #39: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.516.825251265' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/soets.387.825258551 Successfully added datafile 40 to media recovery Datafile #40: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets.517.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/soets2.385.825258553 Successfully added datafile 41 to media recovery Datafile #41: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets2.515.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/soets3.373.825258555 Successfully added datafile 42 to media recovery Datafile #42: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets3.514.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/soets4.389.825258557 Successfully added datafile 43 to media recovery Datafile #43: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets4.529.825251253' Deleted Oracle managed file +DATAD1/[CONT3]/e57ca3f121dfd48ae043f646f40a61ea/datafile/soets5.374.825258557 Successfully added datafile 44 to media recovery Datafile #44: '+DATAD1/[CONT3STBY]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.513.825251253'
21. In the same SQL*Plus session in the destination primary CDB root used by the plugin operation, complete the conversion of the non-CDB to a PDB using the noncdb_to_pdb.sql script. You will connect to the newly created PDB, the PDB should be in mount mode (not open) and the script should be executed while connected to the PDB.
SQL> alter session set container=my_pdb; Session altered.
SQL> @?/rdbms/admin/noncdb_to_pdb SQL> Rem SQL> Rem $Header: rdbms/admin/noncdb_to_pdb.sql /st_rdbms_12.1.0.1/9 2013/04/14 20:05:50 talliu Exp $ SQL> Rem SQL> Rem noncdb_to_pdb.sql SQL> Rem SQL> Rem Copyright (c) 2011, 2013, Oracle and/or its affiliates. SQL> Rem All rights reserved. SQL> Rem SQL> Rem NAME SQL> Rem noncdb_to_pdb.sql - Convert PDB SQL> Rem SQL> Rem DESCRIPTION SQL> Rem Converts DB to PDB. SQL> Rem SQL> Rem NOTES SQL> Rem Given a DB with proper obj$ common bits set, we convert it to a proper SQL> Rem PDB by deleting unnecessary metadata. SQL> Rem SQL> Rem MODIFIED (MM/DD/YY) SQL> Rem sankejai 04/11/13 - 16530655: do not update status in container$ SQL> Rem pyam 04/03/13 - rename temp cdb$* views, to not interfere when SQL> Rem this is run in multiple PDBs simultaneously SQL> Rem pyam 02/06/13 - error out for non-CDB SQL> Rem pyam 01/21/13 - stop exiting on sqlerror at end ... TIMESTAMP -------------------------------------------------------------------------------- COMP_TIMESTAMP UTLRP_BGN 2013-09-04 14:46:41 1 row selected. SQL> SQL> DOC DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid DOC> objects in the database. Recompilation time is proportional to the DOC> number of invalid objects in the database, so this command may take DOC> a long time to execute on a database with a large number of invalid DOC> objects. DOC> DOC> Use the following queries to track recompilation progress: ... SQL> -- leave the PDB in the same state it was when we started SQL> BEGIN 2 execute immediate '&open_sql &restricted_state'; 3 EXCEPTION 4 WHEN OTHERS THEN 5 BEGIN 6 IF (sqlcode <> -900) THEN 7 RAISE; 8 END IF; 9 END; 10 END; 11 / PL/SQL procedure successfully completed. SQL> SQL> WHENEVER SQLERROR CONTINUE; SQL>
22. Once the script completes successfully, open the PDB on the primary database. The PDB will have a STATUS of NEW on both the primary and standby until the PDB is opened for the first time in the primary at which time the status will change to NORMAL. This initial open must be performed on the primary. There is a small amount of redo generated by this initial open which will be transported to the standby database and applied via media recovery. Until this redo is applied on the standby to change the status from NEW to NORMAL, the PDB cannot be opened on the standby database.
SQL> alter session set container=cdb$root; Session altered.
SQL> alter pluggable database stark open instances=all; Pluggable database altered.
23. On the standby, ensure the new PDB has a NORMAL status and open the PDB on standby. If you did not specify the TEMPFILE REUSE clause on the CREATE PLUGGABLE DATABASE statement, add a file to the TEMP tablespace on the standby.
SQL> select pdb_name, status from cdb_pdbs; PDB_NAME STATUS -------------------- ------------- PDB$SEED NORMAL STARK NORMAL MY_PDB NORMAL
SQL> alter pluggable database my_pdb open instances=all; Pluggable database altered. SQL> alter session set container=my_pdb; Session altered. SQL> alter tablespace temp add tempfile '+DATA1' size 10g; Tablespace altered.
24. Backup the PDB. It cannot be recovered on the new container database without a backup:
RMAN> backup pluggable database my_pdb; Starting backup at 06-SEP-13 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00040 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets.387.825258551 input datafile file number=00041 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets2.385.825258553 input datafile file number=00042 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets3.373.825258555 input datafile file number=00043 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets4.389.825258557 input datafile file number=00044 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/soets5.374.825258557 input datafile file number=00038 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/sysaux.390.825258559 input datafile file number=00037 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/system.384.825258561 input datafile file number=00039 name=+DATA/[CONT3]/E57CA3F121DFD48AE043F646F40A61EA/DATAFILE/users.272.825258627 channel ORA_DISK_1: starting piece 1 at 06-SEP-13 channel ORA_DISK_1: finished piece 1 at 06-SEP-13 piece handle=+RECO/CONT3/E57CA3F121DFD48AE043F646F40A61EA/BACKUPSET/2013_09_06/nnndf0_tag20130906t152558_0.381.825434759 tag=TAG20130906T152558 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16 Finished backup at 06-SEP-13 Starting Control File and SPFILE Autobackup at 06-SEP-13 piece handle=+RECO/CONT3/AUTOBACKUP/2013_09_06/s_825434834.358.825434835 comment=NONE Finished Control File and SPFILE Autobackup at 06-SEP-13