Upgrade Oracle database from 11g to 12c using the RMAN Backup

Description:-

In this article we are going to see upgrade Oracle database from the version 11g to the version 12c using the RMAN

Environment Detail’s

High Level Steps:-

  1. Oracle Database 11.2.0.3 Rman Full Backup
  2. Oracle Database 12c Restore
  3. Alter database open
  4. Upgrade Database

Let’s start the Demo:-

  1. Oracle Database 11.2.0.3 Rman Full Backup

Step1:- Verify the Database name and archive log is enabled on database 11g.

[oracle@gg-11 ~]$ export ORACLE_SID=oradbwr
[oracle@gg-11 ~]$ sqlplus ‘/as sysdba’
SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 3 01:20:57 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name,log_mode from v$database;
NAME LOG_MODE
——— ————
ORADBWR ARCHIVELOG

Step2:-Testing After Upgrade to 12c

SQL> create table chennai (name varchar(10));
Table created.

SQL> insert into chennai values(‘HARI’);
1 row created.

SQL> commit;
Commit complete.

Step3:-Going to take 11g database Full backup using rman

[oracle@gg-11 ~]$ export ORACLE_SID=oradbwr
[oracle@gg-11 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 3 01:26:53 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORADBWR (DBID=1410039869)

RMAN> backup database plus archivelog;

Starting backup at 03-AUG-18
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=983150751
input archived log thread=1 sequence=3 RECID=2 STAMP=983150751
input archived log thread=1 sequence=4 RECID=3 STAMP=983150755
input archived log thread=1 sequence=5 RECID=4 STAMP=983150755
input archived log thread=1 sequence=6 RECID=5 STAMP=983150756
input archived log thread=1 sequence=7 RECID=6 STAMP=983150757
input archived log thread=1 sequence=8 RECID=7 STAMP=983150758
input archived log thread=1 sequence=9 RECID=8 STAMP=983150824
channel ORA_DISK_1: starting piece 1 at 03-AUG-18
channel ORA_DISK_1: finished piece 1 at 03-AUG-18
piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_annnn_TAG20180803T012704_fp6rjjmz_.bkp tag=TAG20180803T012704 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-AUG-18
Starting backup at 03-AUG-18
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=00001 name=/u01/app/oracle/oradata/oradbwr/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/oradbwr/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/oradbwr/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/oradbwr/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-AUG-18
channel ORA_DISK_1: finished piece 1 at 03-AUG-18
piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_nnndf_TAG20180803T012705_fp6rjkt8_.bkp tag=TAG20180803T012705 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 03-AUG-18
Starting backup at 03-AUG-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=10 RECID=9 STAMP=983150870
channel ORA_DISK_1: starting piece 1 at 03-AUG-18
channel ORA_DISK_1: finished piece 1 at 03-AUG-18
piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_annnn_TAG20180803T012751_fp6rkz5m_.bkp tag=TAG20180803T012751 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 03-AUG-18
Starting Control File and SPFILE Autobackup at 03-AUG-18
piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/2018_08_03/o1_mf_s_983150872_fp6rl0lw_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 03-AUG-18

Step4:- Copy the rman backup pieces from Server 11g to Server 12c

Datafile and archivelog

[oracle@gg-11 ~]$ cd /u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/
[oracle@gg-11 2018_08_03]$ scp o1_mf_nnndf_TAG20180803T012705_fp6rjkt8_.bkp o1_mf_annnn_TAG20180803T012751_fp6rkz5m_.bkp oracle@192.168.2.157:/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/
oracle@192.168.2.157's password: 
o1_mf_nnndf_TAG20180803T012705_fp6rjkt8_.bkp 100% 993MB 26.8MB/s 00:37 
o1_mf_annnn_TAG20180803T012751_fp6rkz5m_.bkp 100% 3072 3.0KB/s 00:00 

Controlfile autobackup location

[oracle@gg-11 2018_08_03]$ cd /u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/
[oracle@gg-11 autobackup]$ scp 2018_08_03/o1_mf_s_983150872_fp6rl0lw_.bkp oracle@192.168.2.157:/u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/
oracle@192.168.2.157's password: 
o1_mf_s_983150872_fp6rl0lw_.bkp

Step5:- Create and copy the pfile $ passwordfile from source 11g to destination 12c

[oracle@gg-11 dbs]$ scp orapworadbwr initoradbwr.ora oracle@192.168.2.157:/u01/app/oracle/product/12.2.0/dbhome_2/dbs
oracle@192.168.2.157’s password:
orapworadbwr 100% 1536 1.5KB/s 00:00
initoradbwr.ora 100% 1046 1.0KB/s 00:00

2.Oracle Database 12c Restore

Step6:-Change the pfile parameters for 12c database

compatible=’12.2.0.1.0′

Step7:- Create directory for 12c database

[oracle@gg-12 dbs]$ mkdir -p /u01/app/oracle/oradata/oradbwr/
[oracle@gg-12 ]$ mkdir -p /u01/app/oracle/admin/oradbwr/adump

Step8:- Startup the 12c database on the 12c Server

[oracle@gg-12 dbs]$ export ORACLE_SID=oradbwr
[oracle@gg-12 dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 3 02:21:04 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.
Total System Global Area 931135488 bytes
Fixed Size 8627296 bytes
Variable Size 301992864 bytes
Database Buffers 616562688 bytes
Redo Buffers 3952640 bytes

SQL> create spfile from pfile;
File created.

Step9:- Restore the Control file on the 12c Server.

[oracle@gg-12 ~]$ export ORACLE_SID=oradbwr
[oracle@gg-12 ~]$ rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Fri Aug 3 02:26:50 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORADBWR (not mounted)

RMAN> restore controlfile from autobackup;

Starting restore at 03-AUG-18
using channel ORA_DISK_1
recovery area destination: /u01/app/oracle/fast_recovery_area
database name (or database unique name) used for search: ORADBWR
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/o1_mf_s_983150872_fp6rl0lw_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/o1_mf_s_983150872_fp6rl0lw_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/oradbwr/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/oradbwr/control02.ctl
Finished restore at 03-AUG-18

Step10:-Mount the Database

RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1

Step11:-Catalog the 11g backup within the controlfile

RMAN> catalog start with '/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/';

Starting implicit crosscheck backup at 03-AUG-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 03-AUG-18
Starting implicit crosscheck copy at 03-AUG-18
using channel ORA_DISK_1
Finished implicit crosscheck copy at 03-AUG-18
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ORADBWR/autobackup/o1_mf_s_983150872_fp6rl0lw_.bkp
searching for all files that match the pattern /u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/
no files found to be unknown to the database

Step12:-Restore Database

RMAN> restore database;

Starting restore at 03-AUG-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=8 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/oradbwr/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/oradbwr/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/oradbwr/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/oradbwr/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_nnndf_TAG20180803T012705_fp6rjkt8_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_nnndf_TAG20180803T012705_fp6rjkt8_.bkp tag=TAG20180803T012705
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 03-AUG-18

Step13:-Recover database upto last sequence

RMAN> run {
set until sequence = 11;  (this sequence number i get from 11g DB)
recover database;
}

executing command: SET until clause
Starting recover at 03-AUG-18
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=10
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_annnn_TAG20180803T012751_fp6rkz5m_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORADBWR/backupset/2018_08_03/o1_mf_annnn_TAG20180803T012751_fp6rkz5m_.bkp tag=TAG20180803T012751
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/fast_recovery_area/ORADBWR/archivelog/2018_08_03/o1_mf_1_10_fp6wvskv_.arc thread=1 sequence=10
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/ORADBWR/archivelog/2018_08_03/o1_mf_1_10_fp6wvskv_.arc RECID=10 STAMP=983155281
media recovery complete, elapsed time: 00:00:00
Finished recover at 03-AUG-18

3.Alter database open

Step14:-Connect sqlplus and open the database

[oracle@gg-12 dbs]$ export ORACLE_SID=oradbwr
[oracle@gg-12 dbs]$ sqlplus ‘/as sysdba’
SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 3 02:44:51 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure   (we can’t open in normal mode)
ORA-00604: error occurred at recursive SQL level 1
ORA-00904: “ACDRROWTSINTCOL#”: invalid identifier
Process ID: 4004
Session ID: 1 Serial number: 22560

4.Upgrade Database

Step15:- Startup upgrade and run the catctl.pl  script .

[oracle@gg-12 dbs]$ sqlplus ‘/as sysdba’
SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 3 03:11:46 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup upgrade

ORACLE instance started.
Total System Global Area 931135488 bytes
Fixed Size 8627296 bytes
Variable Size 301992864 bytes
Database Buffers 616562688 bytes
Redo Buffers 3952640 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

[oracle@gg-12 dbs]$ cd $ORACLE_HOME/rdbms/admin
[oracle@gg-12 admin]$ $ORACLE_HOME/perl/bin/perl catctl.pl -n 4 catupgrd.sql

Argument list for [catctl.pl]
Run in c = 0
Do not run in C = 0
Input Directory d = 0
Echo OFF e = 1
Simulate E = 0
Forced cleanup F = 0
Log Id i = 0
Child Process I = 0
Log Dir l = 0
Priority List Name L = 0
Upgrade Mode active M = 0
SQL Process Count n = 4
SQL PDB Process Count N = 0
Open Mode Normal o = 0
Start Phase p = 0
End Phase P = 0
Reverse Order r = 0
AutoUpgrade Resume R = 0
Script s = 0
Serial Run S = 0
RO User Tablespaces T = 0
Display Phases y = 0
Debug catcon.pm z = 0
Debug catctl.pl Z = 0
catctl.pl VERSION: [12.2.0.1.0]
STATUS: [production]
BUILD: [RDBMS_12.2.0.1.0_LINUX.X64_170125]
/u01/app/oracle/product/12.2.0/dbhome_2/rdbms/admin/orahome = [/u01/app/oracle/product/12.2.0/dbhome_2]
/u01/app/oracle/product/12.2.0/dbhome_2/bin/orabasehome = [/u01/app/oracle/product/12.2.0/dbhome_2]
catctlGetOrabase = [/u01/app/oracle/product/12.2.0/dbhome_2]
Analyzing file /u01/app/oracle/product/12.2.0/dbhome_2/rdbms/admin/catupgrd.sql
Log file directory = [/tmp/cfgtoollogs/upgrade20180803031607]
catcon: ALL catcon-related output will be written to [/tmp/cfgtoollogs/upgrade20180803031607/catupgrd_catcon_4242.lst]
catcon: See [/tmp/cfgtoollogs/upgrade20180803031607/catupgrd*.log] files for output generated by scripts
catcon: See [/tmp/cfgtoollogs/upgrade20180803031607/catupgrd_*.lst] files for spool files, if any
Number of Cpus = 1
Database Name = oradbwr
DataBase Version = 11.2.0.3.0
catcon: ALL catcon-related output will be written to [/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609/catupgrd_catcon_4242.lst]
catcon: See [/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609/catupgrd*.log] files for output generated by scripts
catcon: See [/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609/catupgrd_*.lst] files for spool files, if any
Log file directory = [/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609]
Parallel SQL Process Count = 4
Components in [oradbwr]
Installed [APEX APS CATALOG CATJAVA CATPROC CONTEXT EM JAVAVM ORDIM OWM SDO XDB XML XOQ]
Not Installed [DV MGW ODM OLS RAC WK]
------------------------------------------------------
Phases [0-115] Start Time:[2018_08_03 03:16:10]
------------------------------------------------------
*********** Executing Change Scripts ***********
Serial Phase #:0 [oradbwr] Files:1 Time: 128s
*************** Catalog Core SQL ***************
Serial Phase #:1 [oradbwr] Files:5 Time: 67s
Restart Phase #:2 [oradbwr] Files:1 Time: 0s
Serial Phase #:109 [oradbwr] Files:1 Time: 60s
Serial Phase #:110 [oradbwr] Files:1 Time: 0s
Serial Phase #:111 [oradbwr] Files:1 Time: 107s
***************** Post Upgrade *****************
Serial Phase #:112 [oradbwr] Files:1 Time: 425s
**************** Summary report ****************
Serial Phase #:113 [oradbwr] Files:1 Time: 2s
Serial Phase #:114 [oradbwr] Files:1 Time: 0s
Serial Phase #:115 [oradbwr] Files:1 Time: 40s
------------------------------------------------------
Phases [0-115] End Time:[2018_08_03 05:15:24]
------------------------------------------------------
Grand Total Time: 7161s 
LOG FILES: (/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609/catupgrd*.log)
Upgrade Summary Report Located in:
/u01/app/oracle/product/12.2.0/dbhome_2/cfgtoollogs/oradbwr/upgrade20180803031609/upg_summary.log
Grand Total Upgrade Time: [0d:1h:30m:21s]

Step16:- Recompile the Invalid objects using utlrp.sql

SQL> @?/rdbms/admin/utlrp.sql

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2018-08-03 05:24:35
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:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2018-08-03 05:33:52
DOC> The following query reports the number of invalid objects.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0

DOC> The following query reports the number of exceptions caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC> Note: Typical compilation errors (due to coding errors) are not
DOC> logged into this table: they go into DBA_ERRORS instead.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
0

Function created.
PL/SQL procedure successfully completed.

Function dropped.
...Starting validation 05:34:07
...Database user "SYS", database schema "APEX_050000", user# "121" 05:34:07
...grant execute on "SYS"."DBMS_CRYPTO_INTERNAL" to APEX_050000 05:34:10
...272 packages
...265 package bodies
...465 tables
...8 functions
...16 procedures
...4 sequences
...497 triggers
...1582 indexes
...255 views
...0 libraries
...14 types
...5 type bodies
...0 operators
...0 index types
...Begin key object existence check 05:34:17
...Completed key object existence check 05:34:17
...Setting DBMS Registry 05:34:17
...Setting DBMS Registry Complete 05:34:17
...Exiting validate 05:34:17
PL/SQL procedure successfully completed


Step17:-check the database status 

SQL> select comp_name,version from dba_registry where status = 'VALID';

COMP_NAME                                  VERSION
----------------                ------------------------------
Oracle Database Catalog Views            12.2.0.1.0
Oracle Database Packages and Types       12.2.0.1.0
JServer JAVA Virtual Machine             12.2.0.1.0
Oracle XDK                               12.2.0.1.0
Oracle Database Java Packages            12.2.0.1.0
OLAP Analytic Workspace                  12.2.0.1.0
Oracle Workspace Manager                 12.2.0.1.0
Oracle Text                              12.2.0.1.0
Oracle XML Database                      12.2.0.1.0
Oracle Multimedia                        12.2.0.1.0
Spatial                                  12.2.0.1.0
Oracle OLAP API                          12.2.0.1.0
Oracle Application Express               5.0.4.00.12

13 rows selected.

Successfully upgrade to 12c database

Catch Me On:- Hariprasath Rajaram

Telegram:https://t.me/joinchat/I_f4DhGF_Zifr9YZvvMkRg
LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter: https://twitter.com/hariprasathdba

Zero downtime database upgrade from 11g to 12c using Oracle Goldengate

Zero downtime database upgrade from 11g to 12c using Oracle Goldengate

Description:-

In this article we are going to see Zero downtime database upgrade from 11g to 12c using Oracle Goldengate
1)Using Goldengate we are going to upgrade from 11g to 12c database without any downtime.
2)Already Data is available source11g scheme Hari.

