Applying Datapatch to PDB$SEED

Neste artigo, eu havia aplicado o Datapatch em alguns PDBs do meu CDB$ROOT, porém não tinha feito o processo do PDB$SEED. Então farei o processo para deixar o meu laboratório coeso, utilizando como referência o Oracle Note “Datapatch precheck failed : Release update is BEING installed to PDB but is not installed in CDB$ROOT.This will cause a patch mismatch between this PDB and CDB$ROOT (Doc ID 2604940.1)“.

Os PDBs do tipo SEED ficam apenas em modo leitura, conforme exemplo abaixo:

[oracle@quiasma admin]$ sqlplus / as sysdba
 
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Mar 30 04:27:47 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.13.0.0.0
 
SQL> SELECT INSTANCE_NAME,STATUS FROM V$INSTANCE;
 
INSTANCE_NAME    STATUS
---------------- ------------
TALAMO           OPEN
 
SQL> SELECT NAME,OPEN_MODE FROM V$PDBS WHERE NAME LIKE '%SEED%';
 
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
READ ONLY

Entretanto, para aplicaros o Datapatch, é necessário que o mesmo esteja aberto. Desse modo, a Oracle sugere a alteração de um parâmetro para permitir que isso seja feito:

SQL> alter session set container=PDB$SEED;
 
Session altered.
 
SQL> alter session set "_oracle_script"=TRUE;
 
Session altered.
 
SQL> alter pluggable database pdb$seed close immediate instances=all;
 
Pluggable database altered.
 
SQL> alter pluggable database pdb$seed OPEN READ WRITE;
 
Pluggable database altered.
 
SQL> select open_mode from v$database;
 
OPEN_MODE
--------------------
READ WRITE

Aplicando o datapatch, porém é reportado uma mensagem de erro:

[oracle@quiasma admin]$ cd $ORACLE_HOME/OPatch
[oracle@quiasma OPatch]$ ./datapatch -verbose -pdbs PDB\$SEED
SQL Patching tool version 18.0.0.0.0 Production on Tue Mar 30 04:33:06 2021
Copyright (c) 2012, 2020, Oracle.  All rights reserved.
 
Log file for this invocation: /oracle/18.0.0/base/cfgtoollogs/sqlpatch/sqlpatch_16615_2021_03_30_04_33_06/sqlpatch_invocation.log
 
Connecting to database...OK
Gathering database info...done
 
Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)
 
Bootstrapping registry and package to current versions...
Error: prereq checks failed!
CDB$ROOT is not in the PDBs to be processed but needs to be bootstrapped
Prereq check failed, exiting without installing any patches.
 
Please refer to MOS Note 1609718.1 and/or the invocation log
/oracle/18.0.0/base/cfgtoollogs/sqlpatch/sqlpatch_16615_2021_03_30_04_33_06/sqlpatch_invocation.log
for information on how to resolve the above errors.
 
SQL Patching tool complete on Tue Mar 30 04:33:07 2021

Segundo o Oracle Note “datapatch execution for PDB results in Error- CDB$ROOT is not in the PDBs to be processed but needs to be bootstrapped (Doc ID 2538591.1)“, devemos aplicar o datapatch primeiramente no CDB$ROOT (apesar de eu já ter feito isso em outra oportunidade), para só então aplicar em algum PDB. Realizando o processo no root:

[oracle@quiasma OPatch]$ cd $ORACLE_HOME/OPatch
[oracle@quiasma OPatch]$ ./datapatch -verbose -pdbs CDB\$ROOT
SQL Patching tool version 18.0.0.0.0 Production on Tue Mar 30 04:39:13 2021
Copyright (c) 2012, 2020, Oracle.  All rights reserved.
 
Log file for this invocation: /oracle/18.0.0/base/cfgtoollogs/sqlpatch/sqlpatch_17834_2021_03_30_04_39_13/sqlpatch_invocation.log
 
Connecting to database...OK
Gathering database info...done
 
Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)
 
Bootstrapping registry and package to current versions...done
Determining current state...done
 
Current state of interim SQL patches:
Interim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):
  Binary registry: Installed
  PDB CDB$ROOT: Applied successfully on 02-MAR-21 06.35.31.589073 AM
 
Current state of release update SQL patches:
  Binary registry:
    18.13.0.0.0 Release_Update 2012231849: Installed
  PDB CDB$ROOT:
    Applied 18.3.0.0.0 Release_Update 1806280943 successfully on 02-MAR-21 06.35.31.581343 AM
 
Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT
    No interim patches need to be rolled back
    Patch 32204699 (Database Release Update : 18.13.0.0.210119 (32204699)):
      Apply from 18.3.0.0.0 Release_Update 1806280943 to 18.13.0.0.0 Release_Update 2012231849
    No interim patches need to be applied
 
