Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

STARTUP and SHUTDOWN CDB AND PDB

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 21 Nov, 2021
  • 0 Comments
  • 5 Mins Read

STARTUP and SHUTDOWN CDB AND PDB

STARTUP/SHUTDOWN CDB AND PDB

In this blog, We will see how to start and shutdwn container and pluggable database in 19C. Startup and shutdown is the responsibility of oracle dba.

HOW TO STARTUP/SHUTDOWN CDB AND PDB ON LINUX

1. Startup CDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[oracle@localhost ~]$ cat /etc/oratab | grep -i CDB2
CDB2:/u01/app/oracle/product/12.2.0.1:N
[oracle@localhost ~]$
[oracle@localhost ~]$ . oraenv
ORACLE_SID = [CDB2] ?
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@localhost ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 12.2.0.1.0 Production on Sun Jul 15 17:30:11 2018
 
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
 
Connected to an idle instance.
 
SQL> startup;
ORACLE instance started.
 
Total System Global Area 1577058304 bytes
Fixed Size                  8793208 bytes
Variable Size             503317384 bytes
Database Buffers         1056964608 bytes
Redo Buffers                7983104 bytes
Database mounted.
Database opened.
SQL>
 
SQL> select name,open_mode,cdb from v$database;
 
NAME      OPEN_MODE            CDB
--------- -------------------- ---
CDB2      READ WRITE           YES  <------
 
SQL>
 
SQL> show con_id con_name
 
CON_ID
------------------------------
1
 
CON_NAME
------------------------------
CDB$ROOT  <-----
 
SQL>

2. Startup PDB

2.1 Startup PDB from CDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
SQL> col name for a30
SQL> select name,open_mode,con_id,dbid from v$containers;
 
NAME                           OPEN_MODE      CON_ID       DBID
------------------------------ ---------- ---------- ----------
CDB$ROOT                       READ WRITE          1  680230459
PDB$SEED                       READ ONLY           2 2993936271
PDB1                           MOUNTED             3  627484885
PDB2                           MOUNTED             4  891811039
PDB3                           MOUNTED             5  424568091
PDB4                           MOUNTED             6 2306285303
 
6 rows selected.
 
SQL>
 
 
SQL> show pdbs;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED  <------
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED
         6 PDB4                           MOUNTED
 
SQL>
 
SQL> ALTER PLUGGABLE DATABASE PDB1 OPEN;
 
Pluggable database altered.
 
SQL>
 
SQL> select name,open_mode,con_id,dbid from v$containers;
 
NAME                           OPEN_MODE      CON_ID       DBID
------------------------------ ---------- ---------- ----------
CDB$ROOT                       READ WRITE          1  680230459
PDB$SEED                       READ ONLY           2 2993936271
PDB1                           READ WRITE          3  627484885 <----
PDB2                           MOUNTED             4  891811039
PDB3                           MOUNTED             5  424568091
PDB4                           MOUNTED             6 2306285303
 
6 rows selected.
 
SQL>

2.2 Startup PDB with in PDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- Switch to PDB from CDB
SQL> alter session set container=PDB2;  <----
 
Session altered.
 
SQL> show con_name
 
CON_NAME
------------------------------
PDB2
SQL> show con_id
 
CON_ID
------------------------------
4
SQL>
 
SQL> show pdbs;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 PDB2                           MOUNTED   <-----
SQL>
 
SQL> startup;
Pluggable Database opened.
SQL>
 
-- OR --
 
SQL> ALTER DATABASE OPEN;
 
Database altered.
 
SQL>
 
-- OR --
 
SQL> ALTER PLUGGABLE DATABASE OPEN;
 
Pluggable database altered.
 
SQL>
 
SQL> show pdbs;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 PDB2                           READ WRITE NO
SQL>
 
SQL> select CON_ID,NAME,OPEN_MODE from v$pdbs;
 
    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         4 PDB2                           READ WRITE <------
 
SQL>

2.3 Startup ALL PDBs from CDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Switch to CDB from PDB
 
SQL> conn / as sysdba
Connected.
SQL>
 
SQL>  select name,open_mode,cdb from v$database;
 
NAME                           OPEN_MODE            CDB
------------------------------ -------------------- ---
CDB2                           READ WRITE           YES <----
 
SQL> show con_id
 
CON_ID
------------------------------
1
 
SQL> show con_name
 
CON_NAME
------------------------------
CDB$ROOT  <---
 
SQL>
 
SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
 
Pluggable database altered.
 
SQL>
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
         6 PDB4                           READ WRITE NO
SQL>

3. Shutdown PDB

3.1 Shutdown PDB from CDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
SQL> show con_name
 
CON_NAME
------------------------------
CDB$ROOT
 