Environment Detail’s:-

High Level Steps  upgrade from 11g to 12c database

1)check network between source and target.
2)install goldengate Software both side
3)setup extract and datapump on source site
4)setup replict on target side
5)export and import initial load using SCN
6)start the replicat using on scn

Source 11g database side GG Configuration

Step1:-Login in to 11g server and connect to Goldengate 

[oracle@gg-11 gghome]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 12.1.2.1.0 OGGCORE_12.1.2.1.0_PLATFORMS_140727.2135.1_FBO
Linux, x64, 64bit (optimized), Oracle 12c on Aug 7 2014 10:21:34
Operating system character set identified as UTF-8.
Copyright (C) 1995, 2014, Oracle and/or its affiliates. All rights reserved.

GGSCI (gg-11.2.com) dblogin userid gguser,password gguser
Successfully logged into database.

Step2:-Configure manager 

GGSCI (gg-11.2.com)view param mgr
PORT 7809

Step3:-Add schematrandata

GGSCI (gg-11.2.com )  add schematrandata hari

2018-07-31 19:56:12 INFO OGG-01788 SCHEMATRANDATA has been added on schema hari.
2018-07-31 19:56:12 INFO OGG-01976 SCHEMATRANDATA for scheduling columns has been added on schema hari.

GGSCI (gg-11.2.com ) info schematrandata hari

