Wednesday, 14 January 2015

Upgrading Oracle Database from 11G to 12C (11.2.0.4 to 12.1.0.1)


Below Minimum database version that can be  directly upgraded to Oracle 12c Release 1 (12.1)
Source Database Target Database
10.2.0.5 –--> 12.1.x
11.1.0.7 ---->12.1.x
11.2.0.2 or higher 12.1.x
The following database versions will require an indirect upgrade path:
Source Database Intermediate Upgrade Path for Target Database Target Database
11.2.0.1 —-> 11.2.0.2 or higher —-> 12.1.x
11.1.0.6 —-> 11.1.0.7 or 11.2.0.2 or higher —-> 12.1.x
10.2.0.4(or earlier)—-> 10.2.0.5 or later direct upgrade version —-> 12.1.x
10.1.0.5(or earlier)—-> 10.2.0.5 or later direct upgrade version —-> 12.1.x
9.2.0.8 (or earlier)—-> 9.2.0.8 –> 11.2.0.2 or higher —-> 12.1.x
My scenario Details:
11g db version= 11.2.0.4
ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1
12c db version:=12.1.0.1
ORACLE_HOME=/u01/oracle/product/12.1.0
Install 12.1.0.1 software only.
Backup the database before starting the upgrade process.
To run the new Pre-Upgrade Information Tool, copy the "preupgrd.sql" script from the 12c home to a location.
$mkdir -p /tmp/12cupg
$cp -rf /u01/oracle/product/12.1.0/rdbms/admin/preupgrd.sql /tmp/12cupg
run 11g .env file
$cd /tmp/upgrade 
$sqlplus / as sysdba 
SQL>@preupgrd.sql;
Loading Pre-Upgrade Package...
Executing Pre-Upgrade Checks...
Pre-Upgrade Checks Complete.
************************************************************
Results of the checks are located at:
/u01/oracle/cfgtoollogs/TEST/preupgrade/preupgrade.log
Pre-Upgrade Fixup Script (run in source database environment):
/u01/oracle/cfgtoollogs/TEST/preupgrade/preupgrade_fixups.sql
Post-Upgrade Fixup Script (run shortly after upgrade):
/u01/oracle/cfgtoollogs/TEST/preupgrade/postupgrade_fixups.sql
     
***********************************************************
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.
You MUST resolve the above errors prior to upgrade
***********************************************************
SQL>
 
The Pre-Upgrade Information Tool produces 3 scripts. 
preupgrade.log: The results of all the checks performed. You need to check this
to see if it is safe to continue with the upgrade. 
preupgrade_fixups.sql: A fixup script that should be run before the upgrade. 
postupgrade_fixups.sql: A fixup script that should be run after the upgrade. 
SQL>@/u01/oracle/cfgtoollogs/TEST/preupgrade/preupgrade_fixups.sql;
As you can see, in this case, the suggested changes were as follows.
SQL> ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE;
SQL>SET ECHO ON;
SQL>SET SERVEROUTPUT ON;
emremove.sql scrip located in the 12c home.
SQL>@/u01/oracle/product/12.1.0/rdbms/admin/emremove.sql;
Removing this before the upgrade will result in the errors shown below.
These errors are not show-stoppers, but if you want a cleaner run through,
remove this feature after the upgrade.
SQL>@?/olap/admin/catnoamd.sql;
SQL>EXECUTE dbms_stats.gather_dictionary_stats;
Shutdown
the database.
SQL>SHUTDOWN IMMEDIATE;
Copy the parameter and password files from the old home to the 12c home.
$cp -rf /u01/oracle/product/11.2.0/dbhome_1/dbs/initTEST.ora /u01/oracle/product/12.1.0/dbs/
$cp -rf /u01/oracle/product/11.2.0/dbhome_1/dbs/orapwTEST /u01/oracle/product/12.1.0/dbs/
Edit the "/etc/oratab" file, setting the new ORACLE_HOME value.
$vi /etc/oratab
TEST:/u01/oracle/product/12.1.0:Y
Make sure the environment is set to the 12c home.
Run 12c .env file
Start the database in upgrade mode.
$sqlplus / as sysdba
SQL>STARTUP UPGRADE;
SQL>EXIT;
Run the new Parallel Upgrade Utility (catctl.pl), alter the level of
parallelism using the "-n" parameter.
$cd $ORACLE_HOME/rdbms/admin
$$ORACLE_HOME/perl/bin/perl catctl.pl -n 8 catupgrd.sql
Startup the upgraded database and run the "utlu121s.sql" script to check the summary of the upgrade results.
$sqlplus / as sysdba
SQL>startup
SQL>@utlu121s.sql;
If you see the upgrade failed for the "Oracle OLAP API" section, which is a feature we removed before the upgrade, so it is OK to continue.
If we had no errors, the "catuppst.sql" script would have been run as part of the upgrade. Since we did have errors, we need to run it manually.
SQL>@catuppst.sql;
If the
"postupgrade_fixups.sql" file contained any
recommendations, run it now.
SQL>@/u01/app/oracle/cfgtoollogs/TEST/preupgrade/postupgrade_fixups.sql;
The following items are not essential, but the upgrade manual suggests it is a best practice to run them.
The following item is probably included in your postupgrade_fixups.sql script.
SQL>EXECUTE DBMS_STATS.gather_fixed_objects_stats;
Recompile invalid objects.
$cd $ORACLE_HOME/rdbms/admin
SQL>select count(*) from dba_objects where status like 'INVALID';
SQL>@utlrp.sql;
SQL>select count(*) from dba_objects where status like 'INVALID';
Check for newly invalid objects.
SQL>@utluiobj.sql;
Run again to check the final outcome of the upgrade.
SQL>@utlu121s.sql;
SQL>exit
The upgraded database is now available.
$ sqlplus / as sysdba
SQL*Plus:
Release 12.1.0.1.0 Production on Wed Jul
24 18:17:03 2013
Copyright
(c) 1982, 2013, Oracle.  All rights reserved.
Connected
to:
Oracle
Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the
Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
SQL>SELECT name, open_mode FROM v$database;
 NAME     OPEN_MODE
 -----------------------------
 TEST     READ WRITE
SQL>

Oracle DB Upgrade from 11.2.0.1 to 11.2.0.4 Using DBUA Part-1

Following are the steps to Upgrade Oracle database from 11.2.0.1 to 11.2.0.4
11.2.0.4 software download:
Download software from https://support.oracle.com
Patchset Number :13390677
Platform :Linux x86-64

$ cd /tmp/11gpatchset
Unzip all 7 files
My present database ORACLE_HOME location '/u01/oracle/product/11.2.0'
Here we are created new ORACLE_HOME location only.
Install oracle software only in new ORACLE_HOME location
ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1
$ cd database
./runInstaller


Uncheck on I wish to receive security updates via my oracle support as this is a test lab.

Click on yes and click next


Click on skip software updates and click on next

On next window, Click on Single instance database installation and click on next,

On next window, Select languages and click on next


Click next
On next window select ORACLE_BASE & new ORACLE_HOME location.



Confirm installation completed without any warnings and errors.
Execute shell scripts.
Go to part-2 for upgrading.