프린트 하기

OS 환경 : Oracle Linux 9.6 (64bit)

 

DB 환경 : Oracle AI Database 23.26.1.0.0 ai

 

방법 : 오라클 26ai cdb 기동시 pdb 자동 기동 방법

오라클 26ai에서 cdb를 기동할 때 pdb는 기본적으로 함께 기동(open)되지 않고 mount 상태로 기동됨
본문에서는 pdb의 state를 save 명령을 이용해 cdb 기동시 함께 기동되게끔 설정하는 방법을 설명함

 

 

테스트
cdb 기동

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ sqlplus / as sysdba
SQL> startup
ORACLE instance started.
 
Total System Global Area 1624477776 bytes
Fixed Size                  5009488 bytes
Variable Size             520093696 bytes
Database Buffers         1090519040 bytes
Redo Buffers                8855552 bytes
Database mounted.
Database opened.
 
SQL> show con_name
 
CON_NAME
------------------------------
CDB$ROOT

 

 

cdb, pdb 상태 확인

1
2
3
4
5
6
7
8
9
10
SQL>
set lines 200 pages 1000
col name for a20
select con_id, name, open_mode from v$containers;
 
    CON_ID NAME                 OPEN_MODE
---------- -------------------- ----------
         1 CDB$ROOT             READ WRITE
         2 PDB$SEED             READ ONLY
         3 ORACLE26PDB1         MOUNTED

cdb는 read write(open) 상태가 되었지만 pdb는 mount 상태임

 

 

pdb 수동 기동

1
2
3
SQL> alter pluggable database oracle26pdb1 open;
 
Pluggable database altered.

 

 

cdb, pdb 상태 재확인

1
2
3
4
5
6
7
8
9
10
SQL>
set lines 200 pages 1000
col name for a20
select con_id, name, open_mode from v$containers;
 
    CON_ID NAME                 OPEN_MODE
---------- -------------------- ----------
         1 CDB$ROOT             READ WRITE
         2 PDB$SEED             READ ONLY
         3 ORACLE26PDB1         READ WRITE

pdb도 read write(open)상태가 됨

 

 

cdb가 기동될때 pdb가 같이 기동되지 않는것은 state 설정 문제임
pdb state 확인

1
2
3
4
5
6
7
8
SQL> 
set lines 200 pages 1000
col con_name for a20
select con_id, con_name, state
from dba_pdb_saved_states
order by con_id;
 
no rows selected

결과가 없다고 나옴

 

 

pdb의 state를 save(저장)

1
2
3
SQL> alter pluggable database oracle26pdb1 save state;
 
Pluggable database altered.

 

 

pdb state 재확인

1
2
3
4
5
6
7
8
9
10
SQL> 
set lines 200 pages 1000
col con_name for a20
select con_id, con_name, state
from dba_pdb_saved_states
order by con_id;
 
    CON_ID CON_NAME             STATE
---------- -------------------- --------------
         3 ORACLE26PDB1         OPEN

pdb의 state가 open으로 변경됨

 

 

cdb 재기동

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
 
SQL> startup
ORACLE instance started.
 
Total System Global Area 1624477776 bytes
Fixed Size                  5009488 bytes
Variable Size             520093696 bytes
Database Buffers         1090519040 bytes
Redo Buffers                8855552 bytes
Database mounted.
Database opened.

 

 

cdb, pdb 상태 재확인

1
2
3
4
5
6
7
8
9
10
SQL>
set lines 200 pages 1000
col name for a20
select con_id, name, open_mode from v$containers;
 
    CON_ID NAME                 OPEN_MODE
---------- -------------------- ----------
         1 CDB$ROOT             READ WRITE
         2 PDB$SEED             READ ONLY
         3 ORACLE26PDB1         READ WRITE

cdb와 함께 pdb도 read write(open)상태가 됨

 

 

참고로 pdb state의 기본값은 discard임
discard로 변경하려면 discard state 명령을 이용하면됨

1
2
3
SQL> alter pluggable database oracle26pdb1 discard state;
 
Pluggable database altered.

 

 

참고1. 모든 pdb의 state를 save(저장)

1
2
3
SQL> alter pluggable database all save state;
 
Pluggable database altered.

 

 

참고2. 모든 pdb 종료

1
2
3
SQL> alter pluggable database all close;
 
Pluggable database altered.

 

 

결론 :
pdb를 open 상태로 변경한 뒤 state를 save 해서 cdb 기동시 pdb도 함께 기동되게끔 할수 있음
반대로 state를 원래대로 되돌리려면 discard 명령을 이용하거나 mount 상태에서 state를 save 하면됨

 

 

참조 : 

https://docs.oracle.com/en/database/oracle/oracle-database/26/refrn/DBA_PDB_SAVED_STATES.html
https://docs.oracle.com/en/database/oracle/oracle-database/26/sqlrf/ALTER-PLUGGABLE-DATABASE.html