Create PDB in silent mode

In Oracle 12c RDBMS you can use the Database Configuration Assistant to create a PDB from shell scripts or command line in an existing CDB.    You can provide all of the necessary parameters for the PDB creation through a response file or at the command prompt.   In this example we will provide all required command line option to create new PDB called pdb1 in the CDB1 container.

 

  1. Logon to your Oracle server as the Oracle software owner.

 

[root@linux2 ~]# su – oracle

Last login: Wed Oct  5 15:10:16 EDT 2016 on pts/2

[oracle@linux2 ~]$

 

  1. Define the following parameter with values:
    1. -sourceDB = the name of the CDB database you wish to create your PDB in.
    2. -pdbName = the name of the new PDB database.
    3. -pdbAdminPassword = password for the PDB admin user.

 

  1. You will have to also supply the tags: –silent and  -createPluggableDatabase

 

  1. Update the below DBCA command with the values defined in step 2.

 

dbca -silent -createPluggableDatabase -sourceDB cdb1 -pdbName pdb1 -pdbAdminPassword password

 

  1. Example execution.

 

[oracle@linux2 admin]$ dbca -silent -createPluggableDatabase -sourceDB cdb1 -pdbName pdb1 -pdbAdminPassword password

Creating Pluggable Database

4% complete                                                                                                                                         

12% complete

21% complete

38% complete

85% complete

Completing Pluggable Database Creation

100% complete

Look at the log file “/opt/app/oracle/cfgtoollogs/dbca/cdb1/pdb1/cdb1.log” for further details.

[oracle@linux2 admin]$

 

  1. View the status of the listener process to validate that the new PDB has been picked up by the listener with the command: lsnrctl status

 

[oracle@linux2 admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 12.1.0.2.0 – Production on 20-OCT-2016 10:21:44

 

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.30.15.75)(PORT=1521)))

STATUS of the LISTENER

————————

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 – Production

Start Date                19-OCT-2016 14:06:54

Uptime                    0 days 20 hr. 14 min. 50 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /opt/app/oracle/product/12.1.0.2/db_1/network/admin/listener.ora

Listener Log File         /opt/app/oracle/diag/tnslsnr/linux2/listener/alert/log.xml

Listening Endpoints Summary…

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.30.15.75)(PORT=1521)))

Services Summary…

Service “cdb1” has 2 instance(s).

  Instance “cdb1”, status UNKNOWN, has 1 handler(s) for this service…

  Instance “cdb1”, status READY, has 1 handler(s) for this service…

Service “cdb1XDB” has 1 instance(s).

  Instance “cdb1”, status READY, has 1 handler(s) for this service…

Service “pdb1” has 1 instance(s).

  Instance “cdb1”, status READY, has 1 handler(s) for this service…

The command completed successfully

[oracle@linux2 admin]$

 

 

  1. Update the tnsnames.ora file with the reference to newly created PDB1 with the command:

 

echo -e “PDB1 =\n” \

”  (DESCRIPTION =\n” \

”    (ADDRESS_LIST =\n” \

”      (ADDRESS = (PROTOCOL = TCP)(HOST = “`hostname -i`”)(PORT = 1521))\n” \

”    )\n” \

”    (CONNECT_DATA =\n” \

”      (SERVER = DEDICATED)\n”  \

”      (SERVICE_NAME = pdb1)\n” \

”    )\n” \

”  )\n” >> $ORACLE_HOME/network/admin/tnsnames.ora

 

Example execution:

 

[oracle@linux2 admin]$ echo -e “PDB1 =\n” \

> ”  (DESCRIPTION =\n” \

> ”    (ADDRESS_LIST =\n” \

> ”      (ADDRESS = (PROTOCOL = TCP)(HOST = “`hostname -i`”)(PORT = 1521))\n” \

> ”    )\n” \

> ”    (CONNECT_DATA =\n” \

”      (SERVER = DEDICATED)\n”  \

”      (SERVICE_NAME = pdb1)\n” \

”    )\n” \

”  )\n” >> $ORACLE_HOME/network/admin/tnsnames.ora> ”      (SERVER = DEDICATED)\n”  \

> ”      (SERVICE_NAME = pdb1)\n” \

> ”    )\n” \

> ”  )\n” >> $ORACLE_HOME/network/admin/tnsnames.ora

[oracle@linux2 admin]$

 

 

  1. Test connection to new PDB with the command: tnsping pdb1

 

[oracle@linux2 admin]$ tnsping pdb1

 

TNS Ping Utility for Linux: Version 12.1.0.2.0 – Production on 20-OCT-2016 10:32:32

 

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

 

Used parameter files:

 

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.30.15.75)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb1)))

OK (0 msec)

[oracle@linux2 admin]$

 

 

  1. This completes the creation of new PDB in silent mode.

 

Larry Catt

OCP

Leave a Reply