【EXPDP】運用PARALLEL 和FILESIZE引數提高備份效率

secooler發表於2010-03-29
EXPDP命令的PARALLEL和FILESIZE引數聯合使用在“某些情況下”可以提高備份的效率。
這種方法可以完成並行的邏輯備份。

1.環境準備
1)建立directory物件
sys@secooler> create or replace directory expdp_dir as '/expdp';

Directory created.

2)讀寫許可權授權給sec使用者
sys@secooler> grant read,write on directory expdp_dir to sec;

Grant succeeded.

3)確認EXPDP_DIR目錄指向
sys@secooler> select DIRECTORY_PATH from dba_directories where DIRECTORY_NAME='EXPDP_DIR';

DIRECTORY_PATH
-------------------------------------
/expdp

2.並行備份高效的場景
備份生成的檔案大概在1.3G

1)備份測試指令碼如下
secooler@secDB /expdp$ vi test.sh
date
exp sec/sec file=sec_exp.dmp log=sec_exp.log
date
expdp sec/sec directory=expdp_dir dumpfile=sec_expdp_%U.dmp logfile=sec_expdp.log filesize=500m parallel=4
date
~

2)執行測試指令碼
sec@secDB /expdp$ sh test.sh
Mon Mar 29 13:36:38 GMT 2010

Export: Release 10.2.0.3.0 - Production on Mon Mar 29 13:36:38 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Export done in AL32UTF8 character set and UTF8 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SEC
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SEC
About to export SEC's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SEC's tables via Conventional Path ...
. . exporting table           SEC_ATTACH_VPDS_TEMP         37 rows exported
. . exporting table         SEC_CHANGE_DEGDSE_TEMP      67915 rows exported
……省略……
. . exporting table                T_SEC_SDE_RESES          0 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
Mon Mar 29 13:45:12 GMT 2010

Export: Release 10.2.0.3.0 - 64bit Production on Monday, 29 March, 2010 13:45:12

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  SEC/******** directory=expdp_dir dumpfile=SEC_expdp_%U.dmp logfile=SEC_expdp.log filesize=500m parallel=4
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 1.110 GB
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/SEQUENCE/SEQUENCE
. . exported "SEC"."T_SEC_DAC_LOG"                  94.67 MB 1984475 rows
. . exported "SEC"."T_SEC_AGRTT_APPLY"              93.57 MB  572489 rows
……省略……
. . exported "SEC"."T_VSE_CLD_PDESOD"               19.25 KB     282 rows
. . exported "SEC"."T_VSE_SEC_RLELE_DAY_TYPE"       9.296 KB      18 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/SEC_expdp_01.dmp
  /expdp/SEC_expdp_02.dmp
  /expdp/SEC_expdp_03.dmp
  /expdp/SEC_expdp_04.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 13:45:59

Mon Mar 29 13:46:00 GMT 2010


3)列選三個時間點進行比較
Mon Mar 29 13:36:38 GMT 2010
Mon Mar 29 13:45:12 GMT 2010
Mon Mar 29 13:46:00 GMT 2010

exp邏輯備份方法共用時8分34秒,而expdp的並行備份僅僅用時48秒。expdp並行備份的效率可見一斑。

3.並行備份某些場景低效表現
此時備份檔案大概在100M左右。

1)測試指令碼如下
secooler@secDB /expdp$ vi test.sh
date
exp sec/sec file=sec_exp.dmp log=sec_exp.log
date
expdp sec/sec directory=expdp_dir dumpfile=sec_expdp_%U.dmp logfile=sec_expdp.log filesize=10m parallel=4
date
~

注意,此時是按照10m大小一個檔案進行並行匯出的。這樣100M多的備份檔案會生成10多個小的備份檔案。因此會加重系統的負擔。

2)指令碼執行過程
secooler@secDB /expdp$ sh test.sh
Mon Mar 29 21:16:48 CST 2010

Export: Release 11.2.0.1.0 - Production on Mon Mar 29 21:16:48 2010

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


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user SEC
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SEC
About to export SEC's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SEC's tables via Conventional Path ...
. . exporting table                              T    1155520 rows exported
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
Mon Mar 29 21:17:25 CST 2010

Export: Release 11.2.0.1.0 - Production on Mon Mar 29 21:17:25 2010

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** directory=expdp_dir dumpfile=sec_expdp_%U.dmp logfile=sec_expdp.log filesize=10m parallel=4
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 136 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
. . exported "SEC"."T"                                   111.7 MB 1155520 rows
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/sec_expdp_01.dmp
  /expdp/sec_expdp_02.dmp
  /expdp/sec_expdp_03.dmp
  /expdp/sec_expdp_04.dmp
  /expdp/sec_expdp_05.dmp
  /expdp/sec_expdp_06.dmp
  /expdp/sec_expdp_07.dmp
  /expdp/sec_expdp_08.dmp
  /expdp/sec_expdp_09.dmp
  /expdp/sec_expdp_10.dmp
  /expdp/sec_expdp_11.dmp
  /expdp/sec_expdp_12.dmp
  /expdp/sec_expdp_13.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 21:19:08

Mon Mar 29 21:19:13 CST 2010


3)整理一下三個時間點
整理一下三個時間:
Mon Mar 29 21:16:48 CST 2010
Mon Mar 29 21:17:25 CST 2010
Mon Mar 29 21:19:13 CST 2010

第一次備份使用了37秒,第二次備份使用了1分48秒,說明啟用並行備份不一定會比普通備份效能高,因為需要很多的額外開銷。

4.關於指令碼中“%U”引數的說明
“dumpfile=sec_expdp_%U.dmp”出現的“%U”表示自動生成遞增的序列號。
更多關於%U引數的使用說明請參考如下Oracle官方文件描述:


5.小結
EXPDP備份工具在資料量較大並且配置合理的情況下,可以極大地提高我們的備份效率。
在使用前做好充分的測試。

Good luck.

secooler
10.03.29

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-630721/,如需轉載,請註明出處,否則將追究法律責任。

相關文章