vendredi 13 novembre 2015

Migration From 11gr2 To 12c Using Rman Duplicate NoOpen New Feature

Introduction:

The goal of this article is to show you how i have migrated an 11gr2 database to 12c, using Duplicate with the new feature NOOPEN.


We assume that the the first database is DB1 on the server S1 : 11.2.0.3
and that the second database is DB2 on the server S2 : 12.1.0.2




A. Check list to do Source Database


I. Pre-Upgrade Steps:

Complete Checklist for Manual Upgrades to Oracle Database 12c Release 1 (12.1)
 (Doc ID 1503653.1)

The Pre-upgrade must be applied on the first database DB1.
Run the Pre-Upgrade Information Tool for Collecting Pre-Upgrade Information
* Log into the system as the owner of the Oracle Database 12c Release 1 (12.1) Oracle Home directory.
* Copy the Pre-Upgrade Information Tool script preupgrd.sql and utluppkg.sql from the Oracle

 Database 12c Release 1 (12.1) $ORACLE_HOME/rdbms/admin directory to the
 $ORACLE_HOME/rdbms/admin directory of the source Oracle Home.
 Step 2:
 * Run the new Pre-Upgrade Information Tool. For example, if you copied preupgrd.sql to the /admin
 directory of the source Oracle Home:

SQL> @$ORACLE_HOME/rdbms/admin/preupgrd.sql  <==============ON DB1 !!!!
preupgrade.log, preupgrade_fixups.sql and postupgrade_fixups.sql files are created in
 $ORACLE_HOME/cfgtoollogs/$ORACLE_SID/preupgrade/, which is under the source database
 ORACLE_HOME to be upgraded.
You will obtain three files : the first two files to be applied on the source  DB1 and DB2 for parameters, the last one on the target : DB2

For DB1:
1./apps/oracle/cfgtoollogs/DB1/preupgrade/preupgrade.log
2./apps/oracle/cfgtoollogs/DB1/preupgrade/preupgrade_fixups.sql


For DB2:

Move /apps/oracle/cfgtoollogs/DB1/preupgrade/postupgrade_fixups.sql to the second server, for example on :
 /apps/oracle/cfgtoollogs/DB2/preupgrade/postupgrade_fixups.sql

1./apps/oracle/cfgtoollogs/DB2/preupgrade/postupgrade_fixups.sql
 Be carreful you must change :
      IF con_name = 'DB1' THEN
 to
     IF con_name = 'DB2' THEN
 Other note:
 the first pre-check file can give you some parameters to change : theses parameters must be changed on the target DB: DB2.

II. Rman Backup



Take and RMAN backup on the first database DB1.
rman "target / nocatalog"
RUN
{
ALLOCATE CHANNEL chan_name TYPE DISK;
BACKUP DATABASE FORMAT '<db_backup_directory>%U' TAG before_upgrade;
BACKUP CURRENT CONTROLFILE TO '<controlfile_backup_directory>';
}

Move the backup to the second server S2 : to /apps/oracle/DB2/Backup/













B. Restore the backup on the second database

On  the second database DB2, restore the backup using the Duplicate command.
Startup on nomount DB2 with appropriate 12c parameters : sepecially compatible set to 12.1.0 or higher.

. oraenv
DB2
rman auxiliary /








RMAN> run
{
 allocate auxiliary channel chnl1 device type disk;
 DUPLICATE DATABASE TO DB2 nofilenamecheck
 NOOPEN BACKUP LOCATION '/apps/oracle/DB2/Backup/' NOREDO ;
 }



We use NOOPEN : so RMAN stops at the MOUNT step.
We use NOREDO if the backup was COLD.



When the databse is restored, open it with the upgrade mode :


SQL> alter database open resetlogs upgrade;

C. Migration to 12c


Use catctl.pl to upgrade the database.

Run the catctl.pl script from the new Oracle home.
In this release, the new Upgrade Utility, catctl.pl, replaces catupgrd.sql.



cd $ORACLE_HOME/rdbms/admin
$ORACLE_HOME/perl/bin/perl  catctl.pl -n 6 -l  /apps/orafra/DB2/migration-12c/ catupgrd.sql

