【EXPDP】不使用DIRECTORY引數完成expdp資料備份

secooler發表於2011-06-27
  在使用expdp工具備份資料庫的時候,一般需要使用DIRECTORY引數指定備份檔案和日誌檔案的存放位置。其實DIRECTORY引數並不是必須的。我們可以將目錄寫到dumpfile引數和logfile引數中以便實現同樣的目的。

1.建立expdp備份檔案存放目錄
ora10g@secdb /home/oracle$ mkdir secooler
ora10g@secdb /home/oracle$ cd secooler/
ora10g@secdb /home/oracle/secooler$

2.在資料庫中建立指向secooler目錄的DIRECTORY資料庫物件
sys@ora10g> create directory dir_secooler as '/home/oracle/secooler';

Directory created.

sys@ora10g> grant read,write on directory dir_secooler to public;

Grant succeeded.

3.在DUMPFILE及LOGFILE引數中指定DIRECTORY名的備份方法
注意:DUMPFILE及LOGFILE引數均需要指定DIRECTORY名
1)備份過程
ora10g@secdb /home/oracle/secooler$ expdp sec/sec dumpfile=dir_secooler:sec.dmp logfile=dir_secooler:sec.log

Export: Release 10.2.0.1.0 - Production on Monday, 27 June, 2011 21:09:02

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** dumpfile=dir_secooler:sec.dmp logfile=dir_secooler:sec.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
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
. . exported "SEC"."T"                                   4.921 KB       1 rows
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/secooler/sec.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 21:09:15


2)檢視生成的備份檔案及引數檔案
ora10g@secdb /home/oracle/secooler$ ls -tlr
total 156K
-rw-r--r-- 1 oracle oinstall 1.3K Jun 27 21:09 sec.log
-rw-r----- 1 oracle oinstall 148K Jun 27 21:09 sec.dmp

4.關於日誌檔案的注意事項
使用這種方法,日誌檔案引數必須指定,並且必須給出DIRECTORY名字,否則會報“ORA-39145”錯誤,表明找不到地方寫日誌檔案。
ora10g@secdb /home/oracle/secooler$ expdp sec/sec dumpfile=dir_secooler:sec.dmp

Export: Release 10.2.0.1.0 - Production on Monday, 27 June, 2011 21:12:05

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-39145: directory object parameter must be specified and non-null

5.小結
  本文雖然給出了不使用DIRECTORY引數完成expdp資料備份的方法,但是細心的您一定發現,雖然省略了DIRECTORY引數,但是必須在DUMPFILE及LOGFILE引數中指定DIRECTORY名。到底使用哪種方法只能看個人喜好了。

Good luck.

secooler
11.06.27

-- The End --

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

相關文章