In a previous tutorial we saw how to autostart the ORCLCDB sample Oracle database in an Oracle Linux 8.5 VM. We are now going to see how to connect to the ORCLPDB1 Pluggable database hosted by the ORCLCDB Container and how to auto open it after a reboot.

I was planning to use the ORCLPDB1 Pluggable database created with the installation of the ORCLCDB Container database for the installation of the Oracle Analytics Server. But I get the “ORA-12154: TNS: could not resolve the connect identifier specified” error the first time I tried to connect to with the “sqlplus” command.

I quickly realised that there was no entry for this database in the “tnsnames.ora” “Oracle Listener” file so I edited this file and I added the connexion parameters for ORCLPDB1 with the “sudo vi /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora” command:

I tried to connect again using the “sqlplus sys@orclpdb1 as sysdba” command and I could connect this time:

I checked the status of the Pluggable database using the “show pdbs” command and I realised that it was mounted but not opened, so I used the “alter pluggable database orclpdb1 open;” command to open it:

I was now able to use the ORCLPDB1 database, but after rebooting the VM, I realised that it was mounted but not opened automatically after a reboot. I didn’t want to have to manually open it after every reboot so I found that I could ask Oracle to save the state of a Pluggable DB using the “alter pluggable database orclpdb1 save state;” command:

As a consequence, the Oracle Database Server would now preserve the Pluggable DB state after restarting the DB. I restarted the VM once more and I used the “show pdbs” command to check the ORCLPDB1 database open mode and it was effectively “READ WRITE” as expected :

With these modifications, the ORCLPDB1 Pluggable database now opened automatically after restarting up the VM and I didn’t have to execute additional commands in order to be able to use it.
Disclaimer
The post How to connect to and automatically open the ORCLPDB1 Oracle 19c Pluggable database appeared first on MyBIJourney