2018-07-31 19:56:34 INFO OGG-01785 Schema level supplemental logging is enabled on schema HARI.
2018-07-31 19:56:34 INFO OGG-01980 Schema level supplemental logging is enabled on schema HARI for all scheduling columns.

Step4:-Configure EXTRACT Process 

GGSCI (gg-11.2.com) view param ext1

EXTRACT ext1
SETENV (ORACLE_SID=”SOURCE”)
SETENV (ORACLE_HOME = “/u01/app/oracle/product/11.2.0/db_1”)
USERID gguser@source, PASSWORD gguser
DDL INCLUDE ALL
EXTTRAIL /u01/gghome/dirdat/ac
TABLE hari.*;

GGSCI (gg-11.2.com ) add extract ext1 tranlog begin now
EXTRACT added.

GGSCI (gg-11.2.com )  add exttrail /u01/gghome/dirdat/ac extract ext1
EXTTRAIL added.

GGSCI (gg-11.2.com as gguser@source)  info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED EXT1 00:00:00 00:00:40

Step4:-Configure Pump Process  

GGSCI (gg-11.2.com )  view param dpump1

EXTRACT dpump1
USERID gguser@source, PASSWORD gguser
RMTHOST gg-12.2, MGRPORT 7810
RMTTRAIL /u01/gghome/dirdat/ad
DDL INCLUDE ALL
TABLE hari.*;