Analyzing file catupgrd.sql
Log files in /apps/orafra/DB2/migration-12c/
catcon: ALL catcon-related output will be written to /apps/orafra/DB2/migration-12c//catupgrd_catcon_13566188.lst
catcon: See /apps/orafra/DB2/migration-12c//catupgrd*.log files for output generated by scripts
catcon: See /apps/orafra/DB2/migration-12c//catupgrd_*.lst files for spool files, if any
Number of Cpus        = 8
SQL Process Count     = 6
------------------------------------------------------
Phases [0-73]
Serial   Phase #: 0 Files: 1     Time: 82s
Serial   Phase #: 1 Files: 5     Time: 67s
Restart  Phase #: 2 Files: 1     Time: 1s
Parallel Phase #: 3 Files: 18    Time: 17s
Restart  Phase #: 4 Files: 1     Time: 0s
Serial   Phase #: 5 Files: 5     Time: 30s
Serial   Phase #: 6 Files: 1     Time: 12s
Serial   Phase #: 7 Files: 4     Time: 11s
Restart  Phase #: 8 Files: 1     Time: 1s
Parallel Phase #: 9 Files: 62    Time: 40s
Restart  Phase #:10 Files: 1     Time: 1s
Serial   Phase #:11 Files: 1     Time: 27s
Restart  Phase #:12 Files: 1     Time: 1s
Parallel Phase #:13 Files: 91    Time: 13s
Restart  Phase #:14 Files: 1     Time: 0s
Parallel Phase #:15 Files: 111   Time: 23s
Restart  Phase #:16 Files: 1     Time: 0s
Serial   Phase #:17 Files: 3     Time: 2s
Restart  Phase #:18 Files: 1     Time: 0s
Parallel Phase #:19 Files: 32    Time: 21s
Restart  Phase #:20 Files: 1     Time: 1s
Serial   Phase #:21 Files: 3     Time: 8s
Restart  Phase #:22 Files: 1     Time: 1s
Parallel Phase #:23 Files: 23    Time: 88s
Restart  Phase #:24 Files: 1     Time: 1s
Parallel Phase #:25 Files: 11    Time: 42s
Restart  Phase #:26 Files: 1     Time: 0s
Serial   Phase #:27 Files: 1     Time: 1s
Restart  Phase #:28 Files: 1     Time: 0s
Serial   Phase #:30 Files: 1     Time: 0s
Serial   Phase #:31 Files: 257   Time: 27s
Serial   Phase #:32 Files: 1     Time: 0s
Restart  Phase #:33 Files: 1     Time: 0s
Serial   Phase #:34 Files: 1     Time: 8s
Restart  Phase #:35 Files: 1     Time: 0s
Restart  Phase #:36 Files: 1     Time: 1s
Serial   Phase #:37 Files: 4     Time: 53s
Restart  Phase #:38 Files: 1     Time: 1s
Parallel Phase #:39 Files: 13    Time: 50s
Restart  Phase #:40 Files: 1     Time: 1s
Parallel Phase #:41 Files: 10    Time: 10s
Restart  Phase #:42 Files: 1     Time: 1s
Serial   Phase #:43 Files: 1     Time: 7s
Restart  Phase #:44 Files: 1     Time: 1s
Serial   Phase #:45 Files: 1     Time: 7s
Serial   Phase #:46 Files: 1     Time: 0s
Restart  Phase #:47 Files: 1     Time: 0s
Serial   Phase #:48 Files: 1     Time: 345s
Restart  Phase #:49 Files: 1     Time: 0s
Serial   Phase #:50 Files: 1     Time: 42s
Restart  Phase #:51 Files: 1     Time: 1s
Serial   Phase #:52 Files: 1     Time: 1s
Restart  Phase #:53 Files: 1     Time: 0s
Serial   Phase #:54 Files: 1     Time: 214s
Restart  Phase #:55 Files: 1     Time: 0s
Serial   Phase #:56 Files: 1     Time: 78s
Restart  Phase #:57 Files: 1     Time: 0s
Serial   Phase #:58 Files: 1     Time: 145s
Restart  Phase #:59 Files: 1     Time: 0s
Serial   Phase #:60 Files: 1     Time: 294s
Restart  Phase #:61 Files: 1     Time: 1s
Serial   Phase #:62 Files: 1     Time: 1s
Restart  Phase #:63 Files: 1     Time: 1s
Serial   Phase #:64 Files: 1     Time: 2s
Serial   Phase #:65 Files: 1 Calling sqlpatch with LD_LIBRARY_PATH=/apps/oracle/12102/rdb/std/lib; export LD_LIBRARY_PATH; LIBPATH=/apps/oracle/12102/rdb/std/lib; export LIBPATH; LD_LIBRARY_PATH_64=/apps/oracle/12102/rdb/std/lib; export LD_LIBRARY_PATH_64; DYLD_LIBRARY_PATH=/apps/oracle/12102/rdb/std/lib; export DYLD_LIBRARY_PATH; /apps/oracle/12102/rdb/std/perl/bin/perl -I /apps/oracle/12102/rdb/std/rdbms/admin -I /apps/oracle/12102/rdb/std/rdbms/admin/../../sqlpatch /apps/oracle/12102/rdb/std/rdbms/admin/../../sqlpatch/sqlpatch.pl -verbose -upgrade_mode_only > /apps/orafra/DB2/migration-12c//catupgrd_datapatch_upgrade.log 2> /apps/orafra/DB2/migration-12c//catupgrd_datapatch_upgrade.err
returned from sqlpatch
    Time: 46s
