Monday, July 27, 2020

PSU PATCH ON 12C ORACLE DATABASE

PSU PATCH ON 12C ORACLE DATABASE
--------------------------------------------------------

Patching: To fix bugs in previous database software releases in the oracle database software 


Two types Of Patches
---------------------------

Critical Patch Update(CPU) ,now known as  Security Patch Update(SPU)

Patch set Upadte (PSU) will aplly these patches using OPatch tool 

Opatch is the ----> Oracle Patching Tool

  will download from metalink.oracle.com
                     support.oracle.com

How Frequently will release ----->quarterly

will backup level0 before patching( full database backup)

we need downtime to apply the patching first will apply in development then will proceed in production 

backout time----->plan---->atleast ---->1hr --4 hrs


Finding Version of Database
----------------------------------

sql>select banner from v$version;  (db version)
sql>select parameter compatible;

9i,10g,11g,12c,18c,19c

we can list ----> $ OPatch ls inventory


Significance of Version
-----------------------------

12.1.0.1.0-------> Release 1 ------>12cR1

12.2.0.1.0-------> Release 2 ------>12cR2

9.1.0.1.0--------->Release 1

9.2.0.1.0---------->Release2

i-------->Internet from 8i ,9i

g-------->grid---->To manage Resources Automatically

c-------->Cloud multitenant feature

12-------->Main Release Number

1---------> Maintanance Release Number

0--------->Application Release Number

1--------->Patch set Number

0--------->Platform Release number


How do i apply in PSU patch in oracle database
---------------------------------------------------------

1)Download the patch from Oracle support Portal

2)Validate the Patch Version

3)Copy the zip to ORACLE_HOME

4)Remove the existing OPatch directory 

5)Unzip the Zip File

6)Copy and Unzip the PATCH zip file

7)Check the conflict again ORACLE_HOME


Lets Start the Process how to apply psu patch on 12 c database
---------------------------------------------------------------------------

$ ORACLE_HOME/OPatch/opatch version

OPatch version :12.1.0.1.3

$ ls -lrt

cp p24006101-121020_linux_x86_64.zip  $ ORACLE_HOME

$ cd $ ORACLE_HOME

ls -lrt

OPatch

$ mv OPatch OPatch_27jul2020

$unzip p24006101-121020_linux_x86_64.zip

$ ORACLE_HOME/OPatch/opatch version

OPatch version ----->12.2.0.1.8

OPatch succeded

$ ps - ef |grep smon

ora--->smon-->proddb

$ ps - ef |grep tns

LISTENER--->proddb

$lsnrctl stop LISTENER_PRODB

$sqlplus '/as sysdba'

shut immediate

exit

$ ps -ef |grep ORA

cd / u03

ls -ltr

$unzip p24006101-121020_linux_x86_64.zip

(The moment you unzip the file we 24006101 directory created like this they will ask like wheter you want to ready the apply the patch db is to shutdown and whether the patch applied to local machine or not Opatch ls inventory it shows the what time what patch will applied 11 g we used cat bundle in sql here 12 c os prompt os level dba_registry_sqlplus database version)


ls -ltr

24006101

cd 24006101

$ ORACLE_HOME/OPatch/opatch apply (it will ask like interactive i mentioned in above)

--->y

---->y

--->y

Composite Patch 2406101 sucessfull applied

$ ORACLE_HOME/OPatch/opatch ls inventory

sqlplus '/as sysdba'

startup

exit

$cd $ ORACLE_HOME/OPatch

$ ./datapatch - verbose

to list the patches applied

$cd ORACLE_HOME/OPatch

$ ./OPatch lsinventory

patch 24006101 apply sucess at databasee level

sqlplus '/as sysdba'

sql>select * from dba_registry_sqlplus;

$lsnrctl start 


Note : Info on psu patch update it may be differ from your environment like production,testing,development,and directories




THANK YOU FOR VIEWING MY BLOG FOR MORE UPDATES FOLLOE ME




ORACLE 12C DATABASE INSTALLATION



ORACLE 12C DATABASE INSTALLATION
---------------------------------------------------------

Prerequisites
-------------- ---

Oracle linux installed

Configure /etc/hosts file

    Adding host entry with ip.

#vi /etc/hosts

127.0.0.1  localhost.localdomain  localhost
192.169.2.3    host1.chaitanya.com host1

