Thursday, 4 October 2018

Applying Latest PSU On Grid+RDBMS Homes

Download Below Latest PSU and OPatch zip files from MOS


p6880880_121010_Linux-x86_64.zip---OPatch
p27468957_121020_Linux-x86_64.zip--PSU

Create directory to keep files

As a root user 

cd /oracle/software

mkdir psu
mkdir gpsu

chown oracle:oinstall psu
chown grid:oinstall gpsu

cp p6880880_121010_Linux-x86_64.zip gpsu
cp p27468957_121020_Linux-x86_64.zip gpsu

cp p6880880_121010_Linux-x86_64.zip psu
cp p27468957_121020_Linux-x86_64.zip psu


Applying PSU on GRID Home


Change owner ship to grid user

As root user

cd /oracle/software/gpsu

chown grid:oinstall p6880880_121010_Linux-x86_64.zip
chown grid:oinstall p27468957_121020_Linux-x86_64.zip


As a grid user unzip OPatch on grid home

cd /u01/app/12.1.0.2/grid

unzip -o /oracle/software/gpsu/p6880880_121010_Linux-x86_64.zip

Once OPatch unzipped , Please check Opatch version using below command

. oraenv

+ASM

cd $ORACLE_HOME/OPatch
./opatch version

Now unzip PSU 

As a grid user

cd /oracle/software/gpsu

unzip p27468957_121020_Linux-x86_64.zip

As a root user stop crs services

. oraenv

+ASM

crsctl stop crs(has --if Single Instance) -f

Now Apply PSU on Grid Home

As a root 

. oraenv

+ASM

echo $ORACLE_SID
ASM
echo $ORACLE_HOME
/u01/app/12.1.0.2/grid

nohup $ORACLE_HOME/OPatch/opatchauto apply /oracle/software/gpsu/p27468957 -oh /u01/app/12.1.0.2/grid &

Once Patch applied successfully, Start crsctl services

. oraenv

+ASM

crsctl start crs


Applying PSU on RDBMS Home


Change owner ship to oracleuser

As root user

cd /oracle/software/psu

chown oracle:oinstall p6880880_121010_Linux-x86_64.zip
chown oracle:oinstall p27468957_121020_Linux-x86_64.zip


As a oracle user unzip OPatch on RDBMS home

cd /u01/app/oracle/product/12.1.0.2/dbhome_1

unzip -o /oracle/software/psu/p6880880_121010_Linux-x86_64.zip

Once OPatch unzipped , Please check Opatch version using below command

. oraenv

+DB1

cd $ORACLE_HOME/OPatch
./opatch version

Now unzip PSU 

As a oracle user

cd /oracle/software/psu

unzip p27468957_121020_Linux-x86_64.zip

As a root user stop crs services

. oraenv

+ASM

crsctl stop crs(has --if Single Instance) -f

Now Apply PSU on RDBMS Home

As a root 

. oraenv

+DB1

echo $ORACLE_SID
DB1
echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/dbhome_1

nohup $ORACLE_HOME/OPatch/opatchauto apply /oracle/software/psu/p27468957 -oh /u01/app/oracle/product/12.1.0.2/dbhome_1 &

Once Patch applied successfully, Start crsctl services

. oraenv

+ASM

crsctl start crs

Once RDBMS Patch Applied, source each RDBMS SID then apply Datapatch 

$ORACLE_HOME=/OPatch/datapatch

Finally Check PSU applied status

set pages 4000 lines 4000
col description for a60
select patch_id,version,action,status,description from  dba_registry_sqlpatch;


col verify_queryable_inventory for a30
select dbsm_sqlpatch.verify_veryable_inventory from dual;

************************************************** All The Best *********************************************

11.2.0.4.0 DB Binaries Installation on Linux Non-RAC/RAC-Enviroment

11.2.0.4.0 DB Binaries Installation on Linux RAC-Enviroment:

Copy the below required files to one of the RAC node


p13390677_112040_Linux_x86_64_1of7.zip
p13390677_112040_Linux_x86_64_2of7.zip


Copy PSU and OPatch to all nodes of the RAC


p26030799_112040_Linux_x86_64.zip--PSU Patch
p6880880_112000_Linux_x86_64.zip---OPatch



Clean the Software Directory

Remove all previous installation software from oracle/software and change the directory group, So our personal ID's can copy software directly(dba group)

As a root on each node

cd /oracle/software
rm -fr database grid psu gpsu
chgrp dba /oracle/software
chmod 775 /oracle/software


Unzip the Database files

As oracle

