Today I’ve encountered an annoying issue while adapting a few scripts for automatic database creation. I track it here so hopefully it may save a few hours of troubleshooting to someone…
I’ve used the DBCA to prepare a new template:
1 2 |
dbca -> Create Database -> Advanced Mode -> General Purpose -> Create As Container Database -> Create an Empty Container Database |
Then continued by customizing other options, including init parameters and datafile/logfile paths. Finally, I’ve saved it as a new template instead of creating the database.
I’ve checked the resulting .dbc and seen that there was, as expected, the parameter “enable_pluggable_database”=”true”.
Then I’ve moved the template file to my $HOME directory and tested the silent database creation with the option “-createAsContainerDatabase true”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ ${ORACLE_HOME}/bin/dbca -silent \ -createDatabase \ -createAsContainerDatabase true \ -templateName /home/oracle/Template_12_EE_MULTITENANT.dbc \ -gdbname cdb1 \ -sid cdb1 \ -responseFile NO_VALUE \ -characterSet AL32UTF8 \ -SYSPASSWORD *** \ -SYSTEMPASSWORD *** \ -redoLogFileSize 256 \ -initparams open_cursors=1300 \ -initparams processes=3000 \ -initparams enable_pluggable_database=true |
The database configuration has completed successfully, without errors. I’ve accessed my new container, and I’ve been surprised by seing:
1 2 3 4 5 |
SQL> select * from v$pdbs; no rows selected SQL> |
In fact, there were no pdb$seed datafiles:
1 2 3 4 5 6 7 |
SQL> select distinct con_id from cdb_data_files; CON_ID ---------- 1 SQL> |
After little investigation, I’ve found these lines in the dbca trace.log:
1 2 3 4 5 |
[main] [ 2014-03-28 10:37:53.956 CET ] [Host.startOperation:2651] is Template CDB false [main] [ 2014-03-28 10:37:53.956 CET ] [TemplateManager.isInstallTemplate:2314] Selected Template by user:=Template CEI 8K 12 EE MULTITENANT [main] [ 2014-03-28 10:37:53.956 CET ] [TemplateManager.isInstallTemplate:2321] The Message Id to be searched:=null [main] [ 2014-03-28 10:37:53.957 CET ] [Host.startOperation:2663] Template Selected is User created NON-CDB Template. Creating database as NON-CDB [main] [ 2014-03-28 10:37:53.957 CET ] [HAUtils.getCurrentOracleHome:490] Oracle home from system property: /ccv/app/oracle/product/12.1.0.1 |
Then I’ve struggled with dbca and templates a few times before finding that, actually, the magic “enable pluggable database” is done by dbca only if the template file name is not customized.
Running the same exact command with the very same template file but renamed to $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc actually works (notice the diff at the first line):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ diff /home/oracle/Template_12_EE_MULTITENANT.dbc $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc $ ${ORACLE_HOME}/bin/dbca -silent \ -createDatabase \ -createAsContainerDatabase true \ -templateName General_Purpose.dbc \ -gdbname cdb1 \ -sid cdb1 \ -responseFile NO_VALUE \ -characterSet AL32UTF8 \ -SYSPASSWORD *** \ -SYSTEMPASSWORD *** \ -redoLogFileSize 256 \ -initparams open_cursors=1300 \ -initparams processes=3000 \ -initparams enable_pluggable_database=true |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
SQL> select * from v$pdbs; CON_ID DBID CON_UID GUID ---------- ---------- ---------- -------------------------------- NAME OPEN_MODE RES ------------------------------ ---------- --- OPEN_TIME --------------------------------------------------------------------------- CREATE_SCN TOTAL_SIZE ---------- ---------- 2 4086042395 4086042395 F5A8226121F93B96E0434B96780A8C91 PDB$SEED READ ONLY NO 28-MAR-14 10.20.42.813 AM 1720341 283115520 SQL> select distinct con_id from cdb_data_files; CON_ID ---------- 2 1 SQL> |
I’ve also tried to cheat and use a symlink to my previous custom template, and surprisingly, it still works:
1 2 3 |
$ ls -l $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc lrwxrwxrwx 1 oracle dba 74 Mar 28 13:07 /u01/app/oracle/product/12.1.0.1/assistants/dbca/templates/General_Purpose.dbc -> /home/oracle/Template_12_EE_MULTITENANT.dbc $ |
In the dbca trace log the message saying that the DB will be NON-CDB disappears:
1 2 3 4 |
[main] [ 2014-03-28 10:12:14.683 CET ] [Host.startOperation:2651] is Template CDB false [main] [ 2014-03-28 10:12:14.683 CET ] [TemplateManager.isInstallTemplate:2314] Selected Template by user:=General Purpose [main] [ 2014-03-28 10:12:14.683 CET ] [TemplateManager.isInstallTemplate:2321] The Message Id to be searched:=GENERAL_PURPOSE [main] [ 2014-03-28 10:12:14.683 CET ] [HAUtils.getCurrentOracleHome:490] Oracle home from system property: /ccv/app/oracle/product/12.1.0.1 |
So the problem is really caused by the different filename/location of the template.
IMHO it’s a kind of bug, the decision between a CDB and NON-CDB should not be taken by DBCA. Moreover, it’s not based on the content of the template, which would be logic. But today I’m late and lazy, I will not open a SR for this.
:-/