Oracle by Example brandingUpgrading a 12c CDB to an Oracle Database 18c CDB


section 0Before You Begin


This 15-minute tutorial shows you how to upgrade a 12c container database (CDB) to an Oracle Database 18c CDB.

Background

The process and utilities to upgrade a 12.1 CDB to an Oracle Database 12.2 CDB are the same as an upgrade of a 12c CDB to an oracle Database 18c CDB.

What Do You Need?

  • Oracle Database 18c installed
  • Oracle Database 12c Release 2 (12.2) installed
  • One Oracle Database 12c Release 2 (12.2) CDB cdb12 with one PDB opened, PDB12. You can use the dbca.sh shell script to create cdb12. Download the shell script to the labs directory created on your server /home/oracle/labs. Replace the password in the shell script with your own complex password
  • The SQL script, create_test_user_bigtab.sql downloaded to the labs directory created on your server /home/oracle/labs with user password updated

section 1Back up 12c CDB Before Upgrade

In this section, you'll back up cdb12 before you upgrade the 12c CDB to an Oracle Database 18c CDB. Before you back up the CDB, use the create_test_user_bigtab.sql SQL script to create a test user and a table with rows in the PDB12 PDB.

  1. Log in to PDB12 to create the test.bigtab table loaded with 10000 rows. This is Session 12.
    sqlplus sys@PDB12 AS SYSDBA
    Enter password: password
  2. Execute the SQL script create_test_user_bigtab.sql that creates the TEST user and the test.bigtab table that is loaded with 10000 rows.
    @/home/oracle/labs/create_test_user_bigtab.sql
  3. Launch rman to back up cdb12.
    rman target sys@cdb12

    target database Password: password
  4. Back up cdb12.
    BACKUP DATABASE PLUS ARCHIVELOG;
  5. Quit the session.
    EXIT;

section 2Prepare the 12c CDB for Upgrade

In this section, you'll prepare cdb12 to be upgraded to an Oracle Database 18c CDB.

  1. The current terminal window is still set with ORACLE_HOME set to Oracle Database 12c Release 2 (12.2)  and ORACLE_SID set to cdb12. This session is called Session 12c.
    export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
    export ORACLE_SID=cdb12
  2. Open another terminal window and set ORACLE_HOME to Oracle Database 18c and ORACLE_SID set to cdb12. This session is called Session 18c.
    export ORACLE_HOME=/u01/app/oracle/product/18.1.0/dbhome_1
    export ORACLE_SID=cdb12
  3. In Session 12c, change the directory to Oracle Database 18c /u01/app/oracle/product/18.1.0/dbhome_1/rdbms/admin.
    cd /u01/app/oracle/product/18.1.0/dbhome_1/rdbms/admin
  4. Prepare CDB12 to be upgraded into an Oracle Database 18c CDB. First, execute the Pre-Upgrade Information Tool on the 12c cdb12 by executing the preupgrade.jar file.
    $ORACLE_HOME/jdk/bin/java -jar preupgrade.jar TERMINAL TEXT
    
  5. Read the Preupgrade Summary report from preupgrade_summary.
  6. Before the upgrade operation, the report suggests that you execute the pre-upgrade fixups scripts on the entire CDB cdb12. Copy and paste the command suggested in the "Before upgrade" paragraph.
    $ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -l /u01/app/oracle/cfgtoollogs/cdb12/preupgrade/ -b preup_cdb12 /u01/app/oracle/cfgtoollogs/cdb12/preupgrade/preupgrade_fixups.sql
    catcon: ALL catcon-related output will be written to [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade//preup_cdb12_catcon_5393.lst]
    catcon: See [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade//preup_cdb12*.log] files for output generated by scripts
    catcon: See [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade//preup_cdb12_*.lst] files for spool files, if any
    catcon.pl: completed successfully
    
  7. After the fixup script completes, shut the instance down by logging in to the CDB root as SYSDBA.
    sqlplus / AS SYSDBA
  8. Shut down cdb12.
    SHUTDOWN IMMEDIATE
  9. Quit the session.
    EXIT

section 3Upgrade the 12c CDB to an Oracle Database 18c CDB

In this section, you'll upgrade cdb12 to Oracle Database 18c.

  1. In Session 18c, copy the cdb12 spfile from the 12c ORACLE_HOME to the 18c ORACLE_HOME before you start the cdb12 instance in the 18c environment.
    cp /u01/app/oracle/product/12.2.0/dbhome_1/dbs/spfilecdb12.ora /u01/app/oracle/product/18.1.0/dbhome_1/dbs/
    
    sqlplus / AS SYSDBA
  2. Start up the cdb12 instance in UPGRADE mode.
    STARTUP UPGRADE
  3. Open all PDBs in UPGRADE mode.
    ALTER PLUGGABLE DATABASE ALL OPEN UPGRADE;
    
  4. Display the open mode of the PDBs.
    SHOW PDBS
    
    CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED MIGRATE YES 3 PDB12 MIGRATE YES
  5. Quit the session.
    EXIT
  6. Upgrade cdb12.
    mkdir /tmp/upgrade_cdb12
    cd $ORACLE_HOME/rdbms/admin
    $ORACLE_HOME/perl/bin/perl catctl.pl -l /tmp/upgrade_cdb12 catupgrd.sql
  7. Read the result of the upgrade operation from the upgrade report.
  8. Log in to the CDB to open the PDBs.
    sqlplus / AS SYSDBA
  9. Open the PDBs.
    ALTER PLUGGABLE DATABASE ALL OPEN;
  10. Quit the session.
    EXIT

section 4Execute the Post-Upgrade Steps

In this section, after your upgrade is complete, run the post-upgrade script that your preupgrade_summary report indicates as required for your upgrade.

  1. Copy and paste the command suggested in the "After the upgrade" paragraph.
    $ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -l /u01/app/oracle/cfgtoollogs/cdb12/preupgrade/ -b postup_cdb12 /u01/app/oracle/cfgtoollogs/cdb12/preupgrade/postupgrade_fixups.sql
    catcon::set_log_file_base_path: ALL catcon-related output will be written to [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade/postup_cdb12_catcon_26887.lst]
    
    catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade/postup_cdb12*.log] files for output generated by scripts
    
    catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/cdb12/preupgrade/postup_cdb12_*.lst] files for spool files, if any
    
    catcon.pl: completed successfully
  2. Log in to PDB12.
    sqlplus / AS SYSDBA
    ALTER SESSION SET CONTAINER=PDB12;
  3. Verify that the TEST.BIGTAB still holds 10000 rows.
    SELECT count(*) FROM test.bigtab;
  4. Quit the session.
    EXIT
  5. Change the Oracle home for CDB12 by editing the /etc/oratab file so that it points to the new 18c Oracle home.
    cdb12:/u01/app/oracle/product/18.1.0/dbhome_1:N
  6. Create the new cdb12 password file in Oracle Database 18.1 environment.
  7. cd /u01/app/oracle/product/18.1.0/dbhome_1/dbs
    orapwd file=orapwcdb12 entries=5 password=password