Save it
esc :wq!


Network Configuration
----------------------------

#neat
    Double Click - eth0
    hardware Device - Probe(click)

    Deactivate - and activate - file - save.

--------------------------------------------

#df -h
#cd /mnt/hgfs
#ls
#cd 12csoft
#ls
# cp linuxamd64_12c_database_* /softwares/

Will unzip the files
#cd /softwares
#ls
#unzip linuxamd64_12c_database_1of2.zip
#unzip linuxamd64_12c_database_2of2.zip

Note: also can use winscp/filezilla


--------------------------------------------------
Creating groups and user - OS level
--------------------------------------------

    To manage Oracle Installed binaries, will create OS groups and user.

     Oracle recommends three groups.
    dba - Full Administrative privileges
    oinstall - Will have privileges on inventory files.
    oper  - optional - operational - limited privileges

#groupadd dba
groupadd oper
groupadd oinstall

Now create user oracle
#useradd -g oinstall -G dba,oper  oracle
#passwd oracle
: oracle123

    Note:     -g -? Primary Group
        -G -? Secondary Group
------------------------------------------------------------------
Changing Ownership and permissions to oracle on Files
------------------------------------------------------------------

using chown will change from root to oracle
#chown -R oracle:oinstall /u01
chown -R oracle:oinstall /orabackup
chown -R oracle:oinstall /archives
chown -R oracle:oinstall /softwares
chown -R oracle:oinstall /oradata


Now ...provide read/write/execute on files/folders to oracle user.
using chmod
#chmod -R 775 /u01
chmod -R 775 /orabackup
chmod -R 775 /archives
chmod -R 775 /softwares
chmod -R 775 /oradata


        read / write / execute
        owner group public
        rwx    rwx  r-x
        7       7     5


Verify now..
cd /softwares
ls -ltr
    will see..
            oracle oinstall on every folder/file.
---------------------------------------------------------------
hosts file
neat - network configuration
shared folder -enable - copy files /softwares
unzip
groups - add
user - add - oracle
chown - 
chmod 

------------------------
software Copy 
Groups / user creation - oracle,dba,oper,oinstall
ownership
Permissions


Display - resolution 
#xhost +
Switch the user from root to oracle
#su - oracle
$cd /softwares
$ls
$cd database
$ls
$./runInstaller
note: . to execute
/ from current folder
----------------------------------------

Uncheck - I wish to receive security updates

Skip Software updates->
server Class - >Create and Configure Database
-> Single Instance Database.

Base : /u01/app/oracle
Software location : dbhome_1
Database File System : /oradata
Edition: Enterprise Edition
Global Database Name : prod.chaitanya.com
AdminPaswd : sys123
confirm : sys123
OSDBA -: DBA

unchk : create as container database(ignore)

directory : /u01/app/oraInventory
groupName: oinstall
Click - run and fix up - button
open a terminal
log in as root
run the following script. to fix recommended prerequisit changes.

# /tmp/CVU_12.1.0.1.0_oracle/runfixup.sh 

-------------------------------------------------

Recommended RPM Packages
Redhat package Manager - tool will install rpms
Will find these rpms in ISO file/use yum install.
VM -> settings - > CDROM - Connect - > Choose ISO file.

In Terminal .
#df -h
# cd /media/OL5.8\ x86_64\ dvd\ 20120229/Server
#ls -ltr
will find rpms
Now install two pending packages
# rpm -ivh libaio-devel-0.3.106-5.*.rpm
# rpm -ivh sysstat-7.0.2-11.el5.x86_64.rpm 
now click 
Check again - to verify

then 
Click on
Install...proceed further.
--------------------------------------------------------
Final Step - running two root scripts

from root user in another terminal.

#/u01/app/oraInventory/orainstRoot.sh
#/u01/app/oracle/product/12.1.0/dbhome_1/root.sh

root.sh will create /etc/oratab file , will make an entry 
the database name and home which installed.
using oratab file, can find number of databases on ur server.

-----------------------------------------
Configure - environment Variable using .bash_profile

for every OS user , default one bash_profile exists
For oracle user
we have /home/oracle
is a hidden file prefixed with dot.
List the hidden files
$ls -ltra

$vi .bash_profile

#Append few parameters following

TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=prod; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


