DATAPUMP 사용시 ENCRYPTION 옵션 사용을 통하여 암호화를 진행 할 수 있다.

ENCRYPTION 의 옵션은 ALL, DATA_ONLY, ENCRYPTED_COLUMNS_ONLY, METADATA_ONLY and NONE 이 있으며,

ENCRYPTION_ALGORITHM 은 AES128(기본 값), AES192 and AES256 이 있다.

 

아래는 test_20170119 테이블을 ENCRYPTION 옵션으로 export 하는 예제이다.

 expdp \" / as sysdba\" dumpfile=MST_1st.dmp logfile=MST_1st.log directory=EXP_HOON tables=\(hoon.test_20170119\) ENCRYPTION=DATA_ONLY ENCRYPTION_MODE=PASSWORD ENCRYPTION_PASSWORD=tyvld

Export: Release 11.2.0.2.0 - Production on Thu Jan 19 11:32:16 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01":  "/******** AS SYSDBA" dumpfile=MST_1st.dmp logfile=MST_1st.log directory=EXP_HOON tables=(hoon.test_20170119) ENCRYPTION=DATA_ONLY ENCRYPTION_MODE=PASSWORD ENCRYPTION_PASSWORD=********
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "HOON"."TEST_20170119"                      44.07 KB     660 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
  /home/oracle/DBA/hoon/tmp/MST_1st.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 11:32:25

 

이제 반대로 import 해보자

 impdp \" / as sysdba\" dumpfile=MST_1st.dmp directory=EXP_HOON

Import: Release 11.2.0.2.0 - Production on Thu Jan 19 11:33:10 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39174: Encryption password must be supplied.

패스워드를 지정하지 않아 import 진행이 되지 않는다.

 

패스워드를 지정하고 다시 import 해보자.

 impdp \" / as sysdba\" dumpfile=MST_1st.dmp directory=EXP_HOON ENCRYPTION_PASSWORD=tyvld

Import: Release 11.2.0.2.0 - Production on Thu Jan 19 11:33:27 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01":  "/******** AS SYSDBA" dumpfile=MST_1st.dmp directory=EXP_HOON ENCRYPTION_PASSWORD=********
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "HOON"."TEST_20170119"                      44.07 KB     660 rows
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at 11:33:30

정상적으로 테이블이 import 되었다.

 

ENCRYPTION 옵션을 잘 황용하면 데이터 백업에 대한 보안을 강화 할 수 있다.

 


 

 

 

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                                                                        Datapump

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

- 10g 이전 버전에서 export/import는 열악한 속도를 불구하고 마이그레이션을 위해 사용한유틸리티였다.
   (일반적으로 insert into 명령을 사용해 대상 테이블에 삽입하기 때문에 import process는 속도가 느렸다.)
- Datapump는 Oracle 10g 유틸리티로 데이터의 이동 기능이 크게 향상되었다.
- Datapump는 일반적인 SQL을 사용하는 대신 API로 load, unload를 한다.

- export/import와 Datapump는 서로 호환되지 않는다.

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. Datapum export/import의 장점━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 1) JOB 컨트롤 가능
     - interactive mode로 작업을 통제할수 있다.
     - 작업의 중단 및 재시작 할수 있으며 동적으로 dump file을 할당 가능.
     - 에러 발생후 작업은 멈추지만 언제든 수정하여 재수행 할수있음.

2) 병렬수행 지원
    - parallel 파라메터를 이용하여 datapump작업의 프로세스를 병렬화 할수있음.
    - 병렬된 프로세스는 여러개의 데이터 파일에 각각 데이터를 쓰거나
    - 여러개의 데이터 파일로부터 데이터를 읽어 데이터베이스에 저장 가능하다.
    - parallel 수행이 가능 함으로 더욱 속도가 향상 됨.

3) 작업에 필요한 공간 예측 가능
    - estimate 파라메터를 이용하여 작업에 필요한 디스크 공간 예측 가능

4) 원격지 수행
    - DB link를 사용하여 원격지에 데이터를 import/export 할수있다.

5) Remapping
    - user 스키마, tablespace, datafile 등의 정보를 import/export시 변경 할수 있다.
    - 이 기능은 데이터 마이그레이션 시 보다 많은 유연성을 제공한다.

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2. data access methods (oracle이 자동으로 판단하여 수행하는 mode)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 1) direct-path

  메모리를 거치지 않고 파일에 직접 쓰는 방법.
  - 메모리 사용이 적고 속도가 빠르며, 데이터 변환에 시간이 걸리지 않는다.

  direct-path가 되지 않는 경우에는??
  - cluster table인 경우
  - table에 active된 triger가 존재 할 경우
  - 글로벌 인덱스를 가진 테이블이 하나의 파티션에 존재 할 경우
  - LOB 칼럼에 있는 domain index
  - insert 모드에서 fine-grained access control이 enable인 경우
  - BFILE을 가진 테이블인 경우

 

 2) External table
    메타 데이터를 데이터베이스에 저장하고 데이터는 파일시스템에 존재함.
    - 대용량 데이터를 export/import 할때 사용함.

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

3. Datapump의 사전 설정
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 - Directory Object 생성
 - 읽기 권한과 쓰기 권한이 필요
 - 다양한 옵션과 datapump의 모든 기능을 사용 하려면 EXP_FULL_DATABASE, IMP_FULL_DATABASE role을 부여함.
 
  1) 사용자 생성
   create user [ user name ] identified by [ password ]
   default tablespace [ tablespace name ]
   temporary tablespace temp;

 

  2) 권한 부여
   grant connect, resource to [ user name ]

 

  3) 모든 테이블에 대한 select 권한 부여
   grant select any table to [ user name ]

 

  4) EXP_FULL_DATABASE, IMP_FULL_DATABASE 권한 부여
   grant EXP_FULL_DATABASE, IMP_FULL_DATABASE to [ user name ]

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4. Datapump 파일 오브젝트

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 1. Datapump가 사용하는 파일
     - dump file : table로부터 data 또는 meta-data를 load하여 저장된 파일
     - log file    : datapump 작업 중에 발생하는 메세지나 결과를 기록하는 파일
     - SQL file  : datapump는 sqlfile이라는 옵션을 사용한다.
                       이 옵션을 사용할 경우 datapump import 작업이 수행되는 동안
                       DDL 문을 수행할 수 있게 해주는 옵션이다.

 
2. Datapump directory object
    Datapump는 디렉토리 오브젝트를 참조하여 dump 파일을 쓰게 된다.
    Datapump사용시 디렉토리에 대한 사용자의 권한까지 설정할수있다.

 

  1 ) 사용중인 디렉토리 오브젝트의 조회
        select * from dba_directories;

 

  2 ) 디렉토리 오브젝트 추가
      create directory [ directory_name ] as '/[ 경로명 ]';

 

  3 ) 디렉토리 오브젝트에 대한 권한 설정
      grant read,write on directory [ directory_name ] to [ user name ]
      // 해당 유저에 대해 해당 디렉토리에 대한 쓰기 및 읽기 권한을 할당.
         export 받을때 해당 유저는 해당 경로의 덤프파일에 export된 덤프 파일을 저장.
         ex) expdp [ user name ]/[ password ] directory=[ directory_name ] tables=[ table_name ] dumpfile=[ 생성할 덤프 파일명 ]

 

  4 ) default directory 설정
      datapump를 사용할대마다 디렉토리 지정을 하지 않고 묵시적으로 사용하려면
      운영체제 환경 변수에 DATA_DUMP_DIR을 만들고 그 값으로 디렉토리 오브젝트 명을 입력하면 됨.
      $ export DATA_DUMP_DIR [ directory_name ]

      설정 했다면 아래와 같이 사용 가능
      $ expdp [ user name ]/[ password ] dumpfile=[ dump 파일명 ] tables=[ table_name ]

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

5. datapump 사용 법
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 - commend line
  $ expdp [ user name ]/[ password ] directory=[ directory_name ] tables=[ table_name ] dumpfile=[ 생성할 덤프 파일명 ]

 - parameter file을 이용 (확장자 상관 없음)
  1) parameter file 생성 내용
      schemas=[ user_name ]
      directory=[ directory_name ]
      dumpfile=[ 생성 될 dumpfile 명 ]
      logfile=[ 생성 될 logfile 명 ]

  2) commend line에서 사용
   $ expdp [ user_name ]/[ password ] parfile=[ parameter file ]

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6. Datapump Export Parameter

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

 - 파일 및 디렉토리 관련 파라메터

  1) DIRECTORY : 디렉토리 오브젝트를 참조하는 DIRECTORY 파라메터를 이용해
                          덤프 파일의 위치 및 로그 파일의 위치를 지정 가능

 

  2) DUMPFILE  : EXPORT 받아 파일 시스템에 저장될 덤프파일의 이름을 지정하는 파라메터
                         - %U 를 사용해서 여러 개의 덤프 파일을 구분 가능
                            DUMPFILE=AAA_%U.DMP로 파라미터를 정의.
                           %U 부분이 자동 증가하여 파일을 구분하게 해줌.
                           %U의 범위는 01~99까지
                         - ','를 이용하여 여러개의 파일명을 구분
                            DUMPFILE=AAA_01.DMP, AAA_02.DMP, AAA_03.DMP 과 같이 정의 가능
                            만약 DUMPFILE 파라메터를 지정하지 않으면 EXPDAT.DMP 라는 파일명으로 ORACLE이 자동 선언 함.

 

  3) FILESIZE  : EXPORT 받는 1개 파일의 최대 SIZE를 지정 하는 파라메터.
                       FILESIZE=N [ BYTES | KILOBYTES | MEGABYTES | GIGABYTES ]

 

  4) PARFILE   : 파일에 파라메터를 저장하고 DATAPUMP를 이용 할때 마다 참조 가능.
                       PARFILE=[ FILENAME.PAR ]  

 

  5) LOGFILE AND NOLOGFILE : 로그파일명을 지정하는 파라메터.
                                              LOGFILE=[ LOGFILE_NAME ]
                                             지정 안할시 EXPORT.LOG라는 파일명으로 로그가 남음
                                             로그 파일을 남기고 싶지 않다면 NOLOGFILE 파라메터 사용

 

  6) COMPRESSION : 사용하지 않을 경우 EXPORT 시에 메타데이터를 압축하여 파일에 저장함.
                                COMPRESSION 파라메터는 METADATA_ONLY 와 NONE 두개의 옵션이 있음
                               $ EXPDP ~~~~~~~~~~~~~~~ COMPTRESSION=[ NONE, METADATA_ONLY ]

 

- EXPORT 모드 관련 파라메터
         1) full export mode
                  - full 파라메터를 사용하며 db전체를 export 할수 있다.
                  - EXP_FULL_DATABASE role이 사용자에게 부여 되어 있어야 한다.

 

         2) schema mode
                  - schemas 파라메터를 사용하며 하나의 유저가 소유하고 있는 데이터 및 오브젝트 전체를 export 할수 있다.

 

         3) tablespace mode
                  - tablespace 파라메터를 사용하며 하나의 tablespace에 속한 모든 table을 export 할수있다.
                  - TRANSPORT_TABLESPACES 파라메터를 이용하면 tablespace의 meta-data까지
                    export 되어 다른 서버에 import 하게 되면 tablespace 및 table이 자동 생성된다.

 

         4) table mode
                   - tables 파라메터를 사용하며 하나 이상의 테이블을 export 할때 사용한다.

 

         5) TRANSPORT_FULL_CHECK
                  - EXPORT 시 TABLESPACE내에 존재하는 테이블과 인덱스의 의존성 검사 유무 설정
                  - Y 또는 N 만을 허용하는 파라메터
                  - TRANSPORT_TABLESPACE와 같이 사용 됨.
                              1. Y 할 경우 반드시 테이블과 인덱스가 같은 TABLESPACE에 존재 해야함.
                              2. N 일 경우 TABLESPACE 내에 테이블만 있을시 작업은 성공하나,
                                  인덱스만 있고 테이블이 없다면 작업은 실패함.

                  - EXPORT 필터링 관련 파라메터
                    : 어떤 데이터를 EXPORT 된 파일에 포함 시킬지 결정 하는 파라메터.

 

                       5-1) CONTENT : 3개의 옵션을 가질 수 있으며 옵션들은 다음과 같음.
                                              $ EXPDP ~~~~~~~~~~~~ CONTENT=[ ALL | DATA_ONLY | METADATA_ONLY ]

                                              - ALL                     : 테이블과 메터데이터를 포함한 모든것을 포함시키는 옵션
                                              - DATA_ONLY          : 테이블 데이터만 포함 시키겠다는 옵션
                                              - METADATA_ONLY : 메타 데이터만 포함 시키겠다는 옵션.
                                                                              이경우 EXPORT 된 파일을 이용해 다른 DB에 IMPORT 할 경우 
                                                                              테이블 구조만 생성되게 함.

 

                      5-2) EXCLUDE AND INCLUDE : 원하는 오브젝트를 선택해서 받을수 있음. 조건식으로 사용 가능
                                                                   $ [ exclude | include ]=object_name:조건 형식
                                                                   EXCLUDE : 해당 오브젝트를 제외한것들만.
                                                                   INCLUDE : 해당 오브젝트만.

 

                                     예1) SCOTT 유저와 관련된 모든것을 EXPORT 하고 싶다. 근데 'BONUS' 테이블은 제외하고 싶다.
                                            $ EXPDP ~~~~~~~~~~~~~~~~~~ schemas=scott exclude=TABLE:"\='BONUS'"
                                     예2) SCOTT 유저와 관련된 모든것을 EXPORT 하고 싶다. 근데 'EMP' 테이블의 인덱스는 싫다.
                                            $ EXPDP ~~~~~~~~~~~~~~~~~~ schemas=scott exclude=INDEX:\"='EMP%'\"

                                     예3) SCOTT 유저와 관련된 모든것을 EXPORT 하고 싶다. 근데 'dept'로 시작하는 인덱스는 제외하고 싶다.
                                            $ EXPDP ~~~~~~~~~~~~~~~~~~ schemas=scott exclude=INDEX:"like 'dept%'"
                                     예4) SCOTT 유저의 'DEPT'와 'EMP' 테이블과 인덱스를 EXPORT 하고 싶다.
                                            $ EXPDP ~~~~~~~~~~~~~~~~~~ schemas=scott INCLUDE=INDEX,TABLE:"IN ('DEPT','EMP')"

                                     예5) SCOTT 유저와 관련된 모든것을 EXPORT 하고 싶다. 근데 FUNCTION은 제외하고 싶다.
                                            $ EXPDP ~~~~~~~~~~~~~~~~~~ schemas=scott exclude=FUNCTION


 

                       5-3) QUERY : 테이블 내 데이터중 조건에 만족하는 데이터만 EXPORT 하는 파라메터
                                           예 ) $ expdp ~~~~~~~~~~~~ QUERY=SCHEMA.TABLE:" where sal>1200 "


                       5-4) SAMPLE : 테이블의 데이터를 EXPORT 할때 %를 정하여

                                             지정된 %만큼 데이터를 샘플링 해서 뽑을때 사용하는 옵션.
                                              입력 가능한 퍼센트 범위 : 0.000001 ~ 100
                                              예 ) $ expdp ~~~~~~~~~~~~~~~~~~~~~ SAMPLE=scott.emp:20

 

- network_link 파라메터
   : 원격지 db에 있는 데이터에 접근해 로컬 db에 export된 덤프 파일을 저장할때 사용
     DB_LINK를 통해 export 할수있으며 NETWORK_LINK 파라메터를 사용하려면
     원격지 DB의 테이블에 대한 DB_LINK를 만들어 놓아야한다.
     예 ) $ expdp ~~~~~~~~~~~~~~~~~~~ NETWORK_LINK[ EMP@orcl ]~~~~~~
 
- Password 관련 파라메터
   : export 데이터중 ENCRYPTION_PASSWORD 파라메터를 이용하여 export시에 암호를 설정 할수있다.
     암호 설정 후에 import시 password를 물어보게 된다.
     ## 전자 지갑 설정을 해줘야 가능하다.
     예 ) $ expdp ~~~~~~~~~~~~~~~~~ ENCRYPTION_PASSWORD=[ PASSWORD ]

 

- JOB 관련 파라메터
         1 ) JOB : JOB 파라메터에 주어진 이름으로 등록한다. 작업 마스터 테이블에 작업명이 등록되고 
                       해당 작업의 정보를 JOB 파라메터에 등록된 이름으로 조회 할수있다.
                       등록을 하지 않으면 오라클에서 자동할당 한다.

 

          2 ) STATUS : export 작업시 작업의 진행상태를 볼때 사용함.
                             STATUS=10 으로 설정하면 10초 간격으로 갱신하여 보여줌(기본값은 0)

 

          3 ) FLASHBACK_SCN : 파라메터에 설정된 SCN 기준, 이전까지의 상태를 받게 됨
                                           예 ) expdp ~~~~~~~~~~~~~~~~~~~ FLASHBACK_SCN=333444

 

          4 ) FLASHBACK_TIME : SCN 번호 대신에 TIMESTAMP 형식의 값을 가지며 TO_TIMESTAMP 함수를 사용하여 설정함.
                                            파라메터에 지정된 시간까지의 변경사항만 EXPORT 함.

 

           5 ) PARALLEL : 프로세스 숫자를 늘려 수행하여 작업의 속도 향상. 기본 값은 1.
                                   PARALLEL 지정 숫자만큼 dumpfile을 지정 해주어야 하며
                                   %U 사용시 지정된 숫자 만큼 자동으로 dumpfile을 생성함.

                                   예 ) expdp ~~~~~~~~~~~~~~~ dumpfile=export%u.dmp PARALLEL=3

 

            6 ) ATTACH : interactive mode로 들어갈수 있게 함.
                                interactive mode 진입은 2가지 방법이 있음
                               관련 parameter : dba_datapump_jobs, user_datapump_jobs, DBA_DATAPUMP_SESSIONS   

 

                               예1 ) expdp ~~~~~~~~~~~~~~~~~~~~~~~~
                                      작업 로그가 쭉 나올때 Crtl + C 를 눌러주면
                                      export> _       처럼 프롬프트 상태로 진입.
                               예2 ) expdp ~~~~~~~~~~~~ ATTACH=scott.JOB
                                       원하는 작업의 interactive mode로 들어감.

                               위와 같이 현재 수행중인 작업을 ineractive mode로 진입해 컨트롤 할수있음

                               =======================================================================
                                           명령어         |                       설명 
                               =======================================================================
                                      ADD_FILE         |   덤프파일을 추가
                                CONTINUE_CLIENT  |   interactive mode에서 Logging Mode로 전환
                                     EXIT_CLIENT      |   Client Session을 종료후 JOB 상태에서 벗어남
                                                   HELP   |   interactive mode 도움말
                                              KILL_JOB  |   작업을 삭제
                                           PARALLEL   |   현재 수행중인 작업의 프로세스 개수를 조정
                                          START_JOB  |   실패 또는 중단된 작업을 재 시작
                                              STATUS   |   현재 작업상태를 모니터링 갱신 시간 설정
                                           STOP_JOB   |   작업을 중단하고 Client 종료
                              =======================================================================

 

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

7. Datapump Import mode

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- dumpfile을 DB내의 테이블로 옮기는 작업
   impdp 명령어로 사용하며, export 작업과 마찬가지로 커맨드라인, 파라메터파일, interactive mode로 사용

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

8. Datapump Import Parameter

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 1 ) 파일 및 디렉토리 관련 파라메터
     impdp [ username/password ] DIRECTORY=[ directory_name ] DUMPFILE=[ dumpfile_name ] SCHEMAS=[ user_name ]

 

2 ) 필터링 관련 파라메터
     필터링 관련 파라메터는 CONTENT, INCLUDE, EXCLUDE, TABLE_EXISTS_ACTION 파라메터가 있다.
     이중 TABLE_EXISTS_ACTION 파라메터만 Import 작업시에 사용할수있다.
  
             - CONTENT, INCLUDE, EXCLUDE 는 생략.. ( export의 CONTENT, INCLUDE, EXCLUDE 참고할것 )

             - TABLE_EXISTS_ACTION : Import 시 table안의 data는 다르지만 테이블 이름이 같은 테이블이 존재할수있다.  
                이러한 경우에 사용 되는 파라메터이며 
                SKIP, APPEND, TRUNCATE, REPLACE의 값을 가질수 있다.
                예 ) impdp ~~~~~ TABLE_EXISTS_ACTION=[ SKIP, APPEND, TRUNCATE, REPLACE ]
     
                              - SKIP            : 같은 테이블을 만나면 지나치고 다음 테이블을 Import (default)
                              - APPEND      : 같은 테이블을 만나면 기존 테이블에 데이터를 추가하여 Import (존재하는 row는 skip)
                              - TRUNCATE  : 같은 테이블을 만나면 기존 테이블을 TRUNCATE 하고 Import (존재하는 row는 delete)
                              - REPLACE    : 같은 테이블을 만나면 기존 테이블을 DROP 하고 테이블을 재생성 한후 데이터를 Import

 

 3 ) JOB 관련 파라메터
      : JOB_NAME, STATUS, PARALLEL 파라메타가 있으며 Export와 사용 방법은 동일하다.
 
 4 ) REMAPPING 관련 파라메터
     : REMAP_SCHEMA, REMAP_DATAFILE, REMAP_TABLESPACE가 있으며 Import시에 많은 유연성을 제공한다.

 

            - REMAP_SCHEMA : A 유저 스키마로 Export 받은 데이터를 B 유저 스키마로 Import 할때 사용
                                           예 ) impdp ~~~~~~~~~~~~~~~~ SCHEMAS=SCOTT REMAP_SCHEMA=SCOTT:HR
                                           명령 수행후 HR 유저 소유로 테이블이 등록된다.

 

            - REMAP_DATAFILE : 전체 데이터베이스가 Export 된 dumpfile에는 Datafile 정보까지 포함된다.
                                            하지만 다른 시스템의 디스크 경로 상에는 존재하지 않는 경로이기 때문에
                                            import에는 실패하는 한다. 이러한 경우에 사용하는 파라메터이다.
                                            Export된 dumpfile이 datafile 정보를 포함한 경우에만 해당된다.
                                            예 ) impdp ~~~~~~~~~~~~~~~~~ REMAP_DATAFILE '/db1/data/lvol01':'/db2/data/lvol01',
                                                  '/db1/data/lvol02':'/db2/data/lvol02'

 

            - REMAP_TABLESPACE : Export 받은 데이터가 속한 tablespace에서 다른 tablespace로
                                                  REMAPPING 하는 경우에 사용하는 파라메터
                                                  예 ) impdp ~~~~~~~~~~~~~~~~~ REMAP_TABLESPACE='scoot_tsb':'hr_tbs'

 

 5 ) NETWORK_LING 관련 파라메터
     : Export와 마찬가지로 DB_LINK를 통해 원격지 DB에 대한 import 작업을 수행가능함.

 

 6 ) INTERACTIVE MODE 파라메터
     : Export와 마찬가지로 진입하여 작업을 통제 할수 있음.

 

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
9. Datapump Monitering

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
: 작업의 진행 경과와 작업속성들 그리고 얼마나 많은 작업이 존재하는지 파악 가능.

 

1 ) 관련 조회 테이블 및 VIEW
     - DBA_DATAPUMP_JOBS : 실행중인 작업의 속성을 볼수있는 테이블
                                             SQL > SELECT * FROM DBA_DATAPUMP_JOBS;     로 조회 가능
                                             해당 컬럼 - OWNER_NAME : DB 작업 계정

      - JOB_NAME   : 작업의 명칭
      - JOB_MODE   : FULL, TABLE, INDEX, TABLESPACE 등이 있음
      - STATE          : EXECUTING, DEFINING, UNDERFINED, NOT RUNNING 등이 있음

 

JOB이 비정상 작동할때

 SQL> select owner_name, job_name, state from dba_datapump_jobs;

 조회하여 다음 명령을 수행

SQL> drop table [ user_name ].[ job_name ] purge;

 

      - Pump Session 확인 : SQL > select s.sid, s.serial#
                                                 from v$session s, dba_datapump_sessions p
                                                where s.saddr = p.saddr;
                                       로 조회 하면 Datapump를 통해 수행 중인 모든 세션과 상태를 모니터 할수있음

 

      - DATA PUMP의 모니터링 : SQL > select opname, target_desc, sofar,totalwork,(sofar/totalwork*100) percentage
                                                       from v$session_longops;
                                                       opname          : JOB name과 같음
                                                       TOTALWORK   : 총 수행해야할 용량. MB 단위
                                                        sofar             : 현재 수행한 용량. MB 단위
                                                        targer_desc    : 작업의 종류. IMPORT/EXPORT가 값이 됨.

 

[출처] http://blog.naver.com/gwgwg?Redirect=Log&logNo=60073888603

'OraclE' 카테고리의 다른 글

db link 사용시 lob타입 테이블 문제  (0) 2012.08.03
append 힌트의 효용성  (0) 2012.06.26
DBMS_STATS  (0) 2012.06.13
DBMS_STATS 패키지  (0) 2012.06.13
tuning block space usage  (0) 2012.06.13

DataPump *

 

 

- Oracle Database data와 metadata의 이동을 위한 Tool

  Oracle 9i까지 사용되던 export, import 유틸리티보다 더욱더 향상된 성능을 가지고 있다.

 

DataPump 준비 단계

 

-- DBA 권한 이상으로 로그인
CONNECT /as sysdba

 

-- DataPump를 위한 Directory 생성
CREATE OR REPLACE DIRECTORY dpump_dir AS '/oracle/app/oracle/product/10.2.0/datapump';

 

-- 생성한 Directory에 Read, Write 권한 할당
GRANT READ, WRITE ON DIRECTORY dpump_dir TO system;

 

-- Directory 확인
set linesize 200
set pagesize 100
col owner format a10
col privilege format a10
col directory_path format a50
SELECT d.owner, directory_name, grantee, privilege, directory_path
FROM user_tab_privs t, all_directories d
WHERE t.table_name(+)=d.directory_name;

 

DataPump 수행 단계


-- DataPump 수행
expdp system/oracle directory=dpump_dir dumpfile=full_%U.dmp logfile=full_%U.log job_name=expdp_full full=y


system/oracle : userid/password
dpump_dir : directory(※ 절대경로가 아님)

full_%U.dmp : dumpfile => parallel 옵션과 함께 사용시 파일명에 %U 사용한다.
full_%U.log : logfile
expdp_full  : job_name

full=y : DB 전체 FULL export

-- 작업 중지

현재 Command-Line 모드로 expdp 수행중에 Ctrl+C를 누른 상태,

즉, "Export>" 프롬프트 상태가 Interactive-Command Interface 모드이다.

이상태에서 stop_job을 수행해야지 작업이 중단된다.

 

Export> stop_job


※ 작업이 중단되더라도 나중에 다시 실행 및 취소가 가능하다.(완전 삭제는 kill_job)

※ Ctrl+C를 누른 상태로는 서버기반이기 때문에 취소되지 않고 작업이 계속 진행중이다

 

-- DataPump 작업 확인
SELECT * from dba_datapump_jobs;

 

-- 중지된 Job 재실행하기
attach=job_name으로 실행중이거나 중지중인 Job에 다시 접속할 수 있다.

expdp system/oracle attach=expdp_full
Export> start_job

 

-- 작업내용 표시
Export> continue_clinet

 

 

Remote DB Export 받기

 

DB Link 생성 및 확인

-- Database Link 생성
CREATE DATABASE LINK expdp_net01 CONNECT TO system IDENTIFIED BY oracle USING 'EXPDP_DOG13'

-- DB Link 확인
col owner for a10
col db_link for a15
col username for a10
col host for a15
SELECT * FROM dba_db_links;


-- Local DB쪽에 파일 남기기
expdp system/oracle NETWORK_LINK=expdp_net01 directory=dpump_dir dumpfile=expdp_net01_%U.dmp logfile=expdp_net01.log
job_name=net_expdp_full full=y

 

※ Long TYPE 등 NETWORK_LINK로 받아지지 않는 것도 있으므로 확인

 

-- Remote DB쪽에 파일 남기기
expdp system/oracle@EXPDP_DOG13 directory=dpump_dir dumpfile=expdp_net01_%U.dmp logfile=expdp_net01.log
job_name=net_expdp_full full=y

 

※ DB Link와 Network_Link를 이용하면 Local DB쪽에 dmp파일이 생성되며, Network Alias만 이용하면

Remote DB쪽에 dmp파일이 생성된다.

 

 

참고문서 : DBworks PDF 문서

[출처] DataPump|작성자


'OraclE' 카테고리의 다른 글

오라클 analyze 자동화  (0) 2008.11.06
Listener.log 파일 남기지 않는 방법  (0) 2008.10.22
Transportable Tablespaces  (0) 2008.10.17
sqlnet ip 제한  (0) 2008.10.07
archive file 자동 삭제 스크립트-window  (0) 2008.10.07

Transportable Tablespaces

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Overview
  2. Introduction to Transportable Tablespaces
  3. Using Transportable Tablespaces


Overview

Oracle's Transportable Tablespace is one of those much awaited features that was introduced in Oracle8i (8.1.5) and is commonly used in Data Warehouses (DW). Using transportable tablespaces is much faster than using other utilities like export/import, SQL*Plus copy tables, or backup and recovery options to copy data from one database to another.

This article provides a brief introduction into configuring and using transportable tablespaces.

Introduction to Transportable Tablespaces

Before covering the details of how to setup and use transportable tablespaces, let's first discuss some of the terminology and limitations to provide us with an introduction.

  • The use of transportable tablespaces are much faster than using export/import, SQL*Plus copy tables, or backup and recovery options to copy data from one database to another.

  • A transportable tablespace set is defined as two components:

    • All of the datafiles that make up the tablespaces that will be moved.

      AND

    • An export that contains the data dictionary information about those tablespaces.

  • COMPATIBLE must be set in both the source and target database to at least 8.1.

  • When transporting a tablespace from an OLTP system to a data warehouse using the Export/Import utility, you will most likely NOT need to transport TRIGGER and CONSTRAINT information that is associated with the tables in the tablespace you are exporting. That is, you will set the TRIGGERS and CONSTRAINTS Export utility parameters equal to "N".

  • The data in a data warehouse is inserted and altered under very controlled circumstances and does not require the same usage of constraints and triggers as a typical operational system does.

  • It is common and recommended though that you use the GRANTS option by setting it to Y.

  • The TRIGGERS option is new in Oracle8i for use with the export command. It is used to control whether trigger information, associated with the tables in a tablespace, are included in the tablespace transport.

Limitations of Transportable Tablespaces:

  • The transportable set must be self-contained.

  • Both the source and target database must be running Oracle 8.1 or higher release.

  • The two databases do not have to be on the same release

  • The source and target databases must be on the same type of hardware and operating-system platform.

  • The source and target databases must have the same database block size.

  • The source and target databases must have the same character set.

  • A tablespace with the same name must not already exist in the target database.

  • Materialized views, function-based indexes, scoped REFs, 8.0 compatible advanced queues with multiple-recipients, and domain indexes can't be transported in this manner. (As of Oracle8i)

  • Users with tables in the exported tablespace should exist in the target database prior to initiating the import. Create the user reported by the error message.

    Explanation: The metadata exported from the target database does not contain enough information to create the user in the target database. The reason is that, if the metadata contained the user details, it might overwrite the privileges of an existing user in the target database.

    (i.e. If the user by the same name already exists in the target database)

    By not maintaining the user details, we preserve the security of the database.

Using Transportable Tablespaces

In this section, we finally get to see how to use transportable tablespaces. Here is an overview of the steps we will perform in this section:

  1. Verify that the set of source tablespaces are self-contained
  2. Generate a transportable tablespace set.
  3. Transport the tablespace set
  4. Import the tablespaces set into the target database.


In this example, we will be transporting the tablespaces, "FACT1, FACT2, and FACT_IDX" from a database named DWDB to REPORTDB. The user that owns these tables will be "DW" and password "DW".


Verify Self-Contained Status with the DBMS_TTS Package

To verify that all tablespaces to transport are self-contained, we can use the TRANSPORT_SET_CHECK procedure within the DBMS_TTS PL/SQL Package. The first parameter to this procedure is a list of the tablespaces to transport. Keep in mind that all indexes for a table, partitions, and LOB column segments in the tablespace must also reside in the tablespace set. The second parameter to this procedure is a boolean value that indicates whether or not to check for referential integrity.

SQL> connect sys/change_on_install@dwdb as sysdba SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('fact1, fact2', TRUE); SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS; VIOLATIONS -------------------------------------------------------------------------------- Index DW.DEPT_PK in tablespace FACT_IDX enforces primary constriants of table D W.DEPT in tablespace FACT1 Index DW.EMP_PK in tablespace FACT_IDX enforces primary constriants of table DW .EMP in tablespace FACT1
OOOPS! As we can see from the above example, I forgot to include all tablespaces that will make this self-contained. In this example, I forgot to include the FACT_IDX tablespace. Let's correct that:
SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('fact1, fact2, fact_idx', TRUE); SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS; no rows selected

Generate a Transportable Tablespace Set

To generate a Transportable Tablespace Set, you will need to perform the following:

  1. Place all tablespace within the tablespace set in READ ONLY mode.
  2. Use Export to gather tablespace data-dictionary information.
  3. Copy datafiles and the export dump from the source location to the target location.
  4. Place all tablespace within the tablespace set back to READ/WRITE.
% sqlplus "sys/change_on_install@dwdb as sysdba" SQL> ALTER TABLESPACE fact1 READ ONLY; SQL> ALTER TABLESPACE fact2 READ ONLY; SQL> ALTER TABLESPACE fact_idx READ ONLY; SQL> exit % exp userid=\"sys/change_on_install@dwdb as sysdba\" transport_tablespace=y tablespaces=fact1, fact2, fact_idx triggers=y constraints=y grants=y file=fact_dw.dmp % cp /u10/app/oradata/DWDB/fact1_01.dbf /u10/app/oradata/REPORTDB/fact1_01.dbf % cp /u10/app/oradata/DWDB/fact2_01.dbf /u10/app/oradata/REPORTDB/fact2_01.dbf % cp /u09/app/oradata/DWDB/fact_idx01.dbf /u09/app/oradata/REPORTDB/fact_idx01.dbf % sqlplus "sys/change_on_install@dwdb as sysdba" SQL> ALTER TABLESPACE fact1 READ WRITE; SQL> ALTER TABLESPACE fact2 READ WRITE; SQL> ALTER TABLESPACE fact_idx READ WRITE; SQL> exit

Transport the Tablespace Set

To actually transport the tablespace, this is nothing more than copying (or FTP'ing) all tablespace set datafiles to be put in their proper location on the target database. In the section previous to this, we did that with the cp command in UNIX.

In some cases this would be necessary if the files where copied off to a staging area in the previous step.

Import the Tablespace Set

Before actually importing the tablespace(s) into the target database, you will need to ensure that all users that own segments in the imported tablespaces exist. For this example, the only user that owns segments in the exported tablespaces is DW. I will create this user:
% sqlplus "sys/change_on_install@reportdb as sysdba" SQL> create user dw identified by dw default tablespace users; SQL> grant dba, resource, connect to dw; SQL> exit

We now use the Import utility to bring the tablespace set's data-dictionary information into the target database.

The two required parameters are TRANSPORT_TABLESPACE=Y and DATAFILES='...' as in the following example:

% imp userid=\"sys/change_on_install@reportdb as sysdba\" transport_tablespace=y datafiles='/u10/app/oradata/REPORTDB/fact1_01.dbf', '/u10/app/oradata/REPORTDB/fact2_01.dbf', '/u09/app/oradata/REPORTDB/fact_idx01.dbf' file=fact_dw.dmp

Final Cleanup

When the tablespaces are successfully imported into the target database, they are in READ ONLY mode. If you intend to use the tablespaces for READ WRITE, you will need to manually alter them:
% sqlplus "sys/change_on_install@reportdb as sysdba" SQL> ALTER TABLESPACE fact1 READ WRITE; SQL> ALTER TABLESPACE fact2 READ WRITE; SQL> ALTER TABLESPACE fact_idx READ WRITE; SQL> exit

 

 

 

Oracle8i에서는 tablespace단위로 그 구성 datafile들을 옮겨서 다른 database에 연결시켜

사용할 수 있는 기능이 제공된다.

 

SCOPE
--------
8i~10g Standard Edition 에서는 Import transportable tablespaces 기능만이 지원이 됩니다.


유용성
-------
1. 전사적 정보시스템내에서 대량의 data의 흐름이 필요할 경우, - 예를 들어,
   OLTP database에서 data warehouse database로의 data이전 또는 data
   warehouse에서 data mart로의 data이전 등 - 8.1이전까지는 SQL*Loader의
   direct path나 parallel DML등의 방법을 이용하여 그 작업속도를
   향상시키려고 시도 하였다. 8.1의 Transportable Tablespace기능을
   이용한다면 datafile들을 새로운 system으로 copy하는 정도의 시간으로
   작업을 완료할 수 있다.

2. 중앙에서 변경, 관리되고 지방(지사)에서 사용되는 data들을 CD-ROM에 담아서
   배포하는 등에 이용가능하다.
   예를 들어, 제품의 사양, 가격등에 대한 정보를 담는 tablespace를 중앙에서
   변경, 저장하여 배포하고, 이 data를 지방의 database에 연결하여 주문
   system등에 이용할 수 있다.

3. Contents 사업자들은 자신이 제공하는 contents들을 Transportable
   Tablespace형태로 제공 하여 고객들의 database에 바로 연결하여 사용할 수
   있도록 할 수 있다.


특성, 제한사항
-------------
1. 특정 tablespace내의 전체 data를 이동시킨다.
2. Media recovery를 지원한다.
3. Source database와 target database는
   - 동일한 OS에서 구동되고 있어야 한다.
   - Oracle8i(8.1)이상의 version이어야 한다.
   - 동일한 block size를 이용해야 한다.
   - 동일한 characterset을 이용해야 한다.


작업절차
-------
1. 대상 tablespace를 read only 상태로 변경한다.
   file을 copy하는 동안 해당 tablespace에 변경작업이 일어나지 않도록
   보장한다.

2. Source database에서 metadata를 export한다.
   해당 tablespace와 그 안의 object들에 대한 dictionary정보를 dump file에
   받는 과정이다.

3. 대상 tablespace의 datafile들을 target system으로 이동시킨다.

4. Export dump file을 이동시킨다.

5. Metadata를 target database에 import한다.

6. 필요하다면 이후에 해당 tablespace를 read-write mode로 변경한다.


SAMPLE
------
Source database : dbA
Target database : dbB
이동 대상 tablespace : TRANS_TS(/u01/data/trans_ts01.dbf, /u01/data/trans_ts02.dbf 로 구성)

1. dbA에서 TRANS_TS를 read only로 변경
   alter tablespace TRANS_TS read only ;

2. dbA에서 metadata를 export한다.
   exp sys/manager file=trans.dmp transport_tablespace=y
   tablespaces=trans_ts triggers=n constraints=n

   version이 8.1.6이상이라면,
   exp system/manager 대신에 exp \'sys/manager as sysdba\'와 같이
   주여야 한다.

   transport_tablespace(Y or N)는 Y로 설정한다.
   tablespaces에는 transport의 대상이 되는 tablespace를 지정한다.
   대상 tablespace의 table들에 걸려있는 trigger, constraint들도 대상으로
   할 것인지를 지정한다.

3. TRANS_TS의 두개의 datafile들을 dbB가 존재하는 system으로 binary
   copy한다.

4. 위의 2번 과정에서 export한 dump file을 dbB가 존재하는 system으로
   binary copy한다.

5. dbB에 metadata를 import한다.
   imp sys/manager file=trans.dmp transport_tablespace=y
   datafiles=/disk1/trans_ts01.dbf,/disk2/trans_ts02.dbf

   8.1.6이상이라면 이 부분도 sys/manager대신에 \'sys/manager as dba\'
   와 같이 적는다.

   transport_tablespace(Y or N)는 Y로 설정한다.
   datafile의 name은 dbB system에 copy된 filename을 지칭한다.

6. 필요할 경우 tablespace를 read write mode로 변경한다.
   alter tablespace TRANS_TS read write ;


TRANSPORT SET
-------------
Transport하고자 하는 tablespace set은 self-contained이어야만 한다.
대상이 되는 tablespace set 내에 partitioned table이 존재한다면 해당
table의 모든 partition들이 이들 tablespace 내에 존재해야 하며, 비슷하게
LOB column의 data들도 table의 data들과 함께 이들 tablespace 내에 존재해야
하는데, 이렇게 서로 관련된 object들이 tablespace set내에 모두 존재하는
것을 self-contained라고 지칭한다.
tablespace set이 self-contained하지 않다면 transport할 수 없다.

Transport tablespace set이 self-contained인지의 여부를 확인하기 위해서
DBMS_TTS.TRANSPORT_SET_CHECK procedure를 이용한다.

예를 들어,
DBMS_TTS.TRANSPORT_SET_CHECK(ts_list=>'A,B,C',incl_constraints=>TRUE)
을 수행하면 A, B, C 세개의 tablespace로 구성된 transport tablespace set이
self-contained인지에 대한 정보를 TRANSPORT_SET_VIOLATIONS view에 기록해
준다.

incl_constraints를 설정하면 referencial(foreign key) constraint에
대해서도 self-contained 여부를 check해준다.

 

 

==================================================================

10G: TRANSPORTABLE TABLESPACES ACROSS DIFFERENT PLATFORMS

==================================================================

 

Purpose
---------
이 자료에서는 서로 다른 Platform 으로  Tablespaces 를 transport 하는 방법에 대해
설명하고자 한다.

 

Explanation
-----------
10g 에서는 서로 다른 platform 으로 tablespace 를 transport 할 수 있으며
transport 가능한 platform 정보는 다음과 같다.


   SQL>  select * from v$transportable_platform;

   PLATFORM_ID PLATFORM_NAME                    ENDIAN_FORMAT
   ----------- ------------------------------   --------------
             1 Solaris[tm] OE (32-bit)          Big
             2 Solaris[tm] OE (64-bit)          Big
             7 Microsoft Windows NT             Little
            10 Linux IA (32-bit)                Little
             6 AIX-Based Systems (64-bit)       Big
             3 HP-UX (64-bit)                   Big
             5 HP Tru64 UNIX                    Little
             4 HP-UX IA (64-bit)                Big
            11 Linux IA (64-bit)                Little
            15 HP Open VMS                      Little
             8 Microsoft Windows IA (64-bit)    Little
             9 IBM zSeries Based Linux          Big
            13 Linux 64-bit for AMD             Little
            16 Apple Mac OS                     Big
            12 Microsoft Windows 64-bit for AMD Little


10g 이전 version 까지는 동일한 platform 에 대해서만 지원하였으며 10g 에서는
서로 다른 platform 에서도 tablespace 이동이 가능하도록 지원하고 있다.

Transportable Tablespaces 가 사용되어지는 사례는 다음과 같다.

1. 다른 platform 으로 database 를 migration 하고자 할때
2. 서로 다른 platform 의 DW 환경에서 Distribute data 를 data marts 로 이동을 원할 경우
3. Publish structured data 를 기존과 다른 platforms 으로 통합하고자 할 경우 등 입니다.

Transportable Tablespaces 를 위단 Step 은 다음과 같습니다.

1. Tablespace 를 READ ONLY 상태로 변경한다.

SQL> alter tablespace REPOSIT read only;
      Tablespace altered.


2. Metadata 를 다음 과 같이 export 한다.

      $ exp userid=\'/ as sysdba\' transport_tablespace=y
                                         tablespaces=reposit
                                         file=tts.dmp log=exp_tts.log
                                         statistics=none

      Export: Release 10.1.0.1.0 - Beta on Mon Nov 24 11:49:49 2003
      ...
 
      Note: table data (rows) will not be exported
      About to export transportable tablespace metadata...
      For tablespace REPOSIT ...
      . exporting cluster definitions
      . exporting table definitions
      . . exporting table                MTG_COL_DEP_CHG
      . . exporting table                  MTG_DATABASES 
      ....
      . . exporting table              SYBASE11_SYSUSERS
      . exporting referential integrity constraints
      . exporting triggers
      . end transportable tablespace metadata export
      Export terminated successfully without warnings.


3. 이동하고자 하는 target database platform 의 ENDIAN_FORMAT 정보를 확인한다.
Case 1 의 경우는 query 결과 ENDIAN_FORMAT 이 같은 상태로 conversion 필요 없이
Tablespaces 이동이 가능하고 Case 2 의 경우에는 ENDIAN_FORMAT 이 다른 경우로
ENDIAN_FORMAT conversion 을 위해 RMAN 을 이용하여 아래와 같이 추가적인 작업이 필요하다.

   Case 1
   ------
      The source platform is Sun SPARC Solaris: endianness Big
      The target platform is HP-UX (64-bit):    endianness Big

          SQL> select PLATFORM_ID , PLATFORM_NAME from v$database;

          PLATFORM_ID PLATFORM_NAME
          ----------- ------------------------------
                    3 HP-UX (64-bit)

  
       No conversion needed.


    Case 2
   ------
      The source platform is Microsoft WIndows NT:   endianness Little
      The target platform is HP-UX (64-bit):         endianness Big

      다음과 같이 endian format 이 다른 상태에서 작업시 다음과 같이 에러가 발생한다.

          . importing SYS's objects into SYS
          IMP-00017: following statement failed with ORACLE error 1565:
           "BEGIN   sys.dbms_plugts.beginImpTablespace('TBS_TTS',37,'SYS',1,0,8192,2,57"
           "54175,1,2147483645,8,128,8,0,1,0,8,462754339,1,1,5754124,NULL,0,0,NULL,NULL"
           "); END;"
          IMP-00003: ORACLE error 1565 encountered
          ORA-01565: error in identifying file '/database/db101b2/V101B2/datafile/reposit01.dbf'
          ORA-27047: unable to read the header block of file
          HP-UX Error: 2: No such file or directory
          Additional information: 2
          ORA-06512: at "SYS.DBMS_PLUGTS", line 1540
          ORA-06512: at line 1
          IMP-00000: Import terminated unsuccessfully

     결국, Tablespace import 를 하기전에 RMAN 을 통해 files convert 작업이 필요하다.    

    $ rman target=/

    Recovery Manager: Release 10.1.0.1.0 - 64bit Beta
    connected to target database: V101B2 (DBID=3287908659)

    RMAN> convert tablespace 'REPOSIT'
    2>  to platform="Linux IA (32-bit)"
    3>  db_file_name_convert='/database/db101b2/V101B2/datafile/reposit01.dbf',
    4>                       '/tmp/reposit01.dbf';

    Starting backup at 24-NOV-03
    using target database controlfile instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=8 devtype=DISK
    channel ORA_DISK_1: starting datafile conversion
    input datafile fno=00006 name=/database/db101b2/V101B2/datafile/reposit01.dbf
    converted datafile=/tmp/reposit01.dbf
    channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
    Finished backup at 24-NOV-03

    Convert 된 files 은 /tmp 디렉토리에 존재하게 되고 이를 target server 에 copy 한다.   


4. Datafile 과 export dump file 을 ftp 를 이용하여 move 한다.

      $ftp tts.dmp 
           + 
             /database/db101b2/V101B2/datafile/reposit01.dbf (no conversion)
           or
             /tmp/reposit01.dbf (converted file if conversion had been required)


5. Metadata 를 import 한다.

      $ imp userid=\'/ as sysdba\' TRANSPORT_TABLESPACE=Y
                                   datafiles=/database/db101b2/V101B2/datafile/reposit01.dbf
                                             (or /tmp/reposit01.dbf )
                                   file=tts.dmp log=imp_tts.log
  
      Import: Release 10.1.0.1.0 - Beta on Mon Nov 24 03:37:20 2003

      Export file created by EXPORT:V10.01.00 via conventional path
      About to import transportable tablespace(s) metadata...
      ...
      . importing SYS's objects into SYS
      . importing OMWB's objects into OMWB
      . . importing table              "MTG_COL_DEP_CHG"
      ...
      . . importing table            "SYBASE11_SYSUSERS"
      Import terminated successfully without warnings.


6. Import 가 성공적으로 끝나면 tablespace 를 READ WRITE 상태로 변경한다.

      SQL> alter tablespace reposit read write;
      Tablespace altered.


'OraclE' 카테고리의 다른 글

Listener.log 파일 남기지 않는 방법  (0) 2008.10.22
DataPump *  (0) 2008.10.17
sqlnet ip 제한  (0) 2008.10.07
archive file 자동 삭제 스크립트-window  (0) 2008.10.07
data file size 줄이기  (0) 2008.10.07

+ Recent posts