Computer >> 컴퓨터 >  >> 프로그래밍 >> 데이터베이스

Oracle Database 12c Data Pump 개선 사항 완벽 정리: 1부

TriCore 원문 게시일: 2017년 6월 6일

Oracle® Data Pump(expdp, impdp)는 데이터베이스 객체를 데이터베이스 간에 내보내고(export) 가져오는(import) 유틸리티입니다. 대부분의 데이터베이스 관리자가 Data Pump에 대해 잘 알고 있지만, Oracle Database 12c에서 멀티테넌트(Multitenant) 아키텍처가 도입되면서 Data Pump의 데이터 내보내기·가져오기 방식에도 변화가 생겼습니다.

소개

이 시리즈는 두 부분으로 구성되어 있으며, 이번 1부에서는 Oracle Data Pump Export(expdp) 기술의 변경 사항과 이를 활용해 데이터베이스 아키텍처의 구성 요소를 내보내는 방법을 다룹니다.

Oracle Database 12c Data Pump 개선 사항 완벽 정리: 1부

이 글의 예제는 Oracle 메타데이터를 보관하는 컨테이너 데이터베이스(CDB)와 실제 사용자 데이터를 담고 있는 하나 이상의 플러거블 데이터베이스(PDB)를 중심으로 한 내보내기 작업에 초점을 맞춥니다.

PDB와 CDB에 대한 자세한 내용은 오라클 공식 문서인 "Introduction to the Multitenant Architecture(멀티테넌트 아키텍처 소개)"를 참고하시기 바랍니다.

전체 데이터베이스(Full Database) 내보내기 수행하기

전체 데이터베이스 내보내기를 실행한다고 해서 반드시 원하는 모든 데이터가 포함되는 것은 아닙니다. 많은 관리자가 루트 컨테이너(CDB)에 접속해 full 옵션으로 전체 내보내기를 수행하면 해당 CDB에 속한 모든 PDB까지 함께 백업될 것이라고 생각하지만, 실제로는 그렇지 않습니다. 루트 컨테이너에서 수행한 full export는 오직 루트 컨테이너에 속한 객체만 내보낼 뿐, PDB들의 객체는 포함되지 않습니다.

예를 들어, 네 개의 PDB가 연결된 PRODCDB라는 이름의 CDB가 있다고 가정해 보겠습니다. 다음 명령어로 이 데이터베이스들의 상세 정보를 확인할 수 있습니다.

sys@PRODCDB> select name,open_mode,con_id from v$pdbs;

위 명령어 실행 결과는 다음과 같습니다.

NAME                           OPEN_MODE      CON_ID
------------------------------ ---------- ----------
PDB$SEED                       READ ONLY           2
PRODPDB1                       READ WRITE          3
PRODPDB2                       READ WRITE          4
PRODPDB3                       READ WRITE          5
PRODPDB4                       READ WRITE          6

이 상태에서 full 옵션으로 내보내기를 시도하면 EXPDP는 루트 컨테이너에 속한 객체만 내보내며, 플러거블 데이터베이스들의 객체는 제외됩니다.

내보내기에 사용한 명령어는 다음과 같습니다.

[oracle@labserver ~]$ expdp directory=DPUMP dumpfile=exp_cdb_full_%U.dmp logfile=exp_cdb_full.log full=Y parallel=4

실행 결과 출력은 아래 코드 블록과 같습니다.

Export: Release 12.1.0.1.0 - Production on Thu Mar 26 23:10:41 2015

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

Username: / as sysdba

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database. Below are the steps for exporting of full database.

