Oracle11g:数据备份迁移恢复-数据泵

一、介绍

rman最小的粒度是数据文件,数据泵最小粒度是表中的特定行,所以之间不能替代,可以互为补充。

 

二、创建目录

1、创建导入导出文件所在目录

create directory home as '/home/oracle';

指定目录下的文件

dumpfile=home:ext.dmp 或者 directory=home dumpfile=ext/dmp

默认路径DATA_PUMP_DIR

select * from dba_directories;

2、授权

grant read.write on direcotry home to hr;

 

三、数据导出

(1)权限

需要具有datapump_exp_full_database或者dba权限

(2)完全模式导出

expdp system/oracle cluster=n compression=all full=y parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

cluster=n #仅允许使用一个数据库实例上执行,限制了对RAC环境中其他节点使用

compression=all #压缩

full=y #完全模式导出,包含所有用户业务数据

parallel=2 #并行度

nologfile=y #不产生日志

dumpfile=EX%U.DMP #%U表示01-10,根据并行度导出EX01和EX02文件

reuse_dumpfiles=y #目录中同名文件将覆盖

(3)指定表空间

expdp system/oracle cluster=n tablespace=users,example parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

(4)指定schema

expdp system/oracle cluster=n schemas=hr,oe parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

(5)导出指定表

expdp system/oracle cluster=n tables=hr.employees,hr.departments parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

(6)指定行

expdp system/oracle cluster=n tables=hr.employees query=hr.employees:\"where job_id\=\'IT_PROG\'" parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

(7)导出闪回时间点数据

expdp system/oracle cluster=n flashback_time=\"systimestamp \-interval \'10\' minute\" tables=hr.employees,hr.departments parallel=2 nologfile=y dumpfile=EX%U.DMP reuse_dumpfiles=y

 

四、数据导入

(1)导入所有对象

impdp system/oracle cluster=n full=y nologfile=y dumpfile=EX01.dmp,EX02.dmp

(2)导入指定表空间所有对象以及数据

impdp system/oracle cluster=n tablespaces=example nologfile=y dumpfile=EX%U.dmp

(3)指定schema

impdp system/oracle cluster=n schemas=hr nologfile=y dumpfile=EX%U.dmp

(4)指定表以及相关对象(索引,权限,触发器等)

impdp system/oracle cluster=n tables=hr.employees nologfile=y dumpfile=EX%U.dmp

(5)加入query

impdp system/oracle cluster=n tables=hr.employees query=xxxxxxx nologfile=y dumpfile=EX%U.dmp

(6)其他相关参数

table_exists_action #默认值skip,存在即跳过。append(追加数据)、truncate(阶段后插入)、replace(表删除重建并插入数据)。追加和截断都有可能违反约束导致失败。

remap_table\remap_schema

exclude

 

 

五、可传输表空间

(1)将备份的表空间设置为可读

alter tablespace users read only;

(2)导出

expdp system/oracle transport_tablespace=users nologfile=y dumpfile=tts.dmp reuse_dumpfiles=y

可传输表空间导出只包含对象的数据字典描述。实际数据还在表空间数据文件中。

transport_fill_check=y #自包含性检查,即不存在依赖

(3)复制数据文件

cp xxxx/ddd.dbf /ddd/ddd/xa.tts

(4)恢复读写

alter tablespace users read write;

(5)删除user表空间

drop tablespace users including contents and datafile;

(6)恢复

impdp \'/ as sysdba\' transport_datafiles=/ddd/ddd/xa.tts nologfile=y dumpfile=tts.dmp

(7)查看恢复的表空间状态

select tablespace_name, status,plugged_in

from dba_tablespaces;

(8)恢复的表空间为只读,设置为读写

alter tablespace users read write;

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值