1. 사전 준비
A) 환경 조사
select COMP_NAME, VERSION_FULL, STATUS from DBA_REGISTRY; select NAME, DISPLAY_VALUE from V$PARAMETER where NAME = 'compatible'; select * from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET';
※ PDB로 전환할 DB의 정보
SQL> set lines 200 SQL> col name form a10 SQL> col open_mode form a20 SQL> select NAME, OPEN_MODE, CDB from V$DATABASE; NAME OPEN_MODE CDB ---------- -------------------- --------- ORCL READ WRITE NO SQL> set lines 200 SQL> set pages 100 SQL> col COMP_NAME form a35 SQL> col VERSION_FULL form a20 SQL> col STATUS form a10 SQL> select COMP_NAME, VERSION_FULL, STATUS from DBA_REGISTRY; COMP_NAME VERSION_FULL STATUS ----------------------------------- -------------------- ---------- Oracle Database Catalog Views 19.22.0.0.0 VALID Oracle Database Packages and Types 19.22.0.0.0 VALID Oracle Real Application Clusters 19.22.0.0.0 OPTION OFF JServer JAVA Virtual Machine 19.22.0.0.0 VALID Oracle XDK 19.22.0.0.0 VALID Oracle Database Java Packages 19.22.0.0.0 VALID Oracle XML Database 19.22.0.0.0 VALID Oracle Workspace Manager 19.22.0.0.0 VALID 8 rows selected. SQL> set lines 200 SQL> col NAME form a20 SQL> col DISPLAY_VALUE form a20 SQL> select NAME, DISPLAY_VALUE from V$PARAMETER where NAME = 'compatible'; NAME DISPLAY_VALUE -------------------- -------------------- compatible 19.0.0 SQL> col PARAMETER form a30 SQL> col VALUE form a30 SQL> select * from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET'; PARAMETER VALUE ------------------------------ ------------------------------ NLS_CHARACTERSET KO16MSWIN949
※ CDB의 정보
SQL> set lines 200 SQL> col name form a10 SQL> col open_mode form a20 SQL> select NAME, OPEN_MODE, CDB from V$DATABASE; NAME OPEN_MODE CDB ---------- -------------------- --- ORCLCDB READ WRITE YES SQL> set lines 200 SQL> set pages 100 SQL> col COMP_NAME form a35 SQL> col VERSION_FULL form a20 SQL> col STATUS form a10 SQL> select COMP_NAME, VERSION_FULL, STATUS from DBA_REGISTRY; COMP_NAME VERSION_FULL STATUS ----------------------------------- -------------------- ---------- Oracle Database Catalog Views 19.22.0.0.0 VALID Oracle Database Packages and Types 19.22.0.0.0 VALID Oracle Real Application Clusters 19.22.0.0.0 OPTION OFF Oracle XML Database 19.22.0.0.0 VALID Oracle Workspace Manager 19.22.0.0.0 VALID Oracle Text 19.22.0.0.0 VALID 6 rows selected. SQL> set lines 200 SQL> col NAME form a20 SQL> col DISPLAY_VALUE form a20 SQL> select NAME, DISPLAY_VALUE from V$PARAMETER where NAME = 'compatible'; NAME DISPLAY_VALUE -------------------- -------------------- compatible 19.0.0 SQL> col PARAMETER form a30 SQL> col VALUE form a30 SQL> select * from NLS_DATABASE_PARAMETERS where parameter = 'NLS_CHARACTERSET'; PARAMETER VALUE ------------------------------ ------------------------------ NLS_CHARACTERSET AL32UTF8
{}
변환할 DB와 CDB 간의 호환성을 확인합니다.
CDB 쪽의 compatible이 높은 버전이거나, CDB쪽의 컴포넌트가 더 있을 경우에도 추가 작업 없이 전환할 수 있습니다.
또한 CDB쪽의 character set이 전환할 DB의 character set보다 superset이면 문제 없이 전환할 수 있습니다.
B) Read only 모드로 전환
shutdown immediate startup open read only
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup open read only ORACLE instance started. Total System Global Area 1577056776 bytes Fixed Size 8940040 bytes Variable Size 385875968 bytes Database Buffers 1174405120 bytes Redo Buffers 7835648 bytes Database mounted. Database opened. SQL> set lines 200 SQL> col name form a10 SQL> col open_mode form a20 SQL> select NAME, OPEN_MODE, CDB from V$DATABASE; NAME OPEN_MODE CDB ---------- -------------------- --------- ORCL READ ONLY NO
2. 구성 정보 확인
A) DB 정보 추출
BEGIN DBMS_PDB.DESCRIBE(pdb_descr_file => '<XML 파일 저장 경로 및 파일명>'); END; /
SQL> BEGIN 2 DBMS_PDB.DESCRIBE(pdb_descr_file => '/home/oracle/orcl.xml'); 3 END; 4 / PL/SQL procedure successfully completed.
B) 플러그인 호환성 조사
SET SERVEROUTPUT ON; DECLARE compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '<XML 파일 저장 경로 및 파일명>') WHEN TRUE THEN 'YES' ELSE 'NO' END; BEGIN DBMS_OUTPUT.PUT_LINE(compatible); END; /
SQL> SET SERVEROUTPUT ON; SQL> DECLARE 2 compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/home/oracle/orcl.xml') 3 WHEN TRUE THEN 'YES' 4 ELSE 'NO' 5 END; 6 BEGIN 7 DBMS_OUTPUT.PUT_LINE(compatible); 8 END; 9 / NO PL/SQL procedure successfully completed.
C) 플러그인 위반 사항 확인
select NAME, CAUSE, TYPE, MESSAGE, STATUS, ACTION from PDB_PLUG_IN_VIOLATIONS order by TIME, LINE;
※ 예제에서는 CDB쪽에 JVM 관련 컴포넌트(CATJAVA, JAVAVM, XML)들이 누락되어 ERROR가 발생한 것을 확인할 수 있습니다.
SQL> set lines 300 SQL> col NAME form a10 SQL> col CAUSE form a15 SQL> col TYPE form a10 SQL> col MESSAGE form a100 SQL> col STATUS form a10 SQL> col ACTION form a50 SQL> select NAME, CAUSE, TYPE, MESSAGE, STATUS, ACTION from PDB_PLUG_IN_VIOLATIONS order by TIME, LINE; NAME CAUSE TYPE MESSAGE STATUS ACTION ---------- --------------- ---------- ---------------------------------------------------------------------------------------------------- ---------- -------------------------------------------------- ORCL Non-CDB to PDB WARNING PDB plugged in is a non-CDB, requires noncdb_to_pdb.sql be run. PENDING Run noncdb_to_pdb.sql. ORCL PDB not Unicode WARNING PDB not in Unicode (AL32UTF8) character set. PDB character set KO16MSWIN949. PENDING Oracle recommends using Unicode (AL32UTF8) charact er set for the database. Consider migrating the da tabase to Unicode. ORCL OPTION ERROR Database option CATJAVA mismatch: PDB installed version 19.0.0.0.0. CDB installed version NULL. PENDING Fix the database option in the PDB or the CDB ORCL OPTION ERROR Database option JAVAVM mismatch: PDB installed version 19.0.0.0.0. CDB installed version NULL. PENDING Fix the database option in the PDB or the CDB ORCL OPTION ERROR Database option XML mismatch: PDB installed version 19.0.0.0.0. CDB installed version NULL. PENDING Fix the database option in the PDB or the CDB ORCL OPTION WARNING Database option CONTEXT mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0. PENDING Fix the database option in the PDB or the CDB ORCL Parameter WARNING CDB parameter sga_target mismatch: Previous 1504M Current 3008M PENDING Please check the parameter in the current CDB ORCL Parameter WARNING CDB parameter pga_aggregate_target mismatch: Previous 500M Current 1000M PENDING Please check the parameter in the current CDB 8 rows selected.
WARNING 상태인 메시지는 PDB로 전환하거나 DB를 재기동하는 등의 일련의 과정을 통해 해결될 수 있으나, ERROR 상태인 메시지는 반드시 문제의 원인을 찾아 해결해야 합니다.
3. 플러그인 이슈 해결
A) CDB에 누락된 컴포넌트 생성 스크립트 작성
cat > install_jvm.sql SET VERIFY OFF connect "SYS"/"&&sysPassword" as SYSDBA set echo on spool <작업 로그 저장 경로>/JServer.log append alter pluggable database all open; alter system set "_system_trig_enabled" = false scope=memory; host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -v -b initjvm -c 'PDB$SEED CDB$ROOT' -U "SYS"/"&&sysPassword" <ORACLE_HOME 경로>/javavm/install/initjvm.sql; host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -v -b initxml -c 'PDB$SEED CDB$ROOT' -U "SYS"/"&&sysPassword" <ORACLE_HOME 경로>/xdk/admin/initxml.sql; host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -v -b xmlja -c 'PDB$SEED CDB$ROOT' -U "SYS"/"&&sysPassword" <ORACLE_HOME 경로>/xdk/admin/xmlja.sql; host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -v -b catjava -c 'PDB$SEED CDB$ROOT' -U "SYS"/"&&sysPassword" <ORACLE_HOME 경로>/rdbms/admin/catjava.sql; connect "SYS"/"&&sysPassword" as SYSDBA host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -v -b catxdbj -c 'PDB$SEED CDB$ROOT' -U "SYS"/"&&sysPassword" <ORACLE_HOME 경로>/rdbms/admin/catxdbj.sql; shutdown immediate startup host <ORACLE_HOME 경로>/perl/bin/perl <ORACLE_HOME 경로>/rdbms/admin/catcon.pl -n 1 -l <작업 로그 저장 경로> -e -b utlrp <ORACLE_HOME 경로>/rdbms/admin/utlrp.sql SELECT comp_name, version, status FROM dba_registry ORDER BY comp_name; SELECT dbms_java.get_jdk_version JDK_Version FROM dual; spool off
테스트 케이스에서는 CDB 쪽에 JAVA 관련 컴포넌트들이 누락되어 이를 추가해야 하는 상황입니다.
이를 위해 컴포넌트 생성 스크립트를 작성하여 실행해야 하며, CDB와 PDB$SEED에 컴포넌트가 적용되도록 옵션을 주어야 합니다.
CDB에는 있으나 PDB로 전환할 DB에 없는 컴포넌트에 대해서는 PDB로 전환한 후에 추가할 수 있습니다.
B) CDB 누락 컴포넌트 설치
@install_jvm
SQL> @install_jvm Enter value for syspassword: oracle Connected. SQL> spool /home/oracle/JVM/JServer.log append SQL> alter pluggable database all open; Pluggable database altered. SQL> alter system set "_system_trig_enabled" = false scope=memory; System altered. ... << 생략 >> ... SQL> SELECT dbms_java.get_jdk_version JDK_Version FROM dual; JDK_VERSION -------------------------------------------------------------------------------- 1.8.0_201 SQL> spool off
작성된 컴포넌트 생성 스크립트를 CDB에서 실행합니다.
C) CDB 컴포넌트 설치 결과 확인
select COMP_NAME, VERSION_FULL, STATUS from DBA_REGISTRY;
SQL> set lines 200 SQL> set pages 100 SQL> col COMP_NAME form a35 SQL> col VERSION_FULL form a20 SQL> col STATUS form a10 SQL> select COMP_NAME, VERSION_FULL, STATUS from DBA_REGISTRY; COMP_NAME VERSION_FULL STATUS ----------------------------------- -------------------- ---------- Oracle Database Catalog Views 19.22.0.0.0 VALID Oracle Database Packages and Types 19.22.0.0.0 VALID Oracle Real Application Clusters 19.22.0.0.0 OPTION OFF JServer JAVA Virtual Machine 19.22.0.0.0 VALID Oracle XDK 19.22.0.0.0 VALID Oracle Database Java Packages 19.22.0.0.0 VALID Oracle XML Database 19.22.0.0.0 VALID Oracle Workspace Manager 19.22.0.0.0 VALID Oracle Text 19.22.0.0.0 VALID 9 rows selected.
D) 호환성 이슈 해결 결과 확인
SET SERVEROUTPUT ON; DECLARE compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '<XML 파일 저장 경로 및 파일명>') WHEN TRUE THEN 'YES' ELSE 'NO' END; BEGIN DBMS_OUTPUT.PUT_LINE(compatible); END; /
SQL> SET SERVEROUTPUT ON; SQL> DECLARE 2 compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/home/oracle/orcl.xml') 3 WHEN TRUE THEN 'YES' 4 ELSE 'NO' 5 END; 6 BEGIN 7 DBMS_OUTPUT.PUT_LINE(compatible); 8 END; 9 / YES PL/SQL procedure successfully completed.
select NAME, CAUSE, TYPE, MESSAGE, STATUS, ACTION from PDB_PLUG_IN_VIOLATIONS order by TIME, LINE;
SQL> set lines 300 SQL> col NAME form a10 SQL> col CAUSE form a15 SQL> col TYPE form a10 SQL> col MESSAGE form a100 SQL> col STATUS form a10 SQL> col ACTION form a50 SQL> select NAME, CAUSE, TYPE, MESSAGE, STATUS, ACTION from PDB_PLUG_IN_VIOLATIONS order by TIME, LINE; NAME CAUSE TYPE MESSAGE STATUS ACTION ---------- --------------- ---------- ---------------------------------------------------------------------------------------------------- ---------- -------------------------------------------------- PDB$SEED OPTION WARNING Database option JAVAVM mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0. RESOLVED Fix the database option in the PDB or the CDB PDB$SEED OPTION WARNING Database option XML mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0. RESOLVED Fix the database option in the PDB or the CDB PDB$SEED OPTION WARNING Database option CATJAVA mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0. RESOLVED Fix the database option in the PDB or the CDB ORCL Non-CDB to PDB WARNING PDB plugged in is a non-CDB, requires noncdb_to_pdb.sql be run. PENDING Run noncdb_to_pdb.sql. ORCL PDB not Unicode WARNING PDB not in Unicode (AL32UTF8) character set. PDB character set KO16MSWIN949. PENDING Oracle recommends using Unicode (AL32UTF8) charact er set for the database. Consider migrating the da tabase to Unicode. ORCL OPTION WARNING Database option CONTEXT mismatch: PDB installed version NULL. CDB installed version 19.0.0.0.0. PENDING Fix the database option in the PDB or the CDB ORCL Parameter WARNING CDB parameter sga_target mismatch: Previous 1504M Current 3008M PENDING Please check the parameter in the current CDB ORCL Parameter WARNING CDB parameter pga_aggregate_target mismatch: Previous 500M Current 1000M PENDING Please check the parameter in the current CDB 8 rows selected.
ERROR가 모두 사라졌다면 PDB로 전환해도 됩니다.
4. PDB 전환
A) PDB 생성
CREATE PLUGGABLE DATABASE <새로 생성할 PDB명> USING '<XML 파일 저장 경로 및 파일명>' COPY FILE_NAME_CONVERT = ('<원본 데이터 파일 저장 경로>', '<PDB 데이터 파일 저장 경로>');
SQL> CREATE PLUGGABLE DATABASE orclpdb USING '/home/oracle/orcl.xml' 2 COPY FILE_NAME_CONVERT = ('/oradata/ORCL/', '/oradata/ORCLCDB/ORCLPDB/'); Pluggable database created.
CREATE PLUGGABLE DATABASE <새로 생성할 PDB명> USING '<XML 파일 저장 경로 및 파일명>' NOCOPY;
기존의 데이터 파일을 복제하여 PDB로 전환하거나, 원래 파일 그대로 전환할 수 있습니다.
NOCOPY 옵션으로 기존의 파일 그대로 PDF로 전환할 경우에는, 기존 경로에 있던 temp file은 사용하지 않게 되므로 모두 지워야 합니다.
B) PDB로 변환
ALTER SESSION SET CONTAINER=<새로 생성된 PDB명>; @?/rdbms/admin/noncdb_to_pdb.sql
SQL> ALTER SESSION SET CONTAINER=orclpdb; Session altered. SQL> @?/rdbms/admin/noncdb_to_pdb.sql SQL> Rem SQL> Rem $Header: rdbms/admin/noncdb_to_pdb.sql /st_rdbms_19/4 2021/09/30 22:14:37 hmohanku Exp $ SQL> Rem SQL> Rem noncdb_to_pdb.sql SQL> Rem SQL> Rem Copyright (c) 2011, 2021, Oracle and/or its affiliates. SQL> Rem All rights reserved. ... << 생략 >> ... SQL> -- leave the PDB in the same state it was when we started SQL> BEGIN 2 execute immediate '&open_sql &restricted_state'; 3 EXCEPTION 4 WHEN OTHERS THEN 5 BEGIN 6 IF (sqlcode <> -900) THEN 7 RAISE; 8 END IF; 9 END; 10 END; 11 / PL/SQL procedure successfully completed. SQL> SQL> WHENEVER SQLERROR CONTINUE;
5. PDB 기동 및 확인
A) 변환된 PDB 기동
ALTER PLUGGABLE DATABASE <새로 생성된 PDB명> OPEN; SELECT name, open_mode FROM v$pdbs;
SQL> ALTER PLUGGABLE DATABASE ORCLPDB OPEN; Pluggable database altered. SQL> SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ---------- -------------------- ORCLPDB READ WRITE 1 row selected.
B) 최종 결과 확인
select PDB_NAME, to_char(OP_TIMESTAMP,'YYYY/MM/DD HH24:MI:SS') OP_TIME, OPERATION, DB_VERSION, CLONED_FROM_PDB_NAME, DB_NAME from CDB_PDB_HISTORY;
SQL> col PDB_NAME form a10 SQL> col OPERATION form a10 SQL> col CLONED_FROM_PDB_NAME form a10 SQL> col DB_NAME form a10 SQL> col OP_TIME form a30 SQL> select PDB_NAME, to_char(OP_TIMESTAMP,'YYYY/MM/DD HH24:MI:SS') OP_TIME, OPERATION, DB_VERSION, CLONED_FROM_PDB_NAME, DB_NAME from CDB_PDB_HISTORY; PDB_NAME OP_TIME OPERATION DB_VERSION CLONED_FRO DB_NAME ---------- ------------------------------ ---------- ---------- ---------- ---------- ORCLPDB 2024/04/18 14:20:29 PLUG 318767104 ORCLPDB ORCLCDB 1 row selected.