Starting "SYS"."SYS_EXPORT_FULL_01":  /******** AS SYSDBA directory=DPUMP dumpfile=exp_cdb_full_%U.dmp logfile=exp_cdb_full.log full=Y parallel=4
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 90.70 MB
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
. . exported "LBACSYS"."OLS$AUDIT_ACTIONS"               5.734 KB       8 rows
Processing object type DATABASE_EXPORT/ROLE
. . exported "LBACSYS"."OLS$DIP_EVENTS"                  5.515 KB       2 rows
. . exported "LBACSYS"."OLS$INSTALLATIONS"               6.937 KB       2 rows
Processing object type DATABASE_EXPORT/RADM_FPTM
. . exported "LBACSYS"."OLS$PROPS"                       6.210 KB       5 rows
. . exported "SYS"."DAM_CONFIG_PARAM$"                   6.507 KB      14 rows
. . exported "SYS"."TSDP_PARAMETER$"                     5.929 KB       1 rows
. . exported "SYS"."TSDP_POLICY$"                        5.898 KB       1 rows
. . exported "SYS"."TSDP_SUBPOL$"                        6.304 KB       1 rows
. . exported "SYSTEM"."REDO_DB"                          23.42 KB       1 rows
. . exported "WMSYS"."WM$ENV_VARS$"                      6.054 KB       5 rows
. . exported "WMSYS"."WM$EVENTS_INFO$"                   5.789 KB      12 rows
. . exported "WMSYS"."WM$HINT_TABLE$"                    9.429 KB      75 rows
. . exported "WMSYS"."WM$NEXTVER_TABLE$"                 6.351 KB       1 rows
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
. . exported "WMSYS"."WM$VERSION_HIERARCHY_TABLE$"       5.960 KB       1 rows
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
. . exported "WMSYS"."WM$WORKSPACES_TABLE$"              12.08 KB       1 rows
. . exported "WMSYS"."WM$WORKSPACE_PRIV_TABLE$"          6.539 KB       8 rows
. . exported "LBACSYS"."OLS$AUDIT"                           0 KB       0 rows
. . exported "LBACSYS"."OLS$COMPARTMENTS"                    0 KB       0 rows
. . exported "LBACSYS"."OLS$DIP_DEBUG"                       0 KB       0 rows
. . exported "LBACSYS"."OLS$GROUPS"                          0 KB       0 rows
. . exported "LBACSYS"."OLS$LAB"                             0 KB       0 rows
. . exported "LBACSYS"."OLS$LEVELS"                          0 KB       0 rows
. . exported "LBACSYS"."OLS$POL"                             0 KB       0 rows
Processing object type DATABASE_EXPORT/SCHEMA/ON_USER_GRANT
. . exported "LBACSYS"."OLS$POLICY_ADMIN"                    0 KB       0 rows
. . exported "LBACSYS"."OLS$POLS"                            0 KB       0 rows
. . exported "LBACSYS"."OLS$POLT"                            0 KB       0 rows
. . exported "LBACSYS"."OLS$PROFILE"                         0 KB       0 rows
. . exported "LBACSYS"."OLS$PROFILES"                        0 KB       0 rows
. . exported "LBACSYS"."OLS$PROG"                            0 KB       0 rows
. . exported "LBACSYS"."OLS$SESSINFO"                        0 KB       0 rows
. . exported "LBACSYS"."OLS$USER"                            0 KB       0 rows
. . exported "LBACSYS"."OLS$USER_COMPARTMENTS"               0 KB       0 rows
. . exported "LBACSYS"."OLS$USER_GROUPS"                     0 KB       0 rows
. . exported "LBACSYS"."OLS$USER_LEVELS"                     0 KB       0 rows
. . exported "SYS"."AUD$"                                    0 KB       0 rows
. . exported "SYS"."DAM_CLEANUP_EVENTS$"                     0 KB       0 rows
. . exported "SYS"."DAM_CLEANUP_JOBS$"                       0 KB       0 rows
. . exported "SYS"."TSDP_ASSOCIATION$"                       0 KB       0 rows
. . exported "SYS"."TSDP_CONDITION$"                         0 KB       0 rows
. . exported "SYS"."TSDP_FEATURE_POLICY$"                    0 KB       0 rows
. . exported "SYS"."TSDP_PROTECTION$"                        0 KB       0 rows
. . exported "SYS"."TSDP_SENSITIVE_DATA$"                    0 KB       0 rows
. . exported "SYS"."TSDP_SENSITIVE_TYPE$"                    0 KB       0 rows
. . exported "SYS"."TSDP_SOURCE$"                            0 KB       0 rows
. . exported "SYSTEM"."REDO_LOG"                             0 KB       0 rows
. . exported "WMSYS"."WM$BATCH_COMPRESSIBLE_TABLES$"         0 KB       0 rows
. . exported "WMSYS"."WM$CONSTRAINTS_TABLE$"                 0 KB       0 rows
. . exported "WMSYS"."WM$CONS_COLUMNS$"                      0 KB       0 rows
. . exported "WMSYS"."WM$LOCKROWS_INFO$"                     0 KB       0 rows
. . exported "WMSYS"."WM$MODIFIED_TABLES$"                   0 KB       0 rows
. . exported "WMSYS"."WM$MP_GRAPH_WORKSPACES_TABLE$"         0 KB       0 rows
. . exported "WMSYS"."WM$MP_PARENT_WORKSPACES_TABLE$"        0 KB       0 rows
. . exported "WMSYS"."WM$NESTED_COLUMNS_TABLE$"              0 KB       0 rows
. . exported "WMSYS"."WM$REMOVED_WORKSPACES_TABLE$"          0 KB       0 rows
. . exported "WMSYS"."WM$RESOLVE_WORKSPACES_TABLE$"          0 KB       0 rows
. . exported "WMSYS"."WM$RIC_LOCKING_TABLE$"                 0 KB       0 rows
. . exported "WMSYS"."WM$RIC_TABLE$"                         0 KB       0 rows
. . exported "WMSYS"."WM$RIC_TRIGGERS_TABLE$"                0 KB       0 rows
. . exported "WMSYS"."WM$UDTRIG_DISPATCH_PROCS$"             0 KB       0 rows
. . exported "WMSYS"."WM$UDTRIG_INFO$"                       0 KB       0 rows
. . exported "WMSYS"."WM$VERSION_TABLE$"                     0 KB       0 rows
. . exported "WMSYS"."WM$VT_ERRORS_TABLE$"                   0 KB       0 rows
. . exported "WMSYS"."WM$WORKSPACE_SAVEPOINTS_TABLE$"        0 KB       0 rows
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/DIRECTORY/DIRECTORY
. . exported "SYS"."KU$\_USER_MAPPING_VIEW"               6.054 KB      36 rows
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
. . exported "SYSTEM"."SCHEDULER_JOB_ARGS"               8.640 KB       4 rows
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/EARLY_POST_INSTANCE_IMPCALLOUT/MARKER
. . exported "ORDDATA"."ORDDCM_DOCS"                     252.9 KB       9 rows
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE
. . exported "SYSTEM"."SCHEDULER_PROGRAM_ARGS"           10.18 KB      22 rows
. . exported "SYS"."AUDTAB$TBS$FOR_EXPORT"               5.929 KB       2 rows
. . exported "SYS"."NACL$\_ACE_EXP"                       9.906 KB       1 rows
. . exported "SYS"."NACL$\_HOST_EXP"                      6.890 KB      1 rows
. . exported "WMSYS"."WM$EXP_MAP"                        7.695 KB       3 rows
. . exported "SYS"."DBA_SENSITIVE_DATA"                      0 KB       0 rows
. . exported "SYS"."DBA_TSDP_POLICY_PROTECTION"              0 KB       0 rows
. . exported "SYS"."FGA_LOG$FOR_EXPORT"                      0 KB       0 rows
. . exported "SYS"."NACL$\_WALLET_EXP"                        0 KB       0 rows
. . exported "C##ABBAS"."T"                              72.67 MB  667728 rows
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/NORMAL_POST_INSTANCE_IMPCALLOU/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/STATISTICS/MARKER
Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCOBJ
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/AUDIT_UNIFIED/AUDIT_POLICY_ENABLE
Processing object type DATABASE_EXPORT/AUDIT
Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER
Master table "SYS"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_FULL_01 is:
  /backup/exp/prodcdb/exp_cdb_full_01.dmp
  /backup/exp/prodcdb/exp_cdb_full_02.dmp
  /backup/exp/prodcdb/exp_cdb_full_03.dmp
Job "SYS"."SYS_EXPORT_FULL_01" successfully completed at Thu Mar 26 13:49:26 2015 elapsed 0 00:08:34

출력 결과를 보면 full 옵션을 사용했음에도 루트 컨테이너에 속한 객체만 내보내진 것을 확인할 수 있습니다. 안타깝게도 모든 PDB와 루트 컨테이너를 한 번에 함께 내보내는 방법은 존재하지 않습니다.

CDB 내보내기 수행하기

CDB 또는 루트 데이터베이스의 내보내기는 주로 PDB를 호스팅하는 역할만 하기 때문에 일반적으로 필요하지 않습니다. 그럼에도 불구하고 이 작업이 꼭 필요하다면 새로운 CDB를 생성하고 기존 PDB를 연결(plug)하는 방식으로 처리할 수 있습니다. 이런 경우 대부분의 관리자가 가장 관심을 두는 부분은 바로 공통 사용자(common user)와 롤(role)의 내보내기입니다.

예를 들어, CDB에 다음과 같은 공통 사용자가 있다고 가정해 보겠습니다.

sys@PRODCDB> select USERNAME, COMMON from dba_users where common='YES' and oracle_maintained='N';

USERNAME   COM
---------- ---
C##ABBAS   YES

CDB에 속한 공통 사용자와 롤을 내보내려면 다음 명령어로 CDB에 대한 EXPDP를 시작하면 됩니다.

[oracle@labserver ~]$ expdp directory=DATA_PUMP_DIR dumpfile=common_usr_cdb.dmp logfile=common_usr_cdb.log schemas=C##ABBAS

명령어 실행 결과는 다음과 같습니다.

Export: Release 12.1.0.1.0 - Production on Thu Mar 26 23:45:26 2015

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

Username: / as sysdba

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "SYS"."SYS_EXPORT_SCHEMA_01":  /******** AS SYSDBA directory=DATA_PUMP_DIR dumpfile=common_usr_cdb.dmp logfile=common_usr_cdb.log schemas=C##ABBAS
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 88 MB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
. . exported "C##ABBAS"."T"                               72.67 MB  667728 rows
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
  /backup/exp/prodcdb/common_usr_cdb.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at Thu Mar 26 14:16:53 2015 elapsed 0 00:01:16

이상적으로는 루트 컨테이너에 공통 사용자의 데이터가 존재하는 경우가 아니라면 루트 컨테이너 객체를 내보낼 필요가 없습니다.

결론

이 글에서 소개한 단계들을 따라 하면 Data Pump 12c의 새로운 기능을 활용해 더욱 손쉽게 데이터를 내보낼 수 있습니다. 2부에서는 Data Pump가 PDB에 적용하는 제약 조건과 PDB를 내보내는 방법을 다룰 예정입니다.

참고 자료

이 글은 아래 문서를 참고하여 작성되었습니다.

  • Changes in This Release for Oracle Database Utilities (Oracle Database 유틸리티 릴리스 변경 사항)

궁금한 점이나 의견이 있다면 피드백 탭을 통해 남겨주세요.