GGSCI (gg-11.2.com) add extract dpump1 exttrailsource /u01/gghome/dirdat/ac
EXTRACT added.

GGSCI (gg-11.2.com ) add rmttrail /u01/gghome/dirdat/ad extract dpump1
RMTTRAIL added.

GGSCI (gg-11.2.com )  info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED DPUMP1 00:00:00 00:01:00
EXTRACT STOPPED EXT1 00:00:00 00:04:40

Step5:-Start all the process and Check

GGSCI (gg-11.2.com )  start ext1

Sending START request to MANAGER …
EXTRACT EXT1 starting

GGSCI (gg-11.2.com )  start dpump1

Sending START request to MANAGER …
EXTRACT DPUMP1 starting

GGSCI (gg-11.2.com )  info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING
EXTRACT RUNNING DPUMP1 00:00:00 00:04:33
EXTRACT RUNNING EXT1 00:00:00 00:00:03

Target side 12c database GG Configuration

Step1:-Configure manager 

GGSCI (gg-12.2.com) 9> dblogin userid gguser,password gguser
Successfully logged into database.

GGSCI (gg-12.2.com ) info mgr

Manager is running (IP port gg-12.2.com.7810, Process ID 3999).

GGSCI (gg-12.2.com ) view param mgr

PORT 7810