Now ... save the file
esc   :wq!

NOw execute the bash_profile
$. .bash_profile
now verify 
using echo
$echo $ORACLE_SID
$echo $ORACLE_BASE

How to connect Database?
sqlplus '/as sysdba'
sql>select name,open_mode,database_role from v$database;
sql>connect /as sysdba
or
sql>connect sys/sys123 as sysdba
or
sql>connect sys as sysdba
sql>passwd: sys123

Note : / represents sys user with sysdba role


Verify currently which SID is configured in terminal
$echo $ORACLE_SID

To connect to differnt database
then export 
eg: for dev db
$export ORACLE_SID=dev
sqlplus '/as sysdba'

or
. oraenv
SID:dev
sqlplus



Note: info on oracle database 12c installation it may be differ from your environment like production,testing,development, and ip address and host names
 and directories




THANK YOU FOR VIEWING MY BLOG FOR MORE UPDATES FOLLOW ME
































































ORACLE 11G TO 12C DATABASE UPGRADE MANUALLY


ORACLE 11G TO 12C DATABASE UPGRADE MANUALLY
-----------------------------------------------------------------------------




SUMMARY ORACLE 11.2.0.4 TO 12.1.0.1 UPGRADE MANUALLY
----------------------------------------------------------------------------------------

PREPARE FOR UPGARDE:
-------------------------------------

1)Take the database backup via Rman

2)Take oracle_home,orainventory backup via os level copy

3)Run the utlrp.sql script to validate the invalid objects

4)exec dbms_stats.gather_database_stats;

5)exec dbms_stats.gather_dictinary_stats;

6)exec dbms_stats.gather_fixed_object_stats;


INSTALL 12.1.0.1:
------------------------

1)Download and Install 12.1.0.1 into a a different Oracle_home location

2)Run the pre_update tility which resides under 12.1.0.1 home

     12.1.0.1_home/rdbms/admin/preupgrad.sql

3)Review and fix all the issues reported via above script

4)Shutdown the Database, Listener.EMC(Enterprise manager)


START THE UPGRADE:
---------------------------------

1)Copy DBS and Network Folder from old ORACLE_HOME to new ORACLE_HOME

2)Set environmental variable old ORACLE_HOME to new ORACLE_HOME loaction

3)Start up the Database in startup upgarde mode

4)Run the upgarde utilitywhich upgrades the database exit from sqlplus

    cd $ ORACLE_HOME/rdbms/admin
       $ ORACLE_HOME/perl/bin/perl catctl.pl catupgrad.sql


POST UPGRADE STEPS:
-----------------------------

1)Start up the Database Normally make sure its started with 12.1.0.1 ORACLE_HOME

2)Run the utlrp.sql script to validate the invalidobject

3)Run the post- update script 

  12.1.0.1_home/rdbms/admin/utlu121s.sql

  12.1.0.1_home/rdbms/admin/catuppst.sql

  12.1.0.1_home/rdbms/admin/utlu121s.sql 

4) Check the Component status
   
   sql>select comp_name,status,substr(vesrion,1,10) as version from dba_registry;

5)Change the Compatibilty parameter to 12.1.0.1

  sql>alter system set compatibile= '12.1.0.1.0' scope= spfile;

6)Check the vesrion details

  sql>select comp_name,version,status from dba_resgistry;


CLEAN UP PROCESS:
------------------------------

1)Update the new oracle_home under /etc/oratabfile

2)Uninstall the old_home

3)Take a fresh backup of Database post upgrade



Note: Upgrade only for the binaries not for the data


NOW LETS START WITH THE PROCESS :
-----------------------------------------------------------


$ ps - ef | grep pmon

$ sqlplus '/as sysdba'

sql> starup

Oracle instance started 

Database Opened

sql> select name,open_mode from v$database;

   name--->proddb

   open_mode---->read,write

sql>exit

$ rman target /

RMAN> list backup of database summary;

RMAN> show all;

Configure channnel device type to disk  '/u02/backup/proddb_%U';

RMAN>exit

$ df -h

 for eg    /u02 is filled with 80% ofthe disk 

  so available space in /u03


$ mkdir - p /u03/backup        ( we cretaed a directory backup in u03 location bcoz space is available)

$ rman target /

RMAN> configure channel device type disk format '/u03/backup/proddb_%U';

