在使用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 --
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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/519536/viewspace-700840/