A couple of days ago I was playing with Oracle Database 12.2.0.1.0 Enterprise Edition Extreme Performance (released last week in Cloud) and I tried to create a new Container Database. As per the 12.2 documentation (that was released a couple of weeks ago) we have to execute the "catcdb.sql" script right after create a Container Database (CDB). This script is located in $ORACLE_HOME/rdbms/admin.
So after execute the CREATE DATABASE sentence (using the new Local Undo btw) I executed the script as I show you below:
SQL> @?/rdbms/admin/catcdb.sql
SQL>
SQL> Rem The script relies on the caller to have connected to the DB
SQL>
SQL> Rem This script invokes catcdb.pl that does all the work, so we just need to
SQL> Rem construct strings for $ORACLE_HOME/rdbms/admin and
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL>
SQL> Rem $ORACLE_HOME
SQL> column oracle_home new_value oracle_home noprint
SQL> select sys_context('userenv', 'oracle_home') as oracle_home from dual;
SQL>
SQL> Rem OS-dependent slash
SQL> column slash new_value slash noprint
SQL> select sys_context('userenv', 'platform_slash') as slash from dual;
SQL>
SQL> Rem $ORACLE_HOME/rdbms/admin
SQL> column rdbms_admin new_value rdbms_admin noprint
SQL> select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual;
old 1: select '&&oracle_home'||'&&slash'||'rdbms'||'&&slash'||'admin' as rdbms_admin from dual
new 1: select '/u01/app/oracle/product/12.2.0/dbhome_1'||'/'||'rdbms'||'/'||'admin' as rdbms_admin from dual
SQL> Rem $ORACLE_HOME/rdbms/admin/catcdb.pl
SQL> column rdbms_admin_catcdb new_value rdbms_admin_catcdb noprint
SQL> select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual;
old 1: select '&&rdbms_admin'||'&&slash'||'catcdb.pl' as rdbms_admin_catcdb from dual
new 1: select '/u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin'||'/'||'catcdb.pl' as rdbms_admin_catcdb from dual
SQL> SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin
Enter value for 2: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl
The script asked me to type two values. Firstly the documentation doesn't say catcdb.pl will request some inputs, I felt this strange.
Well I spent a couple of seconds to figure out which values should I put for the bind variables :1 and :2 but when I saw the previous lines (in green color) I saw that the values were built already by the script but for some reason it is not using them properly. Anyways I used the values obtained from the previous lines and I hit Enter. The result, was an error, the following one:
Can't locate util.pm in @INC (you may need to install the util module) (@INC contains: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin /u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/site_perl/5.22.0/x86_64-linux-thread-multi /u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/site_perl/5.22.0 /u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi /u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0 .) at /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl line 35.
BEGIN failed--compilation aborted at /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl line 35.
Here different thoughts came to my mind, but the first thought was: Perhaps I provided wrong values, but since these "inputs" are not documented I didn't know what to type. After investigation, I found the values were correct (now you don't have to spend time on this [:)] ). I found that the problem was the "util.pm" perl module. While my investigation I had to take a look into the "catcdb.pl" file in the line #35 as the error says:
vi /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl
Line #32 use Cwd;
Line #33 use File::Spec;
Line #34 use Data::Dumper;
Line #35 use util qw(trim, splitToArray);
Line #36 use catcon qw(catconSqlplus);
I searched that perl module in my filesystem:
[oracle@NuvolaDB $]$ find $ORACLE_HOME -name util.pm | wc -l
0
But interestingly I didn't find any, then I tried (just for fun) to search "Util" instead of "util":
[oracle@NuvolaDB ~]$ find $ORACLE_HOME -name Util.pm | wc -l
5
I had 5 results [:O]
[oracle@NuvolaDB ~]$ find $ORACLE_HOME -name Util.pm
/u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/site_perl/5.22.0/HTTP/Headers/Util.pm
/u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash/Util.pm
/u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi/Sub/Util.pm
/u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi/Scalar/Util.pm
/u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi/List/Util.pm
[oracle@NuvolaDB ~]$
I changed the line #35 in the catcdb.sql file. I replaced "util" by "Util":
vi /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl
Line #32 use Cwd;
Line #33 use File::Spec;
Line #34 use Data::Dumper;
Line #35 use Util qw(trim, splitToArray);
Line #36 use catcon qw(catconSqlplus);
Then I re-executed catcdb.pl and I got the same error, but, since I was pretty sure that Util.pm exists I thought "perhaps I have to include the directory where the Util.pm is located? So Included in the PATH env variable the directory where one Util.pm was located, it didn't work [:(] . Then I thought "Should I move to that directory?" Perhaps Oracle is not calling Util.pm from PATH env variable but using "." (current directory) to call it. I decided to move there:
[oracle@NuvolaDB ~]$ cd /u01/app/oracle/product/12.2.0/dbhome_1/perl/lib/5.22.0/x86_64-linux-thread-multi/Hash/
I re-executed catcdb.pl again and guess what? it worked [:)]
SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin
Enter value for 2: /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/catcdb.pl
Enter new password for SYS: Nuvola1
Enter new password for SYSTEM: Nuvola1
Enter temporary tablespace name: temp
No options to container mapping specified, no options will be installed in any containers
....
....
catcon.pl: completed successfully
NOTE: if you get the error "Can't locate Term/ReadKey.pm in @INC", this article is for you: "How to create a CDB with sqlplus and 12c Documentation"
The script lasted several minutes (more than 1hour) to complete but that is another story.... So, to fix the issue of util.pm do the the following:
- Change Line #35 in catcdb.pl replacing "util" by "Util"
- Move to the directory where "Util.pm" is located and from there exeucte catcdb.pl
Follow me: