Oracle Database 11.2.0.2 : Online Patch devient réel

Si vous lisez la documentation ou de certains blogs bien choisis comme celui de Laurent Schneider, vous savez qu’Oracle promet de livrer des patchs online depuis la version 11.1.0.6. Cela dit entre la promesse et la réalité, il aura fallu attendre de long mois.

La note MOS « 761111.1 RDBMS Online Patching Aka Hot Patching » indique en effet « It will be delivered starting with RDBMS 11.2.0.2.0. ». Et de fait, lorsque vous regardez les patchs 11.2.0.2, ce qui restait une théorie une possibilité devient réel ; voici quelques exemples réels de patchs online réels :

  • 9912965: LRG9H32: GTX DIES WITH ORA-00600 [KJUSCL:!FREE]
  • 9943960: « TTX ID1: %X ID2: %X RET: %D WAITOPT: %D »MESSAGE IN TRACE FILE
  • 10188727 – Dump (kkeidc) from parallel nested loops on REFERENCE partitioned table

Voici quelques notes à propos de l’application des « patchs online » ou « hot patches »

Principe des online patchs

Un online patch consiste à déployer une bibliothèque dynamique (.so ou .dll) plutôt que de modifier les bibliothèques existantes en appliquant dans les programmes ou .dll originales, les .o ou modification qui comprennent les modification de code.

Une fois le patch déployé dans ce mode particulier, le noyau Oracle est notifié à l’aide d’une commande oradebug va dynamiquement changer le chargement de son code et effectuer un branchement différent de celui original pour passer par la nouvelle branche de code.

On comprend donc bien qu’un patch online ne fonctionne pas exactement comme un patch classique, qu’il nécessite plus de mémoire et qu’il faudra le repasser dans un fonctionnement classique lors d’un prochain arrêt. On comprend également qu’il est essentiel que l’infrastructure soit éprouvée avant de proposer ce genre de fonctionnement d’où :

  • une longue période entre le l’annonce de la fonctionnalité et la mise au point opérationnelle (11.1.0.6) et son utilisation effective régulière (11.2.0.2) dans les déploiements
  • une période d’adaptation des équipes de développement et de tests
  • l’impossibilité d’utiliser ce type de patches dans tous les cas de problèmes ou dans les CPU, malgré l’objectif annoncé d’Oracle.

Application des patchs

Activer le patch s’effectue avec opatch en ajoutant les mots clé online et -connectstring pour que celui-ci, une fois le patch installé dans $ORACLE_HOME/hpatch indique au RDBMS de l’utiliser via oradebug.

Voici les traces d’une installation type:

$ORACLE_HOME/OPatch/opatch apply online -connectstring BLACK:::
Invoking OPatch 11.2.0.1.5

Oracle Interim Patch Installer version 11.2.0.1.5
Copyright (c) 2010, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.5
OUI version : 11.2.0.2.0
OUI location : /u01/app/oracle/product/11.2.0/db_1/oui
Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2011-05-22_13-01-29PM.log

Patch history file: /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt


The patch should be applied/rolled back in '-all_nodes' mode only.
Converting the RAC mode to '-all_nodes' mode.
ApplySession applying interim patch '9912965' to OH '/u01/app/oracle/product/11.2.0/db_1'

Running prerequisite checks...
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name:

You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: Y

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '9912965' for restore. This might take a while...
Backing up files affected by the patch '9912965' for rollback. This might take a while...

Patching component oracle.rdbms, 11.2.0.2.0...
The patch will be installed on active database instances.
Installing and enabling the online patch 'bug9912965.pch', on database 'BLACK'.

ApplySession adding interim patch '9912965' to inventory

Verifying the update...
Inventory check OK: Patch ID 9912965 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 9912965 are present in Oracle Home.


OPatch succeeded.

Vous pouvez vérifier dans l’inventory que le patch n’est pas installé comme les autres mais bien en mode online :

$ORACLE_HOME/OPatch/opatch lsinv
Invoking OPatch 11.2.0.1.5

Oracle Interim Patch Installer version 11.2.0.1.5
Copyright (c) 2010, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.5
OUI version : 11.2.0.2.0
OUI location : /u01/app/oracle/product/11.2.0/db_1/oui
Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2011-05-22_13-05-58PM.log

Patch history file: /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2011-05-22_13-05-58PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle Database 11g 11.2.0.2.0
There are 1 products installed in this Oracle Home.


Interim patches (3) :

Patch (online) 9912965: applied on Sun May 22 13:01:42 GMT+01:00 2011
Unique Patch ID: 13712877
Created on 3 May 2011, 21:12:45 hrs PST8PDT
Bugs fixed:
9912965


