Various methods to STARTUP,SHUTDOWN the Container(CDB) and Pluggable Databases(PDBs) in Oracle 19C
Posted by Mir Sayeed Hassan on March 24th, 2024
Various methods to STARTUP,SHUTDOWN the Container(CDB) and Pluggable Databases(PDBs) in Oracle 19C
STARTUP CONTAINER AND PLUGGABLE DATABASES
Check the database env at OS Level
[oracle@ora19c ~]$ cat /etc/oratab | grep -i ora19cdb ora19cdb:/u01/app/oracle/product/19.3.0/db_1:N
Set the above database env
[oracle@ora19c ~]$ . oraenv ORACLE_SID = [ora19cdb] ? ora19cdb The Oracle base remains unchanged with value /u01/app/oracle
Startup the Container Database
[oracle@ora19c ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sun Mar 24 08:25:55 2024 Version 19.18.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 3070227784 bytes Fixed Size 9168200 bytes Variable Size 620756992 bytes Database Buffers 2432696320 bytes Redo Buffers 7606272 bytes Database mounted. Database opened.
SQL> select name,open_mode,cdb from v$database; NAME OPEN_MODE CDB --------- -------------------- --- ORA19CDB READ WRITE YES SQL> show con_id con_name CON_ID ------- 1 CON_NAME -------- CDB$ROOT
Check the list of Pluggable databases & start the PDB from CDB
SQL> select name,open_mode,con_id,dbid from v$containers; NAME OPEN_MODE CON_ID DBID --------------------------------------------------- CDB$ROOT READ WRITE 1 708841121 PDB$SEED READ ONLY 2 2920739374 PDB_TEST1 MOUNTED 3 3419863545
Here one of the PDB Database is in mount state.
SQL> alter pluggable database pdb_test1 open; Pluggable database altered.
Verify
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------------------------------------------- 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 READ WRITE NO
Starup the Pluggable database within the Pluggable database
SQL> alter session set container=PDB_TEST1; Session altered.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ------------------------------------ 3 PDB_TEST1 MOUNTED
SQL> alter pluggable database open; Pluggable database altered.
Verify
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------------------------------------------- 3 PDB_TEST1 READ WRITE NO
If you have multiple Pluggable database and want to start all the pluggable database at once., Issue the below command.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ----------------------------------------------- 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 MOUNTED 4 PDB_TEST2 MOUNTED
Here there are 2 Pluggable database which are in mount state.
SQL> alter pluggable database all open; Pluggable database altered.
Verify
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------------ 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 READ WRITE NO 4 PDB_TEST2 READ WRITE NO
SHUTDOWN CONTAINER AND PLUGGABLE DATABASES
Shutdown the pluggable database from Container Database
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ------------------------------------------- 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 READ WRITE NO 4 PDB_TEST2 READ WRITE NO
SQL> alter pluggable database PDB_TEST1 close immediate; Pluggable database altered.
SQL> alter pluggable database PDB_TEST2 close; Pluggable database altered.
Verify
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------------ 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 MOUNTED 4 PDB_TEST2 MOUNTED
Shutdown the pluggable database within the Pluggable database
SQL> alter session set container=PDB_TEST1; Session altered.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED -------------------------------------------------- 3 PDB_TEST1 READ WRITE NO
SQL> alter database close; alter database close * ERROR at line 1: ORA-65040: operation not allowed from within a pluggable database
Here: You should issue this command work only from the Container Database(CDB)
Issue this command:
SQL> alter pluggable database close; Pluggable database altered.
Or
SQL> alter pluggable database close immediate; Pluggable database altered.
Shutdown all the pluggable database from Container Database(CDB)
Connect with sys / as sysdba
SQL> conn / as sysdba
Connected.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ------------------------------------------------- 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 READ WRITE NO 4 PDB_TEST2 READ WRITE NO
SQL> alter pluggable database all close immediate; Pluggable database altered.
Verify
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------------- 2 PDB$SEED READ ONLY NO 3 PDB_TEST1 MOUNTED 4 PDB_TEST2 MOUNTED
If you want to shutdown ALL PDBs,PDB$SEED & CDB$ROOT from the Container Database(CDB).
SQL> select name,open_mode,con_id,dbid from v$containers; NAME OPEN_MODE CON_ID DBID ------------------------------------------------- CDB$ROOT READ WRITE 1 708841121 PDB$SEED READ ONLY 2 2920739374 PDB_TEST1 READ WRITE 3 3419863545 PDB_TEST2 READ WRITE 4 2933199175
Issue below command by sys / as sysdba
SQL> SHOW CON_NAME CON_NAME -------- CDB$ROOT
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down.
Verify
SQL> !ps -ef | grep pmon oracle 79526 77382 0 08:52 pts/0 00:00:00 /bin/bash -c ps -ef | grep pmon oracle 79528 79526 0 08:52 pts/0 00:00:00 grep pmon