Oracle数据库恢复命令


恢复controlfile恢复controlfile有三种办法,功能相同,只需要掌握其中一种即可。
方法一:从autobackup中恢复
缺省情况下,备份数据库时会自动备份controlfile,如果缺省设置被修改,可以使用如下RMAN命令设置autobackup选项:CONFIGURE CONTROLFILE AUTOBACKUP ON。
 
恢复controlfile的命令
run {
allocate channel ch00 type sbt_tape;
restore controlfile from autobackup;
release channel ch00;
}
 
方法二:直接恢复controlfile,这种方法会自动恢复最后一次备份的controlfile
run {
allocate channel ch00 type sbt_tape;
restore controlfile;
release channel ch00;
}
 
方法三:从指定备份集恢复
先用netbackup命令”bplist –C clientname –t 4 –R /”,找到保存controlfile的backupset id,然后从中恢复。
run {
allocate channel ch00 type sbt;
restore controlfile from '/cntrl_mgr1_44_1_703796294';
release channel ch00;
}
 

 

恢复数据库

 

恢复数据库过程

 

1.     检查备份是否成功,确认需要恢复的备份存在
2.     把数据库启动到nomount状态
3.     恢复controlfile
4.     把数据库启动到mount状态
5.     恢复数据库
6.     打开数据库
7.     验证恢复是否成功
 
恢复数据库的命令1.     全库恢复命令
run {
#分配通道,通道数据量根据数据量和恢复时间要求来确定。
allocate channel ch00 type sbt_tape; 
allocate channel ch01 type sbt_tape;
#缺省情况下,该命令会恢复最后一次备份,如果需要恢复以前的全备份,需要设置until time。
restore database;
#应用archive log
recover database;
release channel ch00;
release channel ch01;
}
 
2.     基于时间点恢复命令
run {
#分配通道
allocate channel ch00 type sbt_tape; 
allocate channel ch01 type sbt_tape;
#设置恢复时间点
set until time "to_date('2009-11-20 17:30:00','yyyy-mm-dd HH24:MI:SS')";
#恢复数据库并做
restore database;
#使用archive log把数据库恢复到until time设定的时间点。
recover database;
release channel ch00;
release channel ch01;
}
3.     基于seqence恢复命令
run {
allocate channel ch00 type sbt_tape;
allocate channel ch01 type sbt_tape;
restore database
#使用archive log把数据库恢复到指定的seqence#
recover database until sequence 29 thread 1;
release channel ch00;
release channel ch01;
}
 
rman不会恢复temp表空间,所以数据库恢复成功后,DBA需要重建temp表空间。
恢复数据库时有两种可选方法:
nocatalog方式,命令:rman target / nocatalog。
catalog 方式,命令:rman target / catalog rman/rman@rman
恢复数据库时建议采用nocatalog方式,因为catalog方式恢复成功后,catalog database中会记录恢复状态标志,需要手工在catalog database中reset database后才可以继续备份,而nocatalog方式没有这个问题。

相关内容