Step2:-Checkpoint table creation

GGSCI (gg-12.2.com)add checkpointtable gguser.checkpoint
Successfully created checkpoint table gguser.checkpoint.

Step3:-Configure Replicat Process 

GGSCI (gg-12.2.com) view param rep1

REPLICAT rep1
ASSUMETARGETDEFS
HANDLECOLLISIONS
USERID gguser@source, PASSWORD gguser
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE
MAP hari.*, TARGET hari.*;

GGSCI (gg-12.2.com )  add replicat rep1 exttrail /u01/gghome/dirdat/ad checkpointtable gguser.checkpoint
REPLICAT added.

GGSCI (gg-12.2.com ) 12> info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT STOPPED REP1 00:00:00 00:00:03

Source side check before datapump starts

GGSCI (gg-11.2.com ) info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING DPUMP1 00:00:00 00:00:00
EXTRACT RUNNING EXT1 00:00:00 00:00:10

Start the initial dataload using Datapump on source side 11g database

SQL> select current_scn from v$database;

CURRENT_SCN
———–
1584462

SQL> select count(*) from hari.chennai;

COUNT(*)
———-
1835008

Step1:-Export the table “chennai” using flashback_scn

[oracle@gg-11 gghome]$ expdp system/oracle dumpfile=hari1.dmp schemas=hari directory=DATA_PUMP_DIR logfile=hari1.log FLASHBACK_SCN=1584462

