Showing posts with label CPU patching. Show all posts
Showing posts with label CPU patching. Show all posts

Monday, July 14, 2014

Applying CPU Patch On Primary Database Server Environment

 Applying CPU Patch On Primary Database Server Environment.


 Step 1:

Incase if you have standby server. Now disable log shipping on the primary database by setting the log_archive_dest_state_2 to disable. As I said earlier, parameter log_archive_dest_2 on my primary database is set to point to the standby database.

SQL> alter system set log_archive_dest_state_2=disable;

System altered.

Step 2:

Shutdown the Primary database and stop the listener running on the primary database server.

 
[oracle@PRIM ~]$ sqlplus sys/"as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, DataMining and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, DataMining and Real Application Testing options

Now Stop the Listener.

[oracle@PRIM ~]$ lsnrctl stop

 [oracle@PRIM ~]$ ps -ef | grep pmon

Step 3:

Now apply the CPU patch on the Primary database.



Set the Opatch path.
[oracle@PRIM ~]$ export $ORACLE_HOME=/u01/app/oracle/product/11.2/db_1
[oracle@PRIM ~]$ export PATH=$PATH:$ORACLE_HOME/OPatch

OPatch Version: 11.2.0.3.0

OPatch succeeded.

[oracle@PRIM ~]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /opt/12827726/
Oracle Interim Patch Installer version 11.2.0.3.0
Copyright (c) 2012, Oracle Corporation. All rights reserved.

PREREQ session
OPatch version : 11.2.0.3.0
OUI version : 11.2.0.2.0
Log file location : /u01/app/oracle/product/11.2.0.2/db1/cfgtoollogs/opatch/opatch2013-05-18_11-56-11AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.

[oracle@PRIM ~]$ export PATH=$PATH:/u01/app/oracle/product/11.2.0.2/db1/OPatch
[oracle@PRIM ~]$ opatch apply /opt/12827726/

 OPatch succeeded.

 Step 4:

Start the listener on the primary database server and also start the Primary database.


[oracle@PRIM ~]$ lsnrctl start

[oracle@PRIM ~]$ sqlplus /"as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

 Step 5:

Incase if you have standby server. Now enable log shipping on the primary database by setting the log_archive_dest_state_2 to "enable". As I said earlier, parameter log_archive_dest_2 on my primary database is set to point to the standby database.

SQL> alter system set log_archive_dest_state_2=enable;


Step 6:

On the primary database, run the patching scripts like “catbundle.sql” in this case.
The script run generates archives and these archives would be shipped and applied to the standby database. So, there is no requriement to run the patching scripts on the standby database.

[oracle@PRIM ~]$ sqlplus /"as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, DataMining and Real Application Testing options

SQL> @?/rdbms/admin/catbundle.sql psu apply

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------

Note : Incase if you want to rollback the patch applied:


  1. Verify that an $ORACLE_HOME/rdbms/admin/catbundle_PSU_<database SID>_ROLLBACK.sql file exists for each database associated with this ORACLE_HOME. If this is not the case, you must execute the steps.
  2. Shut down all instances and listeners associated with the Oracle home that you are updating. 
  3. For more information, see Oracle Database Administrator's Guide.

            Run the OPatch utility specifying the rollback argument as follows.

            opatch rollback -id 12827726


Patch Post-Deinstallation Instructions for a Non Oracle RAC Environment

  1. Start all database instances running from the Oracle home. (For more information, see Oracle Database Administrator's Guide.)
  2. For each database instance running out of the ORACLE_HOME, connect to the database using SQL*Plus as SYSDBA and run the rollback script as follows:
    cd $ORACLE_HOME/rdbms/admin
    sqlplus /nolog
    SQL> CONNECT / AS SYSDBA
    SQL> STARTUP
    SQL> @catbundle_PSU_<database SID>_ROLLBACK.sql
    SQL> QUIT
    

Applying CPU Patch in a dataguard (Physical Standby) environment

Here is a brief explanation on how to apply CPU(Critical Patch Update) in a dataguard environment
In this demo, I am applying PSU 11.2.0.4.2 on the Primary and standby databases.

Standby  Database Name :ORCL_STBY
Primary  Database Name : ORCL


Primary Server:

[oracle@PRIM ~]$ sqlplus sys/oracle@srprim as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 18 10:43:50 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, DataMining and Real Application Testing options
SQL> select status,instance_name,database_role from v$database,v$instance;
STATUS INSTANCE_NAME DATABASE_ROLE
------ ------------- ---------------
OPEN               ORCL            PRIMARY
 Standby Server:

[oracle@STBY~]$ sqlplus /"as sysdba"
SQL*Plus: Release 11.2.0.2.0 Production on Tue Sep 18 10:46:35 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, DataMining and Real Application Testing options
SQL> select status,instance_name,database_role from v$database,v$instance;
STATUS   INSTANCE_NAME        DATABASE_ROLE
-------- --------------           ----------------------
MOUNTED      ORCL_STBY         PHYSICAL STANDBY
 
 Step 1:
As a first step we need to disable the log shipping from primary database to the standby database by setting the log_archive_dest_state_2 to “defer” on the primary database.




SQL> alter system set log_archive_dest_state_2=defer;
System altered.
 Step 2:

Now Cancel the Managed Recovery Process on your standby database .




SQL> alter database recover managed standby database cancel;
Database altered.
 Step 3:

CPU (Critical Patch Update)/ Patch Set patches  always needs to be applied first on the standby database and then on the primary database. In order to apply it on the standby database, shutdown the standby database and also the listener running on the standby server.
 SQL> shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.

[oracle@STBY ~]$ lsnrctl stop

[oracle@STBY ~]$ ps -ef | grep tns
oracle 6958 5107 0 10:52 pts/1 00:00:00 grep tns

[oracle@STBY ~]$

[oracle@STBY ~]$ ps -ef | grep pmon
oracle 6960 5107 0 10:52 pts/1 00:00:00 grep pmon
 
 Step 4:
Now apply the CPU on the standby database.
[oracle@STBY ~]$ export PATH=$PATH:$ORACLE_HOME/OPatch
[oracle@STBY ~]$ opatch version
OPatch Version: 11.2.0.3.0

OPatch succeeded.
 
Step 5: 

Unzip the downloaded patch file.

unzip p18031668_112040_<platform>.zip 
 

cd 18031668
 
Verify pre-reqs:
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Now Apply Patch:

opatch apply
 
Step 6: 

Once the patch has been applied on the standby database,
start the listener and the standby database. 

[oracle@uat ~]$ lsnrctl start
 
[oracle@uat ~]$ sqlplus /"As sysdba"

SQL> startup mount
 
 
Step 7:
 
On Primary Database server, Start the archiving.




SQL> alter system set log_archive_dest_state_2=enable;
 System altered.
 
  
Note: Do not run any patching scripts on the standby database (Example: catbundle.sql). 
We are done with the patching on the standby database. 
 
Click on this Link to read further on how to apply CPU Patch On Primary Production Database Server Environment.