{"id":2961,"date":"2019-10-06T16:30:45","date_gmt":"2019-10-06T16:30:45","guid":{"rendered":"https:\/\/nenadnoveljic.com\/blog\/?p=2961"},"modified":"2019-10-06T16:30:47","modified_gmt":"2019-10-06T16:30:47","slug":"automating-multi-tenant-container-database-creation","status":"publish","type":"post","link":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/","title":{"rendered":"Automating Multi-Tenant Container Database Creation"},"content":{"rendered":"<p>There are two ways of <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/18\/multi\/creating-and-configuring-a-cdb.html#GUID-77D4BBA7-2A64-46D9-A2B8-C56060772215\">creating multi-tenant container databases (CDB)<\/a>: Database Configuration Assistant and scripts. With the latter you have to run the script catcdb.sql for building data dictionary. This script calls a cascade of other Perl and sqlplus scripts, which are primarily intended for interactive use. Simply put, the aforementioned scipt catcdb.sql is just a wrapper for the Perl program catcdb.pl:<\/p>\n<pre><code>host perl -I &amp;&amp;rdbms_admin &amp;&amp;rdbms_admin_catcdb --logDirectory &amp;&amp;1 --logFilename &amp;&amp;2<\/code><\/pre>\n<p>As you can see, you can supply a log directory and a log file on the command line to avoid the interaction.<\/p>\n<p>Also, notice that the perl executable isn&#8217;t referenced with the absolute path. Consequently, depending on your PATH variable, some arbitrary Perl installation might be picked up. Below is the typical error message when this happens:<\/p>\n<pre><code>Can't locate Term\/ReadKey.pm in @INC (you may need to install the Term::ReadKey module) (@INC contains: \/u00\/oracle\/orabase\/product\/18.7.0.0.190716_a\/rdbms\/admin \/usr\/perl5\/site_perl\/5.22\/i86pc-solaris-thread-multi-64 \/usr\/perl5\/site_perl\/5.22 \/usr\/perl5\/vendor_perl\/5.22\/i86pc-solaris-thread-multi-64 \/usr\/perl5\/vendor_perl\/5.22 \/usr\/perl5\/5.22\/lib\/i86pc-solaris-thread-multi-64 \/usr\/perl5\/5.22\/lib) at \/u00\/oracle\/orabase\/product\/18.7.0.0.190716_a\/rdbms\/admin\/catcdb.pl line 38.\nBEGIN failed--compilation aborted at \/u00\/oracle\/orabase\/product\/18.7.0.0.190716_a\/rdbms\/admin\/catcdb.pl line 38.)<\/code><\/pre>\n<p>Therefore, it&#8217;s necessary to include Perl delivered with the Oracle home in your PATH: $ORACLE_HOME\/perl\/bin and unset PERL5LIB, too.<\/p>\n<p>Moreover, catcdb.pl will be calling other Perl scripts (catcon.pl) which, in turn, will be invoking some sqlplus scripts, alas, again without the absolute path, so you have to add $ORACLE_HOME\/bin to the PATH as well. By the way, catcon.pl was introduced &#8211; among others, to handle SQL scripts execution in multi-tenant environments.<\/p>\n<p>Normally, a Perl program acts as a wrapper for sqlplus, not the other way around. Strangely, the sole purpose of the catcdb.sql wrapping code is to query the Oracle home from the database, even though a Perl program could do that much more efficiently &#8211; by simply reading the environment variable $ENV{ORACLE_HOME}. A shortcoming is that sqlplus won&#8217;t signal any errors if the Perl script fails.<\/p>\n<p>So, parse the sqlplus output for Perl fatal errors, such as the one below:<\/p>\n<pre><code>open2: exec of sqlplus \/nolog failed at \/u00\/oracle\/orabase\/product\/18.7.0.0.190716_a\/rdbms\/admin\/catcon.pm line 996.<\/code><\/pre>\n<p>In particular, the key word to search for is: &#8216;failed&#8217;.<\/p>\n<p>Further, set the following environment variables: CATCDB_SYS_PASSWD, CATCDB_SYSTEM_PASSWD and CATCDB_TEMPTS to avoid prompting. That&#8217;s not documented &#8211; I figured it out by analyzing catcdb.pl.<\/p>\n<p>Last but not least, catcdb.sql installs Oracle Workspace Manager, which, according to <a href=\"https:\/\/mikedietrichde.com\/2017\/07\/28\/oracle-workspace-manager-owm-clean-oracle-database-11-2-12-2\/\">Mike Dietrich<\/a>, can be safely removed:<\/p>\n<pre><code>$ORACLE_HOME\/perl\/bin\/perl $ORACLE_HOME\/rdbms\/admin\/catcon.pl -\u2013reverse -n 1 -l \/logdir -b uninstall_owm $ORACLE_HOME\/rdbms\/admin\/owmuinst.plb<\/code><\/pre>\n<p>In summary, do the following when automating the data dictionary creation with scripts:<\/p>\n<ul>\n<li>supply arguments to catcdb.sql: catcdb.sql log_directory log_file<\/li>\n<li>PATH=$ORACLE_HOME\/perl\/bin:$ORACLE_HOME\/bin<\/li>\n<li>unset PERL5LIB<\/li>\n<li>set CATCDB_SYS_PASSWD, CATCDB_SYSTEM_PASSWD and CATCDB_TEMPTS<\/li>\n<li>parse catcdb.sql output for &#8216;failed&#8217;<\/li>\n<li>uninstall Oracle Workspace manager if you don&#8217;t use it<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>There are two ways of creating multi-tenant container databases (CDB): Database Configuration Assistant and scripts. With the latter you have to run the script catcdb.sql for building data dictionary. This script calls a cascade of other Perl and sqlplus scripts,&hellip; <a href=\"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/\" class=\"more-link\">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":{"inline_featured_image":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2961","post","type-post","status-publish","format-standard","hentry","category-oracle"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Automating Multi-Tenant Container Database Creation - All-round Database Topics<\/title>\n<meta name=\"description\" content=\"A check list for automating catcdb.sql execution\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Automating Multi-Tenant Container Database Creation - All-round Database Topics\" \/>\n<meta property=\"og:description\" content=\"A check list for automating catcdb.sql execution\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/\" \/>\n<meta property=\"og:site_name\" content=\"All-round Database Topics\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-06T16:30:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-06T16:30:47+00:00\" \/>\n<meta name=\"author\" content=\"Nenad Noveljic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NenadNoveljic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nenad Noveljic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/\"},\"author\":{\"name\":\"Nenad Noveljic\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"headline\":\"Automating Multi-Tenant Container Database Creation\",\"datePublished\":\"2019-10-06T16:30:45+00:00\",\"dateModified\":\"2019-10-06T16:30:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/\"},\"wordCount\":414,\"commentCount\":0,\"articleSection\":[\"Oracle\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/\",\"name\":\"Automating Multi-Tenant Container Database Creation - All-round Database Topics\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\"},\"datePublished\":\"2019-10-06T16:30:45+00:00\",\"dateModified\":\"2019-10-06T16:30:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"description\":\"A check list for automating catcdb.sql execution\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/automating-multi-tenant-container-database-creation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automating Multi-Tenant Container Database Creation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\",\"name\":\"All-round Database Topics\",\"description\":\"Nenad Noveljic\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\",\"name\":\"Nenad Noveljic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"caption\":\"Nenad Noveljic\"},\"sameAs\":[\"nenad-noveljic-9b746a6\",\"https:\\\/\\\/x.com\\\/NenadNoveljic\"],\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/author\\\/nenad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Automating Multi-Tenant Container Database Creation - All-round Database Topics","description":"A check list for automating catcdb.sql execution","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/","og_locale":"en_US","og_type":"article","og_title":"Automating Multi-Tenant Container Database Creation - All-round Database Topics","og_description":"A check list for automating catcdb.sql execution","og_url":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/","og_site_name":"All-round Database Topics","article_published_time":"2019-10-06T16:30:45+00:00","article_modified_time":"2019-10-06T16:30:47+00:00","author":"Nenad Noveljic","twitter_card":"summary_large_image","twitter_creator":"@NenadNoveljic","twitter_misc":{"Written by":"Nenad Noveljic","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/#article","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/"},"author":{"name":"Nenad Noveljic","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"headline":"Automating Multi-Tenant Container Database Creation","datePublished":"2019-10-06T16:30:45+00:00","dateModified":"2019-10-06T16:30:47+00:00","mainEntityOfPage":{"@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/"},"wordCount":414,"commentCount":0,"articleSection":["Oracle"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/","url":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/","name":"Automating Multi-Tenant Container Database Creation - All-round Database Topics","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#website"},"datePublished":"2019-10-06T16:30:45+00:00","dateModified":"2019-10-06T16:30:47+00:00","author":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"description":"A check list for automating catcdb.sql execution","breadcrumb":{"@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nenadnoveljic.com\/blog\/automating-multi-tenant-container-database-creation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nenadnoveljic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Automating Multi-Tenant Container Database Creation"}]},{"@type":"WebSite","@id":"https:\/\/nenadnoveljic.com\/blog\/#website","url":"https:\/\/nenadnoveljic.com\/blog\/","name":"All-round Database Topics","description":"Nenad Noveljic","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nenadnoveljic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa","name":"Nenad Noveljic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","caption":"Nenad Noveljic"},"sameAs":["nenad-noveljic-9b746a6","https:\/\/x.com\/NenadNoveljic"],"url":"https:\/\/nenadnoveljic.com\/blog\/author\/nenad\/"}]}},"_links":{"self":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/comments?post=2961"}],"version-history":[{"count":1,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2961\/revisions"}],"predecessor-version":[{"id":2965,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2961\/revisions\/2965"}],"wp:attachment":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/media?parent=2961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/categories?post=2961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/tags?post=2961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}