Quotidien Shaarli

Tous les liens d'un jour sur une page.

July 31, 2023

How to apply patches on Oracle DB
  1. Download patches

  2. backup precheck
    cd precheck
    ps -ef |grep pmon > current_instance.txt
    ps -ef |grep tns > current_tns.txt
    cat /etc/oratab > current_oratab.txt
    $ORACLE_HOME/OPatch/opatch lsinventory > before_current_lsinventory.txt

  3. Check conflicts
    export PATH=$ORACLE_HOME/OPatch:$PATH
    opatch version
    unzip <patch.zip> && cd <path folder>
    opatch prereq CheckConflictAgainstOHWithDetail -ph ./

  4. Stop oracle database and listeners

  5. Check
    ps -ef|grep pmon
    ps -ef|grep tns
    ps -ef|grep exp
    ps -ef|grep rman

  6. Apply patch
    opatch apply

  7. Check
    opatch lsinventory > after_current_lsinventory.txt

  8. Start only oracle database (not the listener)

  9. Patch data
    datapatch -verbose

  10. Check
    sqlplus / as sysdba
    SET LINESIZE 400
    COLUMN action_time FORMAT A20
    COLUMN action FORMAT A10
    COLUMN status FORMAT A10
    COLUMN description FORMAT A40
    COLUMN version FORMAT A10
    COLUMN bundle_series FORMAT A10

SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,action,status,description,patch_id FROM sys.dba_registry_sqlpatch ORDER by action_time;

  1. Check stop and start
    sqlplus / as sysdba
    shutdown immediate
    startup
    select name,open_mode from v$database;

  2. Start the listener