Serial   Phase #:66 Files: 1     Time: 37s
Serial   Phase #:68 Files: 1     Time: 0s
Serial   Phase #:69 Files: 1 Calling sqlpatch with LD_LIBRARY_PATH=/apps/oracle/12102/rdb/std/lib; export LD_LIBRARY_PATH; LIBPATH=/apps/oracle/12102/rdb/std/lib; export LIBPATH; LD_LIBRARY_PATH_64=/apps/oracle/12102/rdb/std/lib; export LD_LIBRARY_PATH_64; DYLD_LIBRARY_PATH=/apps/oracle/12102/rdb/std/lib; export DYLD_LIBRARY_PATH; /apps/oracle/12102/rdb/std/perl/bin/perl -I /apps/oracle/12102/rdb/std/rdbms/admin -I /apps/oracle/12102/rdb/std/rdbms/admin/../../sqlpatch /apps/oracle/12102/rdb/std/rdbms/admin/../../sqlpatch/sqlpatch.pl -verbose > /apps/orafra/DB2/migration-12c//catupgrd_datapatch_normal.log 2> /apps/orafra/DB2/migration-12c//catupgrd_datapatch_normal.err
returned from sqlpatch
    Time: 48s
Serial   Phase #:70 Files: 1     Time: 13s
Serial   Phase #:71 Files: 1     Time: 1s
Serial   Phase #:72 Files: 1     Time: 0s
Serial   Phase #:73 Files: 1     Time: 19s
Grand Total Time: 1951s




Run the Post-Upgrade Status Tool $ORACLE_HOME/rdbms/admin/utlu121s.sql which provides a summary of
the upgrade at the end of the spool log.
It displays the status of the database components in the upgraded database and the time required to
complete each component upgrade.
Any errors that occur during the upgrade are listed with each component and must be addressed.


$ sqlplus "/as sysdba"
SQL> STARTUP
SQL> @utlu121s.sql








Run catuppst.sql, located in the $ORACLE_HOME/rdbms/admin directory, to perform upgrade actions that
do not require the database to be in UPGRADE mode.

SQL> @catuppst.sql

This script can be run concurrently with utlrp.sql.

Run utlrp.sql to recompile any remaining stored PL/SQL and Java code in another session.

SQL> @utlrp.sql



At this moment, DB2 is migrated to 12c :

Oracle Database 12.1 Post-Upgrade Status Tool           11-07-2015 16:37:11
Component                               Current         Version  Elapsed Time
Name                                    Status          Number   HH:MM:SS
Oracle Server                          UPGRADED      12.1.0.2.0  00:10:57
JServer JAVA Virtual Machine              VALID      12.1.0.2.0  00:05:43
Oracle Workspace Manager                  VALID      12.1.0.2.0  00:01:02
Oracle XDK                                VALID      12.1.0.2.0  00:00:40
Oracle Text                               VALID      12.1.0.2.0  00:01:01
Oracle XML Database                       VALID      12.1.0.2.0  00:02:30
Oracle Database Java Packages             VALID      12.1.0.2.0  00:00:13
Oracle Multimedia                         VALID      12.1.0.2.0  00:02:23
Spatial                                UPGRADED      12.1.0.2.0  00:04:52
Final Actions                                                    00:01:21
Post Upgrade                                                     00:00:09

C. Execute in the NEW environment AFTER upgrade

@/apps/oracle/cfgtoollogs/DB2/preupgrade/postupgrade_fixups.sql