rman中备份恢复的案例

2017-11-15 by 路人佳

备份

RMAN>show all;

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;  设置控制文件自动备份


RMAN> backup database format='/home/oracle/myrman/prod_%s.bak' filesperset 3;

RMAN>list backup;

1.模拟system01.dbf损坏

rm /u01/oradata/prod/system01.dbf
startup froce

解决:
run{
startup force mount;
restore datafile 1;
recover datafile 1;
alter database open;
}

2.模拟users01.dbf损坏

rm /u01/oradata/prod/users01.dbf
alter system flush buffer_cache;

解决:
run{
sql 'alter tablespace users offline';
restore tablespace users;
recover tablespace users;
sql 'alter tablespace users online';
}

3.模拟新创建的表空间被误删除。

create tablespace abcd datafile '/u01/oradata/prod/abcd01.dbf' size 5m;
create table scott.t2(id int) tablespace abcd;
insert into scott.t2 values (1);
commit;
select * from scott.t2;
rm /u01/oradata/prod/abcd01.dbf
alter system flush buffer_cache;

解决:
run {
sql 'alter database datafile 7 offline';
restore datafile 7;
recover datafile 7;
sql 'alter database datafile 7 online';
}
select * from scott.t2;
drop tablespace abcd including contents and datafiles;

4.

不完全恢复
截断表恢复
select * from scott.t1;
select sysdate from dual;记录时间也可以日志挖掘时间
truncate table scott.t1;
解决:
run{
startup force mount;
set until time 'XXXX';
restore database;
recover database;
alter database open resetlogs;
}

5.

2.
误删spfile文件
shutdown abort
rm spfileprod.ora

解决:
rman target /
RMAN>startup nomount;
$ll /u01/flash_recovery_area/prod/autobackup/2013_01_16/..
RMAN>restore spfile form '/u01/flash_recovery_area/prod/autobackup/2013_01_16/..';

6.

误删除表空间
shutdown abort
rm *.ctl
rm *.dbf

解决:
run{
startup force nomount;
set dbid=3416564781;
restore controlfile from autobackup until time 'xxxx';
alter database mount;
restore database;
recover database until time 'xxxx';
alter database open resetlogs;
}

shutdown immediate
startup nomount
restroe controlfile from '';
alter database mount;
restroe database until time '';
recover database until time '';
alter database open resetlog;

7.

表空间时间点恢复
create tablespace defg datafile '/u01/oradata/prod/defg01.dbf' size 5m;
create table scott.t2(c1 date) tablespace defg;
insert into scott.t2 values(sysdate);
commit;
backup tablespace defg format '/u01/myrman/defg_%s.bak';
select sysdate from dual;
drop table scott.t2 purge;

解决:

$mkdir -p /u01/oradata/prod/auxdata
recover tablespace abcd until time 'xxxx' auxiliary destination '/u01/oradata/prod/auxdata';

8.

删除一个数据库
构建spfile文件
rman target /
RMAN>startup nomount;
$ll /u01/flash_recovery_area/prod/autobackup/2013_01_16/
RMAN>retore spfile form '/u01/flash_recovery_area/prod/autobackup/2013_01_16/..';
string spfileprod.ora找一些没创建的目录
mkdir -p /u01/admin/emrep/adump

构建控制文件和数据文件
1.shutdown immediate
2.startup nomount
3.还原控制文件并验证restore controlfile from '';
4.alter database mount
5.restore database until time '';
6.recover database until time '';

recover database until sequence 号数;
或者
recover database until scn 号数;

7.alter database open resetlogs;

最新更新:

第七城市

栏目导航(关闭)