Installing patches...
Patch installation complete.  Total patches installed: 1
 
Validating logfiles...done
Patch 32204699 apply (pdb CDB$ROOT): SUCCESS
  logfile: /oracle/18.0.0/base/cfgtoollogs/sqlpatch/32204699/24011084/32204699_apply_TALAMO_CDBROOT_2021Mar30_04_39_36.log (no errors)
SQL Patching tool complete on Tue Mar 30 04:43:38 2021

Aplicando no PDB$SEED:

[oracle@quiasma OPatch]$ cd $ORACLE_HOME/OPatch
[oracle@quiasma OPatch]$ ./datapatch -verbose -pdbs PDB\$SEED
SQL Patching tool version 18.0.0.0.0 Production on Tue Mar 30 04:44:34 2021
Copyright (c) 2012, 2020, Oracle.  All rights reserved.
 
Log file for this invocation: /oracle/18.0.0/base/cfgtoollogs/sqlpatch/sqlpatch_19337_2021_03_30_04_44_34/sqlpatch_invocation.log
 
Connecting to database...OK
Gathering database info...done
 
Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)
 
Bootstrapping registry and package to current versions...done
Determining current state...done
 
Current state of interim SQL patches:
Interim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):
  Binary registry: Installed
  PDB PDB$SEED: Applied successfully on 02-MAR-21 06.44.54.948445 AM
 
Current state of release update SQL patches:
  Binary registry:
    18.13.0.0.0 Release_Update 2012231849: Installed
  PDB PDB$SEED:
    Applied 18.3.0.0.0 Release_Update 1806280943 successfully on 02-MAR-21 06.44.54.938616 AM
 
Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: PDB$SEED
    No interim patches need to be rolled back
    Patch 32204699 (Database Release Update : 18.13.0.0.210119 (32204699)):
      Apply from 18.3.0.0.0 Release_Update 1806280943 to 18.13.0.0.0 Release_Update 2012231849
    No interim patches need to be applied
 
Installing patches...
Patch installation complete.  Total patches installed: 1
 
Validating logfiles...done
Patch 32204699 apply (pdb PDB$SEED): SUCCESS
  logfile: /oracle/18.0.0/base/cfgtoollogs/sqlpatch/32204699/24011084/32204699_apply_TALAMO_PDBSEED_2021Mar30_04_45_07.log (no errors)
SQL Patching tool complete on Tue Mar 30 04:49:19 2021

Alterando parâmetro e alterando o mode do seed para somente leitura:

[oracle@quiasma OPatch]$ sqlplus / as sysdba
 
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Mar 30 04:50:22 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.13.0.0.0
 
SQL> alter session set container=PDB$SEED;
 
Session altered.
 
SQL> alter session set "_oracle_script"=FALSE;
 
Session altered.
 
SQL> show pdbs
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ WRITE NO
SQL> set linesize 150
SQL> col logfile for a90
SQL> select patch_id, action, logfile, status from registry$sqlpatch;
 
  PATCH_ID ACTION          LOGFILE                                                                          STATUS
---------- --------------- ------------------------------------------------------------------------------------------ -------------------------
  28090523 APPLY           /oracle/18.0.0/base/cfgtoollogs/sqlpatch/28090523/22329768/28090523_apply_TALAMO_PDBSEED_2 SUCCESS
                           021Mar02_06_42_50.log
 
  27923415 APPLY           /oracle/18.0.0/base/cfgtoollogs/sqlpatch/27923415/22239273/27923415_apply_TALAMO_PDBSEED_2 SUCCESS
                           021Mar02_06_44_28.log
 
  32204699 APPLY           /oracle/18.0.0/base/cfgtoollogs/sqlpatch/32204699/24011084/32204699_apply_TALAMO_PDBSEED_2 SUCCESS
                           021Mar30_04_45_07.log
 
 
SQL> alter pluggable database pdb$seed close immediate instances=all;
 
Pluggable database altered.
 
SQL> alter pluggable database pdb$seed OPEN READ ONLY;
 
Pluggable database altered.
 
SQL> SELECT NAME,OPEN_MODE FROM V$PDBS WHERE NAME LIKE '%SEED%';
 
NAME                                                                                                   OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                               READ ONLY

Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.

Leave a Comment

Your email address will not be published.