Creation d'une CDB avec DBCA et un sous-ensemble d'options

Par défaut, la création d’une CDB avec DBCA ne permet pas de désactiver l’installation de certains composants.
La note « Creating A Container Database (CDB) With A Subset Of Options (Doc ID 2001512.1) » propose un contournement qui implique d’exécuter DBCA en mode graphique pour générer les scripts et de modifier ensuite ces scripts (avec la mise en commentaire de certains scripts SQL associés) avant de les lancer.
Il est possible d’utiliser une autre méthode (non officielle) avec DBCA en mode silencieux.

Par défaut, si on ne fait rien, tous ces composants sont installés :

SET LINES 200 PAGES 200
col COMP_NAME for a10
col COMP_NAME for a40
col VERSION for A15
SELECT comp_id, comp_name, version, status FROM dba_registry ORDER BY comp_id;
COMP_ID       COMP_NAME                            VERSION     STATUS
------------- ------------------------------------ ----------- --------
DV            Oracle Database Vault                12.1.0.2.0  VALID
RAC           Oracle Real Application Clusters     12.1.0.2.0  VALID
SDO           Spatial                              12.1.0.2.0  VALID
ORDIM         Oracle Multimedia                    12.1.0.2.0  VALID
CONTEXT       Oracle Text                          12.1.0.2.0  VALID
OWM           Oracle Workspace Manager             12.1.0.2.0  VALID
XDB           Oracle XML Database                  12.1.0.2.0  VALID
CATALOG       Oracle Database Catalog Views        12.1.0.2.0  VALID
CATPROC       Oracle Database Packages and Types   12.1.0.2.0  VALID
JAVAVM        JServer JAVA Virtual Machine         12.1.0.2.0  VALID
XML           Oracle XDK                           12.1.0.2.0  VALID
CATJAVA       Oracle Database Java Packages        12.1.0.2.0  VALID
APS           OLAP Analytic Workspace              12.1.0.2.0  VALID
XOQ           Oracle OLAP API                      12.1.0.2.0  VALID
OLS           Oracle Label Security                12.1.0.2.0  VALID

Extrait de la note 2001512.1 :
« One workaround is to use the DataBase Configuration Assistant (dbca) to generate the database creation scripts and then remove the references for the options that are not to be installed. »
La mise en commmentaire dans le script permet de ne pas réaliser l’installation des options correspondantes au moment de l’exécution :

$ cat cdb1.sql
set verify off
ACCEPT sysPassword CHAR PROMPT 'Enter new password for SYS: ' HIDE
ACCEPT systemPassword CHAR PROMPT 'Enter new password for SYSTEM: ' HIDE
host /scratch/dbuser/app/oracle/product/12.1.0.2/dbhome_1/bin/orapwd file=/scratch/dbuser/app/oracle/product/12.1.0.2/dbhome_1/dbs/orapwcdb1 force=y format=12
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/CreateDB.sql
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/CreateDBFiles.sql
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/CreateDBCatalog.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/JServer.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/context.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/ordinst.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/interMedia.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/cwmlite.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/spatial.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/labelSecurity.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/apex.sql
-- @/scratch/dbuser/app/oracle/admin/cdb11/scripts/datavault.sql
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/CreateClustDBViews.sql
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/lockAccount.sql
@/scratch/dbuser/app/oracle/admin/cdb1/scripts/postDBCreation.sql

Une autre solution est de modifier le script PERL ${ORACLE_HOME}/rdbms/admin/catcon.pl.
Ce programme est utilisé pour lancer les scripts associés aux composants.
Si on regarde le répertoire des scripts générés, on constate que le paramètre « -b » permet d’identifier l’option associée :