unzip p13390677_112040_Linux_x86_64_1of7.zip
unzip p13390677_112040_Linux_x86_64_2of7.zip

Create RDBMS response file

As oracle

cd /oracle/software

grep -i ^[A-Z] database /response/db_install.rsp | sort > dbInstall.rsp


Modify the following variables as per RAC environment you are patching

DECLINE_SECURITY_UPDATES=true
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
oracle.install.db.CLUSTER_NODES=Testdb1,Testdb2
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.EEOptionsSelection=true
oracle.install.db.InstallEdition=EE
oracle.install.db.OPER_GROUP=dba
oracle.install.option=INSTALL_DB_SWONLY
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolal:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0


Deploy Software

As oracle

cd /oracle/software/database
./runInstaller -silent -response /oracle/software/dbInstall.rsp


Copy init.ora and tnsnames.ora files to new RDBMS Home

For each node:

. oraenv

cp -p $ORACLE_HOME/network/admin/tnsnames.ora /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin

For each database:

. oraenv
cp - p $ORACLE_HOME/dbs/init${ORACLE_SID}.ora ${ORACLE_HOME}/dbs/prapw${ORACLE_SID} \ /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs

Upgrade opatch on each node:

Run the following on each node
As oracle

cd ./u01/app/oracle/product/11.2.0.4/dbhome_1
unzip -o /oracle/software/p6880880_112000_Linux_x86_64.zip

Create OCM responce file

As oracle

The following command has 2 prompts:

1. Email address/User Name: Leave Blank

2. Do you wish to remain uninformed of security issues(Yes,No)N:Answer "Y"

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/ocm/bin/emocmrsp -no banner -output /var /tmp/ocm.rsp

Example Output:

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/ocm/bin/emocmrsp -no banner -output /var /tmp/ocm.rsp

Email address/User Name: Leave Blank

Do you wish to remain uninformed of security issues(Yes,No)N:Y

The OCM configuration response file (/var/tmp/ocm.rsp) was successfully created


Apply the latest PSU on each node

As oracle
RDBMS patch will be used:

cd /oracle/software
mkdir psu
cd psu
unzip ../p26030799_112040_Linux_x86_64.zip
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/opatch apply /oracle/software/psu/p26030799 -oh ${ORACLE_HOME} -ocmrf /var/tmp/ocm.rsp

Verify the output mentions copying the PSU to all RAC nodes.
Example:

All nodes have been patched. you may start oracle instances on the local system and nodes...
Composite patch 26030799 successfully applied

OPatch session completed successfully with warnings.

Log file location:
/u01/app/oracle/product/11.2.0.4/dbhome_1/cfgtoollogs/opatch/opatch2018-05-28_18-56-09PM_1.log

Verify Installation:

As oracle 

Verify software installed on all nodes

for node in ${nodes} ; do

 ssh -q ${node} tail /u01/app/oraInventory/ContentsXML/inventory.xml

done

Verify PSU applied on all nodes.

for node in ${nodes} ; do

 ssh -q ${node} ls /u01/app/oracle/product/11.2.0.4/dbhome_1/psu

done

=============================================================================================================

11.2.0.4.0 DB Binaries Installation on Linux Non-RAC-Enviroment:


 Copy the below required files 


p13390677_112040_Linux_x86_64_1of7.zip
p13390677_112040_Linux_x86_64_2of7.zip


Copy PSU and OPatch 


p26030799_112040_Linux_x86_64.zip--PSU Patch
p6880880_112000_Linux_x86_64.zip---OPatch



Clean the Software Directory

Remove all previous installation software from oracle/software and change the directory group, So our personal ID's can copy software directly(dba group)

As a root 

cd /oracle/software
rm -fr database grid psu gpsu
chgrp dba /oracle/software
chmod 775 /oracle/software


Unzip the Database files

As oracle

unzip p13390677_112040_Linux_x86_64_1of7.zip
unzip p13390677_112040_Linux_x86_64_2of7.zip

Create RDBMS response file

As oracle

cd /oracle/software

grep -i ^[A-Z] database /response/db_install.rsp | sort > dbInstall.rsp


Modify the following variables as per  environment you are patching

DECLINE_SECURITY_UPDATES=true
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.EEOptionsSelection=true
oracle.install.db.InstallEdition=EE
oracle.install.db.OPER_GROUP=dba
oracle.install.option=INSTALL_DB_SWONLY
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolal:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0


Deploy Software

As oracle

cd /oracle/software/database
./runInstaller -silent -response /oracle/software/dbInstall.rsp


