{"id":607,"date":"2014-03-28T14:33:16","date_gmt":"2014-03-28T12:33:16","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=607"},"modified":"2020-08-18T16:43:43","modified_gmt":"2020-08-18T14:43:43","slug":"multitenant-and-custom-dbca-templates","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/multitenant-and-custom-dbca-templates\/","title":{"rendered":"Oracle Multitenant and custom DBCA templates"},"content":{"rendered":"<p>Today I&#8217;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&#8230;<\/p>\n<p>I&#8217;ve used the DBCA to prepare a new template:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">dbca -&gt; Create Database -&gt; Advanced Mode -&gt; General Purpose -&gt; \r\nCreate As Container Database -&gt; Create an Empty Container Database<\/pre>\n<p>&nbsp;<\/p>\n<p>Then continued by customizing other options, including init parameters and datafile\/logfile paths. Finally, I&#8217;ve saved it as a new template instead of creating the database.<\/p>\n<p>I&#8217;ve checked the resulting .dbc and seen that there was, as expected, the parameter &#8220;enable_pluggable_database&#8221;=&#8221;true&#8221;.<\/p>\n<p>Then I&#8217;ve moved the template file to my $HOME directory and tested the silent database creation with the option &#8220;-createAsContainerDatabase true&#8221;:<\/p>\n<pre class=\"lang:default decode:true\">$ ${ORACLE_HOME}\/bin\/dbca -silent \\\r\n-createDatabase \\\r\n-createAsContainerDatabase true  \\\r\n-templateName \/home\/oracle\/Template_12_EE_MULTITENANT.dbc \\\r\n-gdbname cdb1 \\\r\n-sid cdb1 \\\r\n-responseFile NO_VALUE \\\r\n-characterSet AL32UTF8 \\\r\n-SYSPASSWORD *** \\\r\n-SYSTEMPASSWORD *** \\\r\n-redoLogFileSize 256 \\\r\n-initparams open_cursors=1300 \\\r\n-initparams processes=3000 \\\r\n-initparams enable_pluggable_database=true<\/pre>\n<p>The database configuration has completed successfully, without errors. I&#8217;ve accessed my new container, and I&#8217;ve been surprised by seing:<\/p>\n<pre class=\"lang:plsql decode:true\">SQL&gt; select * from v$pdbs;\r\n\r\nno rows selected\r\n\r\nSQL&gt;<\/pre>\n<p>In fact, there were no pdb$seed datafiles:<\/p>\n<pre class=\"lang:plsql decode:true\">SQL&gt; select distinct con_id from cdb_data_files;\r\n\r\n    CON_ID\r\n----------\r\n         1\r\n\r\nSQL&gt;<\/pre>\n<p>After little investigation, I&#8217;ve found these lines in the dbca trace.log:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">[main] [ 2014-03-28 10:37:53.956 CET ] [Host.startOperation:2651]  is Template CDB false\r\n[main] [ 2014-03-28 10:37:53.956 CET ] [TemplateManager.isInstallTemplate:2314]  Selected Template by user:=Template CEI 8K 12 EE MULTITENANT\r\n[main] [ 2014-03-28 10:37:53.956 CET ] [TemplateManager.isInstallTemplate:2321]  The Message Id to be searched:=null\r\n[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\r\n[main] [ 2014-03-28 10:37:53.957 CET ] [HAUtils.getCurrentOracleHome:490]\u00a0 Oracle home from system property: \/ccv\/app\/oracle\/product\/12.1.0.1<\/pre>\n<p>&nbsp;<\/p>\n<p>Then I&#8217;ve struggled with dbca and templates a few times before finding that, actually, the magic &#8220;enable pluggable database&#8221; is done by dbca only if the template file name is not customized.<\/p>\n<p>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):<\/p>\n<pre class=\"lang:plsql decode:true\">$ diff \/home\/oracle\/Template_12_EE_MULTITENANT.dbc $ORACLE_HOME\/assistants\/dbca\/templates\/General_Purpose.dbc\r\n$ ${ORACLE_HOME}\/bin\/dbca -silent \\\r\n-createDatabase \\\r\n-createAsContainerDatabase true  \\\r\n-templateName General_Purpose.dbc \\\r\n-gdbname cdb1 \\\r\n-sid cdb1 \\\r\n-responseFile NO_VALUE \\\r\n-characterSet AL32UTF8 \\\r\n-SYSPASSWORD *** \\\r\n-SYSTEMPASSWORD *** \\\r\n-redoLogFileSize 256 \\\r\n-initparams open_cursors=1300 \\\r\n-initparams processes=3000 \\\r\n-initparams enable_pluggable_database=true<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"lang:plsql decode:true\">SQL&gt; select * from v$pdbs;\r\n\r\n    CON_ID       DBID    CON_UID GUID\r\n---------- ---------- ---------- --------------------------------\r\nNAME                           OPEN_MODE  RES\r\n------------------------------ ---------- ---\r\nOPEN_TIME\r\n---------------------------------------------------------------------------\r\nCREATE_SCN TOTAL_SIZE\r\n---------- ----------\r\n         2 4086042395 4086042395 F5A8226121F93B96E0434B96780A8C91\r\nPDB$SEED                       READ ONLY  NO\r\n28-MAR-14 10.20.42.813 AM\r\n   1720341  283115520\r\n\r\nSQL&gt; select distinct con_id from cdb_data_files;\r\n\r\n    CON_ID\r\n----------\r\n         2\r\n         1\r\n\r\nSQL&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>I&#8217;ve also tried to cheat and use a symlink to my previous custom template, and surprisingly, it still works:<\/p>\n<pre class=\"lang:plsql decode:true\">$ ls -l $ORACLE_HOME\/assistants\/dbca\/templates\/General_Purpose.dbc\r\nlrwxrwxrwx 1 oracle dba 74 Mar 28 13:07 \/u01\/app\/oracle\/product\/12.1.0.1\/assistants\/dbca\/templates\/General_Purpose.dbc -&gt; \/home\/oracle\/Template_12_EE_MULTITENANT.dbc\r\n$<\/pre>\n<p>In the dbca trace log the message saying that the DB will be NON-CDB disappears:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">[main] [ 2014-03-28 10:12:14.683 CET ] [Host.startOperation:2651]  is Template CDB false\r\n[main] [ 2014-03-28 10:12:14.683 CET ] [TemplateManager.isInstallTemplate:2314]  Selected Template by user:=General Purpose\r\n[main] [ 2014-03-28 10:12:14.683 CET ] [TemplateManager.isInstallTemplate:2321]  The Message Id to be searched:=GENERAL_PURPOSE\r\n[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<\/pre>\n<p>So the problem is really caused by the different filename\/location of the template.<\/p>\n<p>IMHO it&#8217;s a kind of bug, the decision between a CDB and NON-CDB should not be taken by DBCA.\u00a0 Moreover, it&#8217;s not based on the content of the template, which would be logic. But today I&#8217;m late and lazy, I will not open a SR for this.<\/p>\n<p>:-\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I&#8217;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&#8230; I&#8217;ve used the DBCA to prepare a new template: &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/multitenant-and-custom-dbca-templates\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[326,3,52,328,330,132],"tags":[154,290,156,289,155,153,58,157],"class_list":["post-607","post","type-post","status-publish","format-standard","hentry","category-oracle","category-oracledb","category-12c","category-oracle-mt","category-oracle-inst-upg","category-triblog","tag-cdb","tag-db12c","tag-dbca","tag-multitenant","tag-non-cdb","tag-pdbseed","tag-silent","tag-template"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=607"}],"version-history":[{"count":8,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/607\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/607\/revisions\/615"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}