RMAN> congigure channel device type disk format '/u03/backup/proddb_%U';

   Rman parameters successfully configured

RMAN> show all;

RMAN> backup database;

RMAN>exit

$ sqlplus  '/as sysdba ' 

sql> exec dbms_stas.gather_database_stats;

open a terminal login as oracle user execeute second script

sql>exec dbms_stats.gather_dictionary_stats;

and next open another new terminal login as a oracle user and execute the third script

sql>exec dbms_stas.gather_fixed_object_stats;

once the script is complted close the terminal and have an error in the scripts do it again and run the script

after that 12c binaries and into different location already 12c database downloaded inthe /u03 location

login in as oracle user  ( 12 c database  (binaries) unzip one by one 12c release 1 software after that we have to create a oraclehome directory in /u03 after unzipped 
 create a directory database folder in the softwares directory 


Note : old oracle_home    /u02/oracle/11.2.0.4/db_home
       new oracle_home    /u03/oracle/12.1.0.1/db_home

$ df -h

/u02
/u03

$ cd /u03/
 ls
  we will find folders backup  lost+fount  softwares

 $ cd softwares /
$ ls -lrth

linuxamd64_12c_database_1of2.zip
linuxamd64_12c_database_2of2.zip

$ unzip linuxamd64_12c_database_1of2.zip
$ unzip linuxamd64_12c_database_2of2.zip

$ df -h
  $ env |grep ORA

ORACLE_SID = proddb

ORACLE_HOME =/u02/oracle/11.2.0.4/db_home


$ mkdir -p /u03/oracle/12.1.0.1/db_home

$ cd softwares

$ ls 

database 

$ softwares] cd database

ls
 
runInstaller

$ ./runInstaller

  ( Oracle Installer 12c window is starting before getting into installation 12c one thing i have to tell that 12c is a multitenant architecture we have cdb and pdb concept will come on 12c and we are installing only binaries that is install database software only  after that login as a root user run that root.sh script back to the first terminal env it shows the old loaction we have to go the sql prompt login as sysdba go to the oracle home loaction rdbms/admin/preupgrad.sql run the procedure all the prechecks  before upgrade we have to check the log preupgradation utility once the run preupgrad utility go to the sql plus)

-----> Insatll database software only

------>single Instance database installation 

------> go with enterprise edition 

         oracel_base : /u03/oracle/oraclebase

         software location :/u03/oracle/12.1.0.1/db_home
      
         click on --->next
     
        select dba --->all

        click on --->install on your server

Open a new terminal

 login as root user

and execute the root.sh scripts

# /u03/oracle/12.1.0.1/db_home/root.sh

after execucting this script 12 c installatioin is done

$ env |grep ORA

 ORACLE_SID = proddb
 ORACLE_HOME= /u02/oracle/11.2.0.4/db_home

sqlplus '/as sysdba

sql> @ /u03/oracle/12.1.0.1/db_home/rdbms/admin/preupgrad.sql

(preupgrade  pre execute is complete some errors and warnings we have go to the logs and check the errors and warnings)

$ cat /u02/oracle/11.2.0.4/db_home/cfgtoollogs/proddb/preupgrad/preupgrad.log

$ sqlplus '/as sysdba'

sql> alter system set process = 300 scope =spfile;

sql>execute dbms_preup.purge_recyclebin_fixup;

sql>pl/sql procedure suceesfully completed

sql >shutdown immediate 

sql> startup

  database opened

sql> @/u03/oracle/12.1.0.1/db_home/rdbms/admin/preupgrad.sql

sql> exit

$ cat /u02/oracle/11.2.0.4/db_home/cfgtoollogs/proddb/preupgrade/preupgrade.log

(Return the preupgrad utility once again and resolve the errors and warnings and see the log file there is no error in the log look at the log file and found 0 errors)

sqlplus '/as sysdba'

 shutdown immediate
exit

ps -ef | grep pmon

ps -ef| grep tns

$ env |grep ora

ORACLE_SID = proddb

ORACLE_HOME ='/u02/oracle/11.2.04/db_home

