2014. 11. 6. 18:20

1. conventional path로 full export 받기(기본모드)


SYS>!

[oracle@localhost ~]$ mkdir /data/exp/

[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full01.dmp log=/data/exp/full_log01.log

나는 하는 도중에 temp 테이블스페이스 없어서 에러가 났음
그래서 기본으로 temp 테이블 스페이스를 만들어주니까 정상적으로 작동함

....생략


. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    4m13.880s

user    0m22.326s

sys     0m6.277s


약 4분 13초 걸림

2. direct path로 full export  받기

마지막에 옵션 하나만 더 추가함

[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full02.dmp log=/data/exp/full_log02.log direct=y


. exporting synonyms

. exporting views

. exporting referential integrity constraints

. exporting stored procedures

. exporting operators

. exporting indextypes

. exporting bitmap, functional and extensible indexes

. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    3m11.137s

user    0m20.209s

sys     0m5.754s


약 3분 11초 걸림


3. export를 저장하는 파일을 분할해서 받기

큰 파일 하나를 여러 개의 작은 파일로 분할해서 백업받음


[oracle@localhost ~]$ time exp system/oracle full=y file=/data/exp/full03_1.dmp,\

/data/exp/full03_2.dmp,\

/data/exp/full03_3.dmp\

filesize=100M;


실행할 때 파일명을 고치지 않고 그대로 실행을 다시 하면 원본 파일을 그대로 물어보지 않고, 덮어써 버린다.

주의하자. 



. exporting posttables actions

. exporting triggers

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    2m45.807s

user    0m21.065s

sys     0m5.704s


그냥 확인해 봄 
[oracle@localhost ~]$ cd /data/exp
[oracle@localhost exp]$ ls
full01.dmp  full03_1.dmp  full_log01.log
full02.dmp  full03_2.dmp  full_log02.log

용량을 잘못 계산해서 파일 개수를 부족하게 지정할 경우는 추가적으로 파일 이름을 입력하도록 프롬프트가 나와서
사용자에게 다음 파일이름을 입력하라고 중간에서 대기하고 있음
그 때 파일 이름을 지정해주면 그 파일에 exp 됨

time exp system/oracle full=y file=/data/exp/full04_1.dmp, /data/exp/full04_2.dmp, /data/exp/fulll04_3.dmp filesize=10m;
...생략
. . exporting table         WWV_FLOW_RANDOM_IMAGES         42 rows exported
. . exporting table WWV_FLOW_REGION_CHART_SER_ATTR          0 rows exported
. . exporting table  WWV_FLOW_REGION_REPORT_COLUMN
Export file: expdat.dmp > /data/exp/full04_4.dmp 
...생략


위와 같이 파일 이름 입력해줌

한 세번 정도 떠서 각각 /data/exp/full04_5.dmp, /data/exp/full04_6.dmp ...이런식으로 계속 멈추면 원하는 파일명을 입력하면 됨


. exporting post-schema procedural objects and actions

. exporting user history table

. exporting default and system auditing options

. exporting statistics

Export terminated successfully with warnings.


real    7m11.178s

user    0m20.848s

sys     0m5.364s



4. 특정 tablespace 만 export 하기

[oracle@localhost ~]$ time exp system/oracle file=/data/exp/ex_user.dmp tablespaces=example, users


...생략

. . exporting table                TEST_NOVALIDATE          3 rows exported

. . exporting table                  TEST_VALIDATE          3 rows exported

. . exporting table                          TT111          1 rows exported

. . exporting table                 CATEGORIES_TAB         22 rows exported

. . exporting table     PRODUCT_REF_LIST_NESTEDTAB        288 rows exported

. . exporting table SUBCATEGORY_REF_LIST_NESTEDTAB         21 rows exported

EXP-00079: Data in table "PURCHASEORDER" is protected. Conventional path may only be exporting partial table.

. . exporting table                  PURCHASEORDER        132 rows exported

. exporting referential integrity constraints

. exporting triggers

Export terminated successfully with warnings.


real    0m18.972s

user    0m2.302s

sys     0m0.469s


5. 특정 table만 exp하기

[oracle@localhost ~]$ exp scott/tiger tables=emp,dept file=emp_dept.dmp;


Export: Release 11.2.0.2.0 - Production on Fri Nov 7 01:56:55 2014


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 - Production

With the Partitioning option

Export done in KO16MSWIN949 character set and AL16UTF16 NCHAR character set


About to export specified tables via Conventional Path ...

. . exporting table                            EMP         14 rows exported

. . exporting table                           DEPT          4 rows exported

Export terminated successfully without warnings.


현재 경로에 만들어진 것 확인

[oracle@localhost ~]$ ls

!           ar.sh      Desktop       hot_back.sql  redo.sql

afiedt.buf  cold_back  emp_dept.dmp  ll.sql        shut

a.out       database   expdat.dmp    login.sql     test_data.sql

arch.sql    dd.sql     hot_back      log.sql


6. 여러 사용자를 동시에 exp 하기


[oracle@localhost ~]$ time exp system/oracle file=/data/exp/scott_hr.emp owner=scott,hr;

... 생략

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting statistics

Export terminated successfully without warnings.


real    0m4.183s

user    0m0.120s

sys     0m0.023s


7. evaluation Buffer값이 export에 주는 영향 테스트 하기

실습을 위해 테스트용 테이블 생성

SQL> create table scott.test01

  2  (no number,

  3  name varchar2(50),

  4  address varchar2(50))

  5  tablespace users;


Table created.


대량의 데이터를 users tablespace에 입력하기 때문에 용량이 부족할 수 있으므로

용량을 충분히 늘려줌



SQL> @/home/oracle/dd.sql


TABLESPACE    MB FILE_NAME

---------- ----- --------------------------------------------------

EXAMPLE      346 /data/temp7/example01.dbf

USERS          8 /data/temp7/users01.dbf

UNDOTBS1      90 /data/temp7/undotbs01.dbf

SYSAUX       560 /data/temp7/sysaux01.dbf

SYSTEM       710 /data/temp7/system01.dbf


SQL> alter database datafile '/data/temp7/users01.dbf' autoextend on;


Database altered.


SQL> alter database datafile '/data/temp7/undotbs01.dbf' autoextend on;


Database altered.

SQL>begin

for i in 1..5000000 loop

insert into scott.test01

values(i, dbms_random.string('A',49),

             dbms_random.string('Q',49));

end loop;

commit;

end;

/


하지만 시간이 한 20~30분 잡아야 함 ㅠ 


생성 후 해당테이블 크기 확인

SYS> select sum(bytes)/1024/1024 MB

from dba_segments

where owner='SCOTT'

and segment_name='TEST01';


테스트 

1 .evaluation buffer 값을 설정하지 않고 export 수행

time exp scott/tiger file=/data/exp/test_01_1.dmp tables=test01;


2. evaluation buffer 값을 1M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_2.dmp tables=test01 buffer=1024000


3. evaluation buffer 값을 10M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_3.dmp tables=test01 buffer=10240000


4. evaluation buffer 값을 20M 설정하고 export 수행

time exp scott/tiger file=/data/exp/test_01_4.dmp tables=test01 buffer=20480000


5. direct path로 export 수행

time exp scott/tiger file=/data/exp/tect_01_5.dmp tables=test01 direct=y


결과 :

evaluation buffer 의 크기를 조절하면서 export를 수행하는 것이 속도에 영향을 미침

무조건 크기가 크다고 속도가 빨라지는 것이 아님

또 temporary tablespace의 크기도 exp/imp에 영향을 많이 줌

작업 전에 미리 큰 용량을 확보한 수 작업을 하자 


8. parameter file을 이용한 export 수행

[oracle@localhost ~]$ vi full.dat

file=/data/exp/full02.dmp

full=y

direct=y

:wq!


[oracle@localhost ~]$ exp system/oracle parfile=full.dat

9. 특정조건만 export 받기 - query 옵션 사용하기
test1. emp 테이블에서 이름 첫 글자가 F인 사람만 export 받기
(OS에서 사용하는 ' / " /  < 등의 문자를 쓸 경우 \ escape문자를 꼭!!! 써야함)
[oracle@localhost ~]$ exp scott/tiger query=\"where ename like \'F%\'\"tables=empfile=/data/exp/test06.dmp

test2. emp테이블에서 job이 clerk이고 급여가 1000이상인 사람만 export 받기



'DB > oralce' 카테고리의 다른 글

drop tablespace 장애 복구 - clone db 사용 정리할것..;;;  (0) 2014.11.11
temporary tablespace  (0) 2014.11.07
리두로그 장애3  (0) 2014.11.06
리두로그 장애2  (0) 2014.11.06
리두로그 장애1  (0) 2014.11.05
Posted by 성장하는yw