[oracle ~]$ grep catcon scripts/* | cut -d " " -f 8-1 8- , 8-8-
scripts/apex.sql:host -b catapx -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/apex/catapx.sql 1change_on_install 1SYSAUX 1SYSAUX 1TEMP 1/i/ 1NONE;
scripts/context.sql:host -b catctx -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/ctx/admin/catctx.sql 1change_on_install 1SYSAUX 1TEMP 1LOCK;
scripts/context.sql:host -b dr0defin -u CTXSYS/CTXSYS -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/ctx/admin/defaults/dr0defin.sql 1\"AMERICAN\";
scripts/context.sql:host -b dbmsxdbt /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/dbmsxdbt.sql;
scripts/CreateClustDBViews.sql:host -b catclust /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catclust.sql;
scripts/CreateDBCatalog.sql:host -b catalog /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catalog.sql;
scripts/CreateDBCatalog.sql:host -b catproc /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catproc.sql;
scripts/CreateDBCatalog.sql:host -b catoctk /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catoctk.sql;
scripts/CreateDBCatalog.sql:host -b owminst /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/owminst.plb;
scripts/CreateDBCatalog.sql:host -b pupbld -u SYSTEM/&&systemPassword /u01/app/oracle/product/12.1.0.2/dbhome_1/sqlplus/admin/pupbld.sql;
scripts/CreateDBCatalog.sql:host -b hlpbld -u SYSTEM/&&systemPassword -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/sqlplus/admin/help/hlpbld.sql 1helpus.sql;
scripts/cwmlite.sql:host -b olap -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/olap/admin/olap.sql 1SYSAUX 1TEMP;
scripts/datavault.sql:host -b catmac -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catmac.sql 1SYSAUX 1TEMP 1&&sysPassword;
scripts/interMedia.sql:host -b iminst /u01/app/oracle/product/12.1.0.2/dbhome_1/ord/im/admin/iminst.sql;
scripts/JServer.sql:host -b initjvm /u01/app/oracle/product/12.1.0.2/dbhome_1/javavm/install/initjvm.sql;
scripts/JServer.sql:host -b initxml /u01/app/oracle/product/12.1.0.2/dbhome_1/xdk/admin/initxml.sql;
scripts/JServer.sql:host -b xmlja /u01/app/oracle/product/12.1.0.2/dbhome_1/xdk/admin/xmlja.sql;
scripts/JServer.sql:host -b catjava /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catjava.sql;
scripts/JServer.sql:host -b catxdbj /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catxdbj.sql;
scripts/labelSecurity.sql:host -b catols /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catols.sql;
scripts/ordinst.sql:host -b ordinst -a 1  /u01/app/oracle/product/12.1.0.2/dbhome_1/ord/admin/ordinst.sql 1SYSAUX 1SYSAUX;
scripts/postDBCreation.sql:host -b catbundleapply /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catbundleapply.sql;
scripts/postDBCreation.sql:host -b utlrp /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/utlrp.sql;
scripts/spatial.sql:host -b mdinst /u01/app/oracle/product/12.1.0.2/dbhome_1/md/admin/mdinst.sql;

Il suffit donc de modifier temporairement le script PERL en ajoutant un test pour la présence des options non souhaitées et une sortie directe dans ce cas.
La modification se fait après la ligne die « At least one file name must be supplied » if !@ARGV;) :

[oracle ~]$ cp -p /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl.noopt
[oracle ~]$ cp -p /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl.ori
[oracle ~]$ vi /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl.noopt
# some things must have been specified:
# - base for log file names
# - at least one sqlplus script
die "Base for log file names must be supplied" if !$opt_b;
die "At least one file name must be supplied" if !@ARGV;
##### MODIFIER POUR NE PAS INSTALLER LES COMPOSTANTS
if ( $opt_b ~~ ['catapx'] ) {
   print "***** Do no install APEX *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['catctx', 'dr0defin', 'dbmsxdbt'] ) {
   print "***** Do no install CONTEXT *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['owminst'] ) {
   print "***** Do no install WORKSPACE MANAGER *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['olap'] ) {
   print "***** Do no install OLAP *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['catmac'] ) {
   print "***** Do no install DB VAULT *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['iminst'] ) {
   print "***** Do no install INTERMEDIA *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['initjvm', 'initxml', 'xmlja', 'catjava', 'catxdbj'] ) {
   print "***** Do no install JSERVER *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['catols'] ) {
   print "***** Do no install LABEL SECURITY *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['ordinst'] ) {
   print "***** Do no install MULTIMEDIA *****; exiting\n";
   exit 0
}
if ( $opt_b ~~ ['mdinst'] ) {
   print "***** Do no install SPATIAL *****; exiting\n";
   exit 0
}
####################################################
[oracle ~]$ cp -p /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl.noopt /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl

Exécution de la création du CDB en mode silencieux sans les options indésirables :

[oracle ~]$ dbca \
    -silent \
    -createDatabase \
    -templateName modeleORCL.dbt \
    -gdbName CDBORCL \
    -databaseConfType RAC \
    -sid CDBORCL \
    -createAsContainerDatabase true -numberOfPDBs 0 \
    -sysPassword password \
    -systemPassword password \
    -emConfiguration NONE \
    -dvConfiguration FALSE \
    -storageType ASM \
    -nodelist node1,node2
Creating and starting Oracle instance
1% complete
3% complete
Creating database files
4% complete
7% complete
Creating data dictionary views
8% complete
10% complete
13% complete
14% complete
15% complete
16% complete
18% complete
Adding Oracle JVM
24% complete
29% complete
35% complete
37% complete
Adding Oracle Text
39% complete
40% complete
Adding Oracle Multimedia
41% complete
51% complete
Adding Oracle Spatial
52% complete
59% complete
Adding Oracle Label Security
66% complete
Adding Oracle Application Express
70% complete
74% complete
Adding Oracle Database Vault
81% complete
Creating cluster database views
82% complete
88% complete
Completing Database Creation
90% complete
91% complete
94% complete
97% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/CDBORCL.log" for further details.

La sortie standard affiche les options comme si elles étaient installées mais les opérations sont en fait ignorées, ce qui est visible dans le fichier journal :

[oracle ~]$ grep "***** Do no install" /u01/app/oracle/cfgtoollogs/dbca/CDBORCL/*.log | grep -v trace.log
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/apex.log:**** Do no install APEX *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/context.log:***** Do no install CONTEXT *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/context.log:***** Do no install CONTEXT *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/context.log:***** Do no install CONTEXT *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/CreateDBCatalog.log:***** Do no install WORKSPACE MANAGER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/datavault.log:***** Do no install DB VAULT *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/interMedia.log:***** Do no install INTERMEDIA *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/JServer.log:***** Do no install JSERVER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/JServer.log:***** Do no install JSERVER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/JServer.log:***** Do no install JSERVER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/JServer.log:***** Do no install JSERVER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/JServer.log:***** Do no install JSERVER *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/labelSecurity.log:***** Do no install LABEL SECURITY *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/ordinst.log:***** Do no install MULTIMEDIA *****; exiting
/u01/app/oracle/cfgtoollogs/dbca/CDBORCL/spatial.log:***** Do no install SPATIAL *****; exiting

Et confirmé après la création dans la vue CDB_REGISTRY:

SELECT comp_id, comp_name, version, status FROM cdb_registry ORDER BY con_id;
COMP_ID      COMP_NAME                            VERSION      STATUS
------------ ------------------------------------ ------------ -----------
XDB          Oracle XML Database                  12.1.0.2.0   VALID
RAC          Oracle Real Application Clusters     12.1.0.2.0   VALID
CATPROC      Oracle Database Packages and Types   12.1.0.2.0   VALID
CATALOG      Oracle Database Catalog Views        12.1.0.2.0   VALID

Pour annuler la modification :

[oracle ~]$ cp -p /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl.ori /u01/app/oracle/product/12.1.0.2/dbhome_1/rdbms/admin/catcon.pl

Remarques :
– Oracle XML Database est un composant obligatoire en 12c.
– Cette opération permet de réduire notablement le temps de création d’une CDB.
– Ne pas installer JServer JAVA Virtual Machine permet de pas avoir à installer le patch OJVM (no rolling / no standby first).
– Ne pas installer APEX sur la CDB permet d’avoir plusieurs versions différentes d’APEX sur les PDB.