( We need to copy the spfile and network/admin listener & Tns files to 12.1.0.1 home location

 11.2.0.4-----> db_home/dbs----> spfile  copy ----> new loaction 12.1.0.1 /u03/db_home/dbs 
    11.2.0.4------->  db_home/network/admin----> tnsnames.ora listener.ora  shrept.lst copy all files to new location  --->12.1.0.1 /u03/db_home/network/admin 

(copy the dbs and network folder from old oracle_home 11gto new oracle_home 12c location let us check the directory /u03 whether the files are copied or not)

ORACLE_SID = proddb

ORACLE_HOME ='/u02/oracle/11.2.04/db_home

$cd  u02/oracle/11.2.0.4/db_home/dbs

$ ls -lrth
 
$ cp * /u03/oracle/12.1.0.1/db_home/dbs/

ls -lrth /u03/oracle/12.1.0.1/db_home/dbs/

$ cd /u02/oracle/11.2.0.4/db_home/network/admin/

$ ls -lrt

$ cp * /u03/oracle/12.1.0.1/db_home/network/admin/

$ ls -lrth u03/oracle/12.1.0.1/db_home/network/admin/

 tnsnames.ora, listener.ora ,shrept.lst

$ env |grep ORA

ORACLE_SID = proddb

ORACLE_HOME ='/u02/oracle/11.2.04/db_home

$ export ORACLE_HOME ='/u03/oracle/12.1.0.1/db_home

(Till now we will not change environment till its pointing to oracle home 11204 so set the export oracle_home and  oraclepath after that once again check now its pointing to 12c home)

$ echo $ path
$ /usr/lib64/qt_3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/u03/oracle/11204/db_home/bin

$ export path= /usr/lib64/qt_3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/u03/oracle/12101/db_home/bin

$ env |grep ORA

ORACLE_SID = proddb
ORACLE_HOME =/u03/oracle/12.1.0.1/db_home

sqlplus '/as sysdba'

release version it showing while opening database 12.1.0.1.0

exit

$ lsnrctl

$ rman

exit

$ env |grep ORA


ORACLE_SID = proddb
ORACLE_HOME =/u03/oracle/12.1.0.1/db_home

sqlplus '/as sysdba'

sql>startup upgrade

sql> select instance_name,status from v$instance;

instance_name--> proddb
status----->open migrate

exit

cd $ oracle_home/rdbms/admin

$ pwd

/u03/oracle/12.1.0.1/db_home/rdbms/admin

$ ORACLE_HOME/perl/bin/perl catctl.pl

catupgrd.sql

$ ps -ef |grep pmon 

env |grep ORA

ORACLE_SID = proddb
ORACLE_HOME =/u03/oracle/12.1.0.1/db_home

sqlplus '/as sysdba'

sql> startup

sql> select name,open_mode from v$database;

name---> proddb
open_mode--->read,write


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

pl/sql procedure sucessfully completed

sql> @?/rdbms/admin/catuppst.sql

sql> @?/rdbms/admin/utlul21s.sql

check the component status


sql> set lines 999;

 col comp_name for a60;

/

sql> select comp_name,status,substr(version,1,10)as vesrsion from dba_regsistry;

sql> show parameter compatible;
 compatible  11.2.0.4.0

sql> alter system set compatible= '12.1.0.1.0' scope=spfile;

sql> select comp_name,vesrion,status from dba_registry;

bounce the database

sql> shut immediate

exit

sqlplus '/as sysdba'

sql> select name,open_mode from v$database;

name---> proddb
open_mode--->reda,write

exit

$ vi /etc/oratab

proddb: /u03/oracle/12.1.0.1/db_home:n

(just remove the old oracle home to new oracle home)

cat etc/oratab

proddb: /u03/oracle/12.1.0.1/db_home:n

vi bash_profile

after that execute the bash profile

..bash_profile


export oracle_home= '/u03/oracle/12.1.0.1/db_home 

env | grep ORA

ORACLE_SID = proddb
ORACLE_HOME =/u03/oracle/12.1.0.1/db_home


Note: Upgrading 11g to 12c info on it may be differ from your environment like production,testing ,development. and directory structure etc 



THANKS FOR VIEWING MY BLOG FOR MORE UPDATES FOLLOW MY SITE  
https://chaitanyaoracledba.blogspot.com/









 

 






     
     



ITIL Process

ITIL Process Introduction In this Blog i am going to explain  ITIL Process, ITIL stands for Information Technology Infrastructure Library ...