Copy init.ora and tnsnames.ora files to new RDBMS Home

For each node:

. oraenv

cp -p $ORACLE_HOME/network/admin/tnsnames.ora /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin

For each database:

. oraenv
cp - p $ORACLE_HOME/dbs/init${ORACLE_SID}.ora ${ORACLE_HOME}/dbs/prapw${ORACLE_SID} \ /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs

Upgrade opatch :

Run the following on each node
As oracle

cd ./u01/app/oracle/product/11.2.0.4/dbhome_1
unzip -o /oracle/software/p6880880_112000_Linux_x86_64.zip

Create OCM responce file

As oracle

The following command has 2 prompts:

1. Email address/User Name: Leave Blank

2. Do you wish to remain uninformed of security issues(Yes,No)N:Answer "Y"

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/ocm/bin/emocmrsp -no banner -output /var /tmp/ocm.rsp

Example Output:

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/ocm/bin/emocmrsp -no banner -output /var /tmp/ocm.rsp

Email address/User Name: Leave Blank

Do you wish to remain uninformed of security issues(Yes,No)N:Y

The OCM configuration response file (/var/tmp/ocm.rsp) was successfully created


Apply the latest PSU 

As oracle
RDBMS patch will be used:

cd /oracle/software
mkdir psu
cd psu
unzip ../p26030799_112040_Linux_x86_64.zip
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
${ORACLE_HOME}/OPatch/opatch apply /oracle/software/psu/p26030799 -oh ${ORACLE_HOME} -ocmrf /var/tmp/ocm.rsp

Verify the output mentions copying the PSU to all RAC nodes.
Example:

All nodes have been patched. you may start oracle instances on the local system and nodes...
Composite patch 26030799 successfully applied

OPatch session completed successfully with warnings.

Log file location:
/u01/app/oracle/product/11.2.0.4/dbhome_1/cfgtoollogs/opatch/opatch2018-05-28_18-56-09PM_1.log

Verify Installation:

As oracle 

Verify software installed on all nodes

for node in ${nodes} ; do

 ssh -q ${node} tail /u01/app/oraInventory/ContentsXML/inventory.xml

done

Verify PSU applied .

for node in ${nodes} ; do

 ssh -q ${node} ls /u01/app/oracle/product/11.2.0.4/dbhome_1/psu

done

************************************************** All The Best *********************************************

Wednesday, 3 October 2018

Restoring Database Using Restore Point-Single Instance(Non-Rac)

SQL>Select name,open_mode,database_role,current_scn,flashback_on from v$database;

NAME        OPEN_MODE    DATABASE_ROLE   CURRENT_SCN    FLASHBACK_ON
=======     ==========   =============   ===========    ==================
TESTDB1     READ WRITE   PRIMARY         3283000481     RESTORE POINT ONLY                       

SQL> select * from v$restore_point;

SCN        NAME    DATABASE_INCARNATION#   GUA   STORAGE_SIZE   TIME
========== =====    =====================   ===   ============   ===============================
3281420775  RPOINTB   2                       YES   4294967296     24-APR-17 11.25.07.000000000 AM

SQL>Shu immediate; 
Database closed. 
Database dismounted. 
ORACLE instance shut down.

SQL> startup mount; 
ORACLE instance started. 
Total system Global Area     8589934 bytes
Fixed size                   592 2944952 bytes
variable size                6794772552 bytes
Database Buffers             1778384896 bytes
Redo Buffers                 13832192 bytes
Database mounted.

SQL> Select name,open_mode,database_role,current_scn,flashback_on from v$database; 

NAME        OPEN_MODE    DATABASE_ROLE   CURRENT_SCN    FLASHBACK_ON
=======     ==========   =============   ===========    ==================
TESTDB1     MOUNTED      PRIMARY         3283000481     RESTORE POINT ONLY      

SQL> select * from v$restore_point;

SCN            DATABASE_INCARNATION#   GUA   STORAGE_SIZE   TIME
==========     =====================   ===   ============   ===============================
3281420775     2                       YES   4294967296     24-APR-17 11.25.07.000000000 AM


SQL> flashback database to restore point RPOINTB; 

Flashback complete. 

SQL> alter database open resetlogs; 

Database altered. 


SQL>Select name,open_mode,database_role,current_scn,flashback_on from v$database;

NAME        OPEN_MODE    DATABASE_ROLE   CURRENT_SCN    FLASHBACK_ON
=======     ==========   =============   ===========    ==================
TESTDB1     READ WRITE   PRIMARY         3281425954     RESTORE POINT ONLY