SQL>
 
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
         6 PDB4                           READ WRITE NO
SQL>
 
SQL> ALTER PLUGGABLE DATABASE PDB1 CLOSE IMMEDIATE;
 
Pluggable database altered.
 
SQL>
 
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED <-----
         4 PDB2                           READ WRITE NO
         5 PDB3                           READ WRITE NO
         6 PDB4                           READ WRITE NO
SQL>

3.2 Shutdown PDB with in PDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- Switch to PDB from CDB
SQL> ALTER SESSION SET CONTAINER=PDB2;   <----
 
Session altered.
 
SQL> SHOW CON_NAME
 
CON_NAME
------------------------------
PDB2 <-----
 
SQL>
 
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 PDB2                           READ WRITE NO  <------ R/W
SQL>
 
SQL> ALTER DATABASE CLOSE;  <-- This command work only inside CDB
ALTER DATABASE CLOSE
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database
 
SQL>
 
SQL> ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
 
Pluggable database altered.
 
SQL>
 
--- OR ---
 
SQL> SHUT IMMEDIATE;  -- PLEASE DO NOT RUN FROM CDB, IT WILL CLOSE CDB AND ALL PDBs inside CDB
Pluggable Database closed.
SQL>
 
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 PDB2                           MOUNTED  <----
SQL>

3.3 Shutdown ALL PDBs from CDB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Switch to CDB from PDB
SQL> CONN / AS SYSDBA
Connected.
SQL>
 
SQL> SHOW CON_NAME
 
CON_NAME
------------------------------
CDB$ROOT <----
 
SQL>
 
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           READ WRITE NO
         6 PDB4                           READ WRITE NO
SQL>
 
SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
 
Pluggable database altered.
 
SQL>
SQL> SHOW PDBS;
 
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 PDB2                           MOUNTED
         5 PDB3                           MOUNTED
         6 PDB4                           MOUNTED
SQL>

4. Shutdown CDB

PLEASE DO NOT run SHUT IMMEDIATE OR ALTER DATABASE CLOSE command from CDB, it will shutdown ALL PDBs,PDB$SEED & CDB$ROOT inside CDB.

Example for the same below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
SQL> select name,open_mode,con_id,dbid from v$containers;
 
NAME                           OPEN_MODE      CON_ID       DBID
------------------------------ ---------- ---------- ----------
CDB$ROOT                       READ WRITE          1  680230459 <-- R/W
PDB$SEED                       READ ONLY           2 2993936271
PDB1                           MOUNTED             3  627484885
PDB2                           MOUNTED             4  891811039
PDB3                           MOUNTED             5  424568091
PDB4                           MOUNTED             6 2306285303
 
6 rows selected.
 
SQL>
 
SQL> SHOW CON_NAME
 
CON_NAME
------------------------------
CDB$ROOT
 
SQL>
 
SQL> SHUT IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
 
SQL> !ps -ef | grep pmon
oracle   13612 12669  0 19:00 pts/0    00:00:00 /bin/bash -c ps -ef | grep pmon
oracle   13614 13612  0 19:00 pts/0    00:00:00 grep pmon
 
SQL>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SQL> col name for a30
SQL> select name,open_mode,con_id,dbid from v$containers;
 
NAME                           OPEN_MODE      CON_ID       DBID
------------------------------ ---------- ---------- ----------
CDB$ROOT                       READ WRITE          1  680230459
PDB$SEED                       READ ONLY           2 2993936271
PDB1                           READ WRITE          3  627484885
PDB2                           READ WRITE          4  891811039
PDB3                           READ WRITE          5  424568091
PDB4                           READ WRITE          6 2306285303
 
6 rows selected.
 
SQL> show con_name
 
CON_NAME
------------------------------
CDB$ROOT <----
SQL>
SQL> ALTER DATABASE CLOSE IMMEDIATE;
 
Database altered.
 
SQL>
SQL> select name,open_mode,con_id,dbid from v$containers;
 
NAME                           OPEN_MODE      CON_ID       DBID
------------------------------ ---------- ---------- ----------
CDB$ROOT                       MOUNTED             1  680230459
PDB$SEED                       MOUNTED             2 2993936271
PDB1                           MOUNTED             3  627484885
PDB2                           MOUNTED             4  891811039
PDB3                           MOUNTED             5  424568091
PDB4                           MOUNTED             6 2306285303
 
6 rows selected.
 
SQL>
SQL> shut immediate;
ORA-01109: database not open
 
 
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> !ps -ef | grep pmon
oracle   14495 12669  0 19:16 pts/0    00:00:00 /bin/bash -c ps -ef | grep pmon
oracle   14497 14495  0 19:16 pts/0    00:00:00 grep pmon
 
SQL>