Patch 12431716 : applied on Sun May 22 10:50:35 GMT+01:00 2011
Unique Patch ID: 13720930
Created on 5 May 2011, 21:52:04 hrs PST8PDT
Bugs fixed:
12431716
This patch overlays patches:
11724916
This patch needs patches:
11724916
as prerequisites

Patch 11724916 : applied on Sun May 22 10:47:12 GMT+01:00 2011
Unique Patch ID: 13739423
Created on 1 Apr 2011, 07:09:05 hrs PST8PDT
Bugs fixed:
10151017, 10158965, 11724916, 10190642, 10129643, 10018789, 9744252
10248523, 9956713, 10356513, 9715581, 9770451, 10170431, 10425676
10222719, 9591812, 10127360, 10094201, 11069199, 10245086, 10205230
10052141, 11818335, 11830776, 11830777, 9905049, 11830778, 10077191
10358019, 10219576, 10264680, 10209232, 10102506, 11067567, 9881076
10040531, 10218814, 9788588, 9735237, 10230571, 10079168, 10228151
10013431, 10217802, 10238786, 10052956, 11699057, 10080579, 10332111
10227288, 10329146, 10332589, 10110863, 10073683, 10019218, 10229719
10373381, 11724984, 9539440, 10411618, 10022980, 10187168, 6523037
9724970, 10084145, 10157402, 9651350, 10299224



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

OPatch succeeded.

Suppression du patch online

Vous pouvez désinstaller vos patchs en ligne également :

cd $ORACLE_HOME/OPatch
./opatch rollback -id 9912965 -connectstring BLACK:::
Invoking OPatch 11.2.0.1.5

Oracle Interim Patch Installer version 11.2.0.1.5
Copyright (c) 2010, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.2.0.1.5
OUI version       : 11.2.0.2.0
OUI location      : /u01/app/oracle/product/11.2.0/db_1/oui
Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2011-05-22_13-46-19PM.log

Patch history file: /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

RollbackSession rolling back interim patch '9912965' from OH '/u01/app/oracle/product/11.2.0/db_1'

The patch should be applied/rolled back in '-all_nodes' mode only.
Converting the RAC mode to '-all_nodes' mode.

Running prerequisite checks...

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.

Backing up files affected by the patch '9912965' for restore. This might take a while...

Patching component oracle.rdbms, 11.2.0.2.0...
The patch will be removed from active database instances.
Disabling and removing online patch 'bug9912965.pch', on database 'BLACK'

RollbackSession removing interim patch '9912965' from inventory

OPatch succeeded.

./opatch lsinv
Invoking OPatch 11.2.0.1.5

Oracle Interim Patch Installer version 11.2.0.1.5
Copyright (c) 2010, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.5
OUI version : 11.2.0.2.0
OUI location : /u01/app/oracle/product/11.2.0/db_1/oui
Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2011-05-22_13-48-04PM.log

Patch history file: /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2011-05-22_13-48-04PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle Database 11g 11.2.0.2.0
There are 1 products installed in this Oracle Home.


Interim patches (2) :

Patch 12431716 : applied on Sun May 22 10:50:35 GMT+01:00 2011
Unique Patch ID: 13720930
Created on 5 May 2011, 21:52:04 hrs PST8PDT
Bugs fixed:
12431716
This patch overlays patches:
11724916
This patch needs patches:
11724916
as prerequisites

Patch 11724916 : applied on Sun May 22 10:47:12 GMT+01:00 2011
Unique Patch ID: 13739423
Created on 1 Apr 2011, 07:09:05 hrs PST8PDT
Bugs fixed:
10151017, 10158965, 11724916, 10190642, 10129643, 10018789, 9744252
10248523, 9956713, 10356513, 9715581, 9770451, 10170431, 10425676
10222719, 9591812, 10127360, 10094201, 11069199, 10245086, 10205230
10052141, 11818335, 11830776, 11830777, 9905049, 11830778, 10077191
10358019, 10219576, 10264680, 10209232, 10102506, 11067567, 9881076
10040531, 10218814, 9788588, 9735237, 10230571, 10079168, 10228151
10013431, 10217802, 10238786, 10052956, 11699057, 10080579, 10332111
10227288, 10329146, 10332589, 10110863, 10073683, 10019218, 10229719
10373381, 11724984, 9539440, 10411618, 10022980, 10187168, 6523037
9724970, 10084145, 10157402, 9651350, 10299224

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

OPatch succeeded.

