****全库Expdp导出,再全库Impdp导入****
源系统:
操作系统:CentOS
Oracle数据库版本:Oracle11g Enterprise Edition Release 11.2.0.1.0
SID:orcl
端口:1521
目标系统:
操作系统:Windows 2012
Oracle数据库版本:Oracle11g Enterprise Edition Release 11.2.0.1.0
SID:orcl
端口:1521
源系统和目标系统都建立账号
create user username identified by password;
grant connect,resoure to username;
赋予expdp和impdp命令权限:
grant exp_full_database,imp_full_database to username;
SQL> create user migrate identified by migrate;
User created
SQL> grant connect,resource,dba to migrate;
Grant succeeded
SQL> grant exp_full_database,imp_full_database to migrate;
Grant succeeded
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ --------------------------------------------------------------------------------
SYS ORACLE_OCM_CONFIG_DIR /oracle/app/product/11.2.0/dbhome_1/ccr/state
SYS DATA_PUMP_DIR /oracle/app/admin/orcl/dpdump/
SYS XMLDIR /ade/b/2125410156/oracle/rdbms/xml
create directory DPDMP as '/oracle/app/admin/orcl/dpdmp/'; --该目录必须是已经存在的目录(该目录应该用oracle用户创建),否则会报错
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
------------------------------ ------------------------------ --------------------------------------------------------------------------------
SYS ORACLE_OCM_CONFIG_DIR /oracle/app/product/11.2.0/dbhome_1/ccr/state
SYS DATA_PUMP_DIR /oracle/app/admin/orcl/dpdump/
SYS DPDMP /oracle/app/admin/orcl/dpdmp/
SYS XMLDIR /ade/b/2125410156/oracle/rdbms/xml
grant read,write on directory DPDMP to username;
expdp username/password@orcl directory= DPDMP dumpfile=XX_schema%U.dmp logfile=XX_schema.log schemas=XX_schema
或者导出整个库:
expdp username/password@orcl directory= DPDMP dumpfile=all%U.dmp logfile=XX_schema.log parallel=10 full=y
这步骤省略
create directory DPDMP as 'E:\oracle\app\Administrator\admin\orcl\dpdmp'; --该目录必须是已经存在的目录,否则会报错
grant read,write on directory impdp to username;
impdp username/password@orcl directory= DPDMP dumpfile=XX_schema%U.dmp logfile=XX_schema.log schemas=XX_schema
或导入整个库:
impdp username/password@orcl directory= DPDMP dumpfile=all%U.dmp logfile=XX_schema.log parallel=10 full=y
impdp migrate/migrate@orcl directory=dpdmp dumpfile=migrate_full.dmp logfile=migrate_imp_full.log full=y parfile=e:\payroll.par parallel=10
payroll.par放到directory impdp目录下或放到E盘根目录:
payroll.par文件内容
remap_datafile="'/oracle/app/oradata/orcl/XXX.dbf':'E:\ORACLE\APP\ADMINISTRATOR\ORADATA\ORCL\XXX.DBF'"
remap_datafile="'/oracle/app/oradata/orcl/XXX.dbf':'E:\ORACLE\APP\ADMINISTRATOR\ORADATA\ORCL\XXX.DBF'"
remap_datafile="'/oracle/app/oradata/orcl/XXX.dbf':'E:\ORACLE\APP\ADMINISTRATOR\ORADATA\ORCL\XXX.DBF'"
select ts.tablespace_name,to_char(dbms_metadata.get_DDl('TABLESPACE',ts.tablespace_name))from dba_tablespaces ts;
select username,default_tablespace,temporary_tablespace,profile,dbms_metadata.get_DDl('USER',username) from dba_users where
account_status='OPEN' ;
select table_name, count_rows(table_name) nrows from user_tables ;
select * from dba_datapump_jobs;
如果impdp过程中异常退出后,要从中断处继续导入执行如下:
impdp migrate/migrate@orcl attach=JOB_NAME (JOB_NAME可以通过dba_datapump_jobs来查询)
比如:> impdp mig_test/mig_test attach=SYS_IMPORT_TABLE_02Import status/continue_client 返回记录模式/stop_job YES/
交互模式常用命令:
CONTINUE_CLIENT返回到记录模式。假如处于空闲状态, 将重新启动作业。
START_JOB 启动恢复当前作业。
STATUS在默认值 (0) 将显示可用时的新状态的情况下,要监视的频率 (以秒计) 作业状态。
STATUS=[interval]
STOP_JOB顺序关闭执行的作业并退出客户机。
STOP_JOB=IMMEDIATE 将立即关闭数据泵作业。
如果全库导入的时候会暂停卡在那里
可以查diag\rdbms\orcl\orcl\trace\alert_orcl.log查看日志,针对当前问题解决掉后,impdp会继续
如果是ORA-19815: WARNING: db_recovery_file_dest_size of 4039114752 bytes is 100.00% used, and has 0 remaining bytes available.
就需要将db_recovery_file_dest_size调大:
SQL> alter system set db_recovery_file_dest_size=50G scope=spfile(需要重启数据库生效)
SQL> shutdown immediate;
SQL> startup;
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string E:\oracle\app\Administrator\flash_recovery_area
db_recovery_file_dest_size big integer 50G
参考网上各位的技术文档,谢谢各位!
http://www.2cto.com/database/201308/238174.html
http://blog.itpub.net/26839123/viewspace-734463/
http://blog.chinaunix.net/uid-23622436-id-2394094.html
http://blog.csdn.net/giianhui/article/details/7788550
http://www.itpub.net/forum.php?mod=viewthread&tid=1786140&page=1
http://blog.csdn.net/tianlesoftware/article/details/6260138
http://blog.itpub.net/29337971/viewspace-1097072/
http://www.osyunwei.com/archives/5943.html
http://blog.chinaunix.net/uid-27126319-id-3676382.html