Introduction
For versions of Oracle 11g R2, Oracle Recovery Manager (RMAN) replicates a database to a different Oracle home and opens it with NORESET LOGS option. From Oracle 12cR1, database RMAN introduced an option called ‘NO OPEN’, which duplicates your database to a new location and keeps it in an unopened state. Using this feature we can duplicate a database to more recent target database version, allowing us to update our existing database to the most recent version.
RMAN duplicate command using backup:
Duplicate process can make use of an existing source database backup. All backup pieces should be kept in the same location and the location should be same for both source and destination.
Configuring the source server:
- Switch the source database to archive log mode if it is not already:
1 |
SQL> select log_mode from v$database; |
In the mount state change the LOG mode of the database:
1 |
SQL> alter database archivelog; |
Execute the pre-upgrade script at source database server and make necessary changes for upgrade. Pre-upgrade script (Preupgrd.sql, utluppkg.sql) is located at: <Target Database server home>/rdbms/admin
- Copy the file(s) to source Oracle home and execute it as ‘SYS’ user. This will validate the source database and provide recommendations for performing the upgrade process. This is a mandatory step for the upgrade process.
- Take a full backup of the source database including archive logs. A RMAN full database backup has to be taken. Your database can be either in the OPEN or MOUNT state. Use following commands:
1 2 |
RMAN> connect target / catalog <catalog_schema>/<password>@<catalog database> RMAN> backup database including archivelog; |
This will generate a backup set.
- Create pfile from spfile:
1 |
SQL> create pfile from spfile; |
Move your database backup and the backup of pfile to the target database server.
Configuring the Target Database Server
- Create a password file for the database service
Orapwd file=<12c password file> password=<password for sys user>
- Make the necessary changes to initialization file at target database server.
Change the compatible parameter value if it is recommended by pre-upgrade script.
- Start the database in nomount state:
1 |
SQL> startup nomount pfile=<modified pfile> |
- Ensure that you keep the backup pieces at same location as the source database server. This is required as catalog has recorded the backup location.
- Execute the duplicate database command with the “No Open” option using backup location:
1 2 3 |
RMAN> Connect target / RMAN> Duplicate database to ‘DB12c’ nopen backup location ‘<location of backup>’; |
- Start the database in upgrade mode with the reset logs option
1 |
SQL> alter database open resetlogs upgrade; |
- Execute catupgrade script using catctl.pl script:
1 |
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catctl.pl –n <parallelism> -l <log location> catupgrd.sql |
- Check the database component status:
1 2 3 4 5 6 |
col comp_id format a10 col comp_name format a30 col version format a10 col status format a8 select substr(comp_id,1,15) comp_id,substr(comp_name,1,30) comp_name,substr(version,1,10) version,status from dba_registry |
- Make an entry in the listener file for database service.
- Create tnsnames.ora entry for the newly-created database service.
- Restart the listener.
Scenario: Upgrading an Oracle 10g database to an Oracle 12c database using the RMAN Duplicate method. The versions of source database and target database :
- Source database: DB10g (10.2.0.5.0)
- Target database: DB12c (12.1.0.1.0)
The Steps:
- Switch the source database from No Archive Log Mode to Archive Log Mode if it is not already that way:
1 2 3 4 5 6 7 8 |
SYS:DB10g> startup mount ORACLE instance started. Total System Global Area 876609536 bytes Fixed Size 2100232 bytes Variable Size 234882040 bytes Database Buffers 633339904 bytes Redo Buffers 6287360 bytes Database mounted. |
- Check the LOG Mode from v$database view
1 2 3 4 |
SYS:DB10g> select log_mode from v$database; LOG_MODE ---------------- NOARCHIVELOG |
1 2 |
SYS:DB10g> alter database archivelog; Database altered. |
- Check the LOG Mode after converting from v$database view
1 2 3 4 |
SYS:DB10g> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG |
1 2 |
SYS:DB10g> alter database open; Database altered. |
- Execute the pre-upgrade script at the source database server, review the output and make necessary changes for the upgrade.
1 2 3 4 |
SYS:DB10g> @preupgrd.sql Loading Pre-Upgrade Package... Executing Pre-Upgrade Checks... Pre-Upgrade Checks Complete. |
Results of the checks are located at:
1 |
/u01/app/oracle/cfgtoollogs/DB10g/preupgrade/preupgrade.log |
Pre-Upgrade Fixup Script (run in source database environment):
1 |
/u01/app/oracle/cfgtoollogs/DB10g/preupgrade/preupgrade_fixups.sql |
Post-Upgrade Fixup Script (run shortly after upgrade):
1 |
/u01/app/oracle/cfgtoollogs/DB10g/preupgrade/postupgrade_fixups.sql |
1 2 3 4 5 6 |
************************************************************ Fixup scripts must be reviewed prior to being executed. ************************************************************ ************************************************************ ====>> USER ACTION REQUIRED <<==== ************************************************************ |
The following are Error level conditions that must be addressed prior to attempting your upgrade. Failure to do so will result in a failed upgrade:
- Check Tag 1: COMPATIBLE_PARAMETER
12345Check Summary: Verify that the compatible parameter value is valid FixupSummary:""compatible" parameter must be increased manually prior to upgrade."+++ Source Database Manual Action Required +++
You must resolve the above error prior to upgrade.
The Minimum Compatible parameter value for Oracle 12c database is 11.1.0.0.0. This needs to be modified in the parameter file. Check /u01/app/oracle/cfgtoollogs/DB10g/preupgrade/preupgrade.log
for recommended changes to the database for performing the upgrade.
- Take full backup of the 10g database including archive logs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
oracle@localhost:/u01/app/oracle/product/10.2.0/rdbms/admin$ rman target / Recovery Manager: Release 10.2.0.5.0 - Production on Fri Jun 12 18:21:21 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: DB10G (DBID=269577939) RMAN> backup database plus archivelog tag 'Full database backup'; Starting backup at 12-JUN-15 current log archived allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=143 devtype=DISK channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=1 recid=19 stamp=882072342 input archive log thread=1 sequence=2 recid=20 stamp=882073330 input archive log thread=1 sequence=4 recid=21 stamp=882210136 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8ttl8_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=11 recid=2 stamp=881380916 input archive log thread=1 sequence=12 recid=4 stamp=881380916 input archive log thread=1 sequence=13 recid=5 stamp=881380916 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8v2mr_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=1 recid=7 stamp=881383026 input archive log thread=1 sequence=2 recid=8 stamp=881383027 input archive log thread=1 sequence=3 recid=9 stamp=881383032 input archive log thread=1 sequence=4 recid=10 stamp=881383032 input archive log thread=1 sequence=5 recid=11 stamp=881383035 input archive log thread=1 sequence=6 recid=12 stamp=881383035 input archive log thread=1 sequence=7 recid=13 stamp=881383038 input archive log thread=1 sequence=8 recid=17 stamp=881383308 input archive log thread=1 sequence=9 recid=18 stamp=881383308 input archive log thread=1 sequence=10 recid=16 stamp=881383307 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8v4pz_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=1 recid=1 stamp=881380916 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8v6s3_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=1 recid=3 stamp=881380916 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8v8vq_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 12-JUN-15 Starting backup at 12-JUN-15 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/DB10g/system01.dbf input datafile fno=00003 name=/oradata/DB10g/sysaux01.dbf input datafile fno=00002 name=/oradata/DB10g/undotbs01.dbf input datafile fno=00004 name=/oradata/DB10g/users01.dbf channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_nnndf_TAG20150612T182233_bqp8vbp6_.bkp tag=TAG20150612T182233 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current control file in backupset including current SPFILE in backupset channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_ncsnf_TAG20150612T182233_bqp8wrnd_.bkp tag=TAG20150612T182233 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04 Finished backup at 12-JUN-15 Starting backup at 12-JUN-15 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=5 recid=22 stamp=882210203 channel ORA_DISK_1: starting piece 1 at 12-JUN-15 channel ORA_DISK_1: finished piece 1 at 12-JUN-15 piece handle=/oradata/DB10g/DB10G/backupset/2015_06_12/o1_mf_annnn_FULL_DATABASE_BACKUP_bqp8wwrc_.bkp tag=FULL DATABASE BACKUP comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 12-JUN-15 |
- Created pfile from spfile:
1 2 |
SYS:DB10g> create pfile from spfile; File created. |
- Move the Oracle 10g database backup and pfile to target database server.
Create a password file for database service. The database name can be different from the source database server.
1 2 3 4 5 |
oracle@localhost:~$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0 oracle@localhost:~$ export PATH=$ORACLE_HOME/bin:$PATH oracle@localhost:/u01/app/oracle/product/12.1.0/dbs$ orapwd file=orapwDB12c password=syspwd entries=5 oracle@localhost:/u01/app/oracle/product/12.1.0/dbs$ ls -lrt orapwDB12c -rw-r----- 1 oracle oinstall 5120 Jun 12 18:28 orapwDB12c |
- Make the necessary changes to the initialization file at target database server. Change the compatible parameter value if it is recommended by the Pre-upgrade script. For Oracle 12c, the minimum required compatible parameter value is 11.1.0.0.0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
oracle@localhost:/u01/app/oracle/product/12.1.0/dbs$ cat initDB12c.ora *.audit_file_dest='/u01/app/oracle/admin/DB12c/adump' *.diagnostic_dest='/u01/app/oracle/diag' *.compatible='12.1.0.1.0' *.control_files='/oradata/DB12c/control01.ctl','/oradata/DB12c/control02.ctl','/oradata/DB12c/control03.ctl' *.db_block_size=8192 *.db_domain='' *.db_file_multiblock_read_count=16 *.db_name='DB12c' *.db_recovery_file_dest_size=1073741824 *.db_recovery_file_dest='/oradata/DB12c' *.dispatchers='(PROTOCOL=TCP) (SERVICE=DB12cXDB)' *.job_queue_processes=10 *.open_cursors=300 *.pga_aggregate_target=291504128 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=876609536 *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1' *.db_file_name_convert='/oradata/DB10g','/oradata/DB12c/data' *.log_file_name_convert='/oradata/DB10g','/oradata/DB12c/log' |
- Start the database in NOMOUNT state using pfile.
1 2 3 4 5 |
oracle@localhost:/u01/app/oracle/product/12.1.0/dbs$ sqlplus "/ as sysdba" SQL*Plus: Release 12.1.0.1.0 Production on Fri Jun 12 18:38:25 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. |
1 2 3 4 5 6 7 8 |
SYS:DB12c> startup nomount pfile=initDB12c.ora ORACLE instance started. Total System Global Area 872685568 bytes Fixed Size 2293680 bytes Variable Size 289407056 bytes Database Buffers 574619648 bytes Redo Buffers 6365184 bytes SYS:DB12c> |
- Specify the backup piece location while executing the Duplicate command, since this location is not cataloged in the database. Execute the duplicate database command with the “NOOPEN” option.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
oracle@localhost:/oradata/DB12c/backup$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Fri Jun 12 18:48:36 2015 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> connect auxiliary sys/syspwd connected to auxiliary database: DB12C (not mounted) RMAN> Duplicate database to 'DB12c' noopen backup location '/oradata/DB12c/backup/’; Starting Duplicate Db at 12-JUN-15 contents of Memory Script: { . . . cataloged datafile copy datafile copy file name=/oradata/DB12c/data/undotbs01.dbf RECID=1 STAMP=882211842 cataloged datafile copy datafile copy file name=/oradata/DB12c/data/sysaux01.dbf RECID=2 STAMP=882211842 cataloged datafile copy datafile copy file name=/oradata/DB12c/data/users01.dbf RECID=3 STAMP=882211842 datafile 2 switched to datafile copy input datafile copy RECID=1 STAMP=882211842 file name=/oradata/DB12c/data/undotbs01.dbf datafile 3 switched to datafile copy input datafile copy RECID=2 STAMP=882211842 file name=/oradata/DB12c/data/sysaux01.dbf datafile 4 switched to datafile copy input datafile copy RECID=3 STAMP=882211842 file name=/oradata/DB12c/data/users01.dbf Leaving database unopened, as requested Cannot remove created server parameter file Finished Duplicate Db at 12-JUN-15 |
- Step-9: Start the database in upgrade mode with reset logs option
1 2 |
SYS:DB12c> alter database open resetlogs upgrade; Database altered. |
- Step-10: Execute the catupgrade script using catctl.pl script:
1 2 3 4 5 |
oracle@localhost:/u01/app/oracle/product/12.1.0/rdbms/admin $ /u01/app/oracle/product/12.1.0/perl/bin/perl catctl.pl -n 4 -l /u01/app/oracle/log catupgrd.sql Analyzing file catupgrd.sql Log files in /u01/app/oracle/log Parallelism 4 is used |
- The database upgrade will be executed in parallel using the Perl script “catctl.pl”. This is a new piece of functionality introduced in 12c. The database upgrade will be executed in phases. In case any particular phase fails, we can re-execute the upgrade from that particular phase using the command:
1 |
$ORACLE_HOME/perl/bin/perl catctl.pl -n 4 -l $ORACLE_HOME/diagnostics -p <phase number> catupgrd.sql |
Once the upgrade completes successfully, check the database component status through dba_registry view.
Summary
This feature is possible only when Duplicate command performed with backup, it is not possible with the Active duplication option. It is an alternative for the RMAN backup restore and recovery method.
Load comments