A noter:
Il ne semble pas possible de désinstaller le patch online alors que l’instance est arrêtée. Evidemmemt, vous pouvez supprimer directement le contenu du répertoire $ORACLE_HOME/hpatch toutefois, (1) la procédure n’est pas supportée et surtout (2) la procédure ne met pas à jour l’inventory ce qui oblige à lancer opatch ultérieurement et prendre en compte les messages d’erreur qui découlent de ce type de manipulations

Réinstaller le patch offline

Une fois le patch online supprimé, vous pouvez le réinstaller en mode offline comme classiquement ; en regardant alors votre inventaire, vous voyez que l’indication online disparait :

$ORACLE_HOME/OPatch/opatch lsinv
Invoking OPatch 11.2.0.1.5

Oracle Interim Patch Installer version 11.2.0.1.5
Copyright (c) 2010, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/oracle/product/11.2.0/db_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.5
OUI version : 11.2.0.2.0
OUI location : /u01/app/oracle/product/11.2.0/db_1/oui
Log file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch2011-05-22_14-03-58PM.log

Patch history file: /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2011-05-22_14-03-58PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle Database 11g 11.2.0.2.0
There are 1 products installed in this Oracle Home.


Interim patches (3) :

Patch 9912965 : applied on Sun May 22 14:02:56 GMT+01:00 2011
Unique Patch ID: 13712877
Created on 3 May 2011, 21:12:45 hrs PST8PDT
Bugs fixed:
9912965


Patch 12431716 : applied on Sun May 22 10:50:35 GMT+01:00 2011
Unique Patch ID: 13720930
Created on 5 May 2011, 21:52:04 hrs PST8PDT
Bugs fixed:
12431716
This patch overlays patches:
11724916
This patch needs patches:
11724916
as prerequisites

Patch 11724916 : applied on Sun May 22 10:47:12 GMT+01:00 2011
Unique Patch ID: 13739423
Created on 1 Apr 2011, 07:09:05 hrs PST8PDT
Bugs fixed:
10151017, 10158965, 11724916, 10190642, 10129643, 10018789, 9744252
10248523, 9956713, 10356513, 9715581, 9770451, 10170431, 10425676
10222719, 9591812, 10127360, 10094201, 11069199, 10245086, 10205230
10052141, 11818335, 11830776, 11830777, 9905049, 11830778, 10077191
10358019, 10219576, 10264680, 10209232, 10102506, 11067567, 9881076
10040531, 10218814, 9788588, 9735237, 10230571, 10079168, 10228151
10013431, 10217802, 10238786, 10052956, 11699057, 10080579, 10332111
10227288, 10329146, 10332589, 10110863, 10073683, 10019218, 10229719
10373381, 11724984, 9539440, 10411618, 10022980, 10187168, 6523037
9724970, 10084145, 10157402, 9651350, 10299224

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

OPatch succeeded.

Notes complémentaires

Lorsque vous avez installé le patch avec opatch, vous pouvez ensuite manipuler son utilisation à l’aide de la commande oradebug comme ci-dessous,
même si la méthode n’est pas officiellement supportée :

sqlplus / as sysdba

oradebug patch help

oradebug patch [list|install|remove|disable|enable] <file> <temp>

temp = (disabled at restart default=perm)
file = (in $ORACLE_HOME/hpatch/)


oradebug patch list

Patch File Name State
================ =========
bug9912965.pch ENABLED


oradebug patch disable bug9912965.pch
Statement processed.
oradebug patch list

Patch File Name State
================ =========
bug9912965.pch DISABLED

Les informations sont également disponibles dans fichier alert.log comme vous pouvez le voir dans l’extrait ci-dessous :

Completed: ALTER DATABASE OPEN
Sun May 22 15:10:13 2011
Patch file bug9912965.pch is out of sync with oracle binary; performing fixup
Patch file bug9912965.pch has been synced with oracle binary
Patch bug9912965.pch Installed - Update #1
Patch bug9912965.pch Enabled - Update #2
Sun May 22 15:10:15 2011
Online patch bug9912965.pch has been installed
Online patch bug9912965.pch has been enabled
Sun May 22 15:11:05 2011
Patch bug9912965.pch Disabled - Update #3
Sun May 22 15:11:06 2011
Online patch bug9912965.pch has been disabled
Sun May 22 15:13:35 2011

Habituez-vous à ce mode de fonctionnement. En effet, les exceptions de la version actuelle devraient devenir la norme au fur et à mesure des versions. Lisez la note 761111.1 disponible sur MOS pour tous les détails qui sont, d’ailleurs, parfois en contradiction avec la documentation et notamment quant aux plateformes supportées…