RMAN中各种文件的恢复方法

支持数据库版本:10gR2,11gR2

1. 完全介质恢复

# 数据库需要在 mount 状态

1-1. 挂载数据库
RMAN> startup mount;

1-2. 执行恢复
RMAN> restore database;
# delete archivelog 会删除恢复期间产生的归档, 不影响之前的归档
# maxsize 指定恢复过程中产生归档的上限大小, 达到上限会自行删除
RMAN> recover database delete archivelog maxsize 10m skip tablespace temp;
RMAN> alter database open;


2. 恢复表空间或数据文件

2-1. 表空间
# 数据库可以在 mount 也可以在 open 状态
RMAN> sql 'alter tablespace users offline';
RMAN> restore tablespace users;
RMAN> recover tablespace users;
RMAN> sql 'alter tablespace users online';

2-2. 数据文件
# 数据库可以在 mount 也可以在 open 状态
RMAN> sql 'alter datafile 5 offline';
RMAN> restore datafile 5;
RMAN> recover datafile 5;
RMAN> sql 'alter datafile 5 online';

RMAN> sql 'alter datafile 5 offline';
RMAN> run {
set newname for datafile 5 to '/data/users01.dbf';
restore datafile 5;
switch datafile 5;
recover datafile 5;
}
RMAN> sql 'alter tablespace users online';

2-2. 归档日志
# 恢复数据文件时, RMAN 会自动恢复并应用归档日志, 一般情况不需要手动恢复
# 默认恢复到 log_archive_dest_1 下
RMAN> restore archivelog sequence 22
RMAN> restore archivelog sequence between 22 and 23;

# 恢复到其他路径
RMAN> run {
set archivelog destination to '/arch1';
restore archivelog sequence between 21 and 22;
set archivelog destination to '/arch1';
restore archivelog sequence between 23 and 24;
}


3. 恢复控制文件

3-1. 从自动备份中恢复
RMAN> set dbid=xxxxxxxxx;
RMAN> startup nomount;

# 恢复控制文件到 control_files 路径下
RMAN> restore controlfile from autobackup;
# 恢复控制文件到任意路径下
RMAN> restore controlfile to '/data/control01.ctl' from autobackup;
# 若之前修改过自动备份的路径, 则恢复前需要手动设置自动备份路径
RMAN> set controlfile autoback format for device type disk to '/data/%F';
RMAN> restore controlfile from autobackup;

3-2. 从备份集中恢复
RMAN> set dbid=xxxxxxxxx;
RMAN> startup nomount;
RMAN> restore controlfile from '/data/xxxxxxxxxxxxxxxxxxxxx';
RMAN> recover database;
RMAN> alter database open resetlogs;


4. 初始化参数文件
RMAN> set dbid=xxxxxxxxx;
RMAN> startup nomount;
RMAN> restore spfile from autobackup;
RMAN> restore spfile to '/data/xxxxxx' from autobackup;
RMAN> restore spfile to '/data/xxxxxx' from '/back/xxxxxx';

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22558114/viewspace-1086553/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22558114/viewspace-1086553/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值