Export: Release 11.2.0.3.0 - Production on Tue Jul 31 20:02:25 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/******** dumpfile=hari1.dmp schemas=hari directory=DATA_PUMP_DIR logfile=hari1.log FLASHBACK_SCN=1584462
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 88 MB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "HARI"."CHENNAI" 72.63 MB 1835008 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/admin/source/dpdump/hari1.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 20:02:45

Step2:-copy the datapump files to 11g server to 12c server

[oracle@gg-11 gghome]$ cd /u01/app/oracle/admin/source/dpdump/
[oracle@gg-11 dpdump]$ scp hari1.dmp oracle@192.168.2.157:/u01/app/oracle/admin/source/dpdump/
The authenticity of host ‘192.168.2.157 (192.168.2.157)’ can’t be established.
RSA key fingerprint is c2:3d:72:16:52:01:ae:5c:41:6b:34:f5:c7:a1:df:74.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.2.157’ (RSA) to the list of known hosts.
oracle@192.168.2.157’s password:
hari1.dmp 100% 73MB 72.8MB/s 00:01

Step3:-After export i am inserting more records in Chennai table

[oracle@gg-11 ~]$ sqlplus hari/hari
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 31 20:06:47 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> insert into chennai select * from chennai;
1835008 rows created.

SQL> commit;
Commit complete.

SQL> select count(*) from chennai;
COUNT(*)
———-
3670016     

Step4:-Now we are going to Import 12c database (1835008 Rows)

[oracle@gg-12 dpdump]$ impdp system/oracle dumpfile=hari1.dmp logfile=hari1.log directory=DATA_PUMP_DIR

Import: Release 12.2.0.1.0 - Production on Tue Jul 31 20:09:23 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Warning: possible data loss in character set conversions
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** dumpfile=hari1.dmp logfile=hari1.log directory=DATA_PUMP_DIR
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "HARI"."CHENNAI" 72.63 MB 1835008 rows
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at Tue Jul 31 20:09:57 2018 elapsed 0 00:00:24

Step5:-Target (12c) side going to start replicat process Using CSN 

GGSCI (gg-12.2.com ) start replicat rep1 aftercsn 1584462    ---(this scn number we get from 11g database)

Sending START request to MANAGER ...
REPLICAT REP1 starting

GGSCI (gg-12.2.com )info all

Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP1 00:00:00 00:00:01

Note :-Already initial load was completed using datapump,
Now extract was capturing all the changes happening on the source database 11g. These changes will now get applied to the target database 12c by the replicat process

[oracle@gg-12 dpdump]$ sqlplus hari/hari

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jul 31 20:19:26 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Last Successful login time: Tue Jul 31 2018 20:14:07 +05:30
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select count(*) from chennai;

COUNT(*)
----------
3670016 

Repoint the users from 11g to 12c server.

Successfully completed without downtime upgrade

Catch Me On:- Hariprasath Rajaram

Telegram:https://t.me/joinchat/I_f4DhGF_Zifr9YZvvMkRg
LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/
Facebook:https://www.facebook.com/HariPrasathdba
FB Group:https://www.facebook.com/groups/894402327369506/
FB Page: https://www.facebook.com/dbahariprasath/?
Twitter: https://twitter.com/hariprasathdba