Oracle rman 各种恢复

--恢复整个数据库
run {
shutdown immediate;
startup mount;
restore database;
recover database;
alter database open;
}

--恢复表空间users
run {
sql ‘alter tablespace users offline‘;
restore tablespace users;
recover tablespace users;
sql ‘alter tablespace data online‘;
}

--恢复数据文件
适用所有表空间数据文件
run{
shutdown immediate;
startup mount;
restore datafile ‘/u01/app/oracle/oradata/data01.dbf‘;
recover datafile ‘/u01/app/oracle/oradata/data01.dbf‘;
alter database open;
}

非system表空间的数据文件,也可以直接在open状态下restore和recover
run {
sql ‘alter database datafile 6 offline‘;
restore datafile 6;
recover datafile 6;
sql ‘alter database datafile 6 online‘;
}

--临时表空间损坏
重新建立一个临时表空间
SQL> create temporary tablespace temp1 
tempfile ‘/u01/app/oracle/oradata/test10g/temp101.dbf‘ size 200M ;

将建好的TEMP1表空间设置为数据库默认的临时表空间
SQL> alter database default temporary tablespace temp1;

DROP掉旧的TEMP的表空间 
SQL> drop tablespace temp including contents and datafiles;

--全部控制文件损坏
run {
shutdown immediate;
startup nomount;
set dbid=1187100180;
restore controlfile from ‘/u01/backup/20131202_TEST11G_64.bak‘;
alter database mount;
recover database;
alter database open resetlogs;
}
打开后对数据库做一次全备份

--spfile损坏
run {
shutdown immediate;
startup nomount;
set dbid=1176041295;
restore spfile from ‘/u01/backup/20131202_TEST11G_64.bak‘;
shutdown immediate;
startup;
}

--非当前日志成员损坏
SQL> startup 不报错

SQL> select status,member from v$logfile;
SQL> alter database drop logfile member ‘/u01/app/oracle/oradata/test11g/redolog3a.log‘;
SQL> alter database add logfile member ‘/u01/app/oracle/oradata/test11g/redolog3a.log‘ to group 1;

--当前日志成员损坏
SQL> startup 不报错
[email protected] test11g> alter database drop logfile member ‘/u01/app/oracle/oradata/test11g/redo01a.log‘;
alter database drop logfile member ‘/u01/app/oracle/oradata/test11g/redo01a.log‘
*
ERROR at line 1:
ORA-01609: log 1 is the current log for thread 1 - cannot drop members
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01.log‘
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01a.log‘

[email protected] test11g> alter system switch logfile;
System altered.

[email protected] test11g> alter database drop logfile member ‘/u01/app/oracle/oradata/test11g/redo01a.log‘;
Database altered.

[email protected] test11g> alter database add logfile member ‘/u01/app/oracle/oradata/test11g/redo01a.log‘ to group 1;
Database altered.

--备用
SQL> alter database clear logfile group 1;
alter database clear logfile group 1
*
ERROR at line 1:
ORA-00350: log 1 of instance orcl (thread 1) needs to be archived
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01a.log‘

失败的原因是group 1还没有归档,需要加上"unarchived"参数;
SQL> alter database clear unarchived logfile group 1;
Database altered. 
SQL> alter database open;
Database altered.

--非当前日志组损坏
SQL> startup
Errors in file /u01/app/oracle/diag/rdbms/test11g/test11g/trace/test11g_lgwr_16823.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: ‘/u01/app/oracle/oradata/test11g/redolog3a.log‘
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: ‘/u01/app/oracle/oradata/test11g/redolog3.log‘
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory

SQL> startup mount;
SQL> alter database clear logfile group 3;
SQL> alter database open;

--当前日志组损坏(CURRENT)
[email protected] test11g> startup
Errors in file /u01/app/oracle/diag/rdbms/test11g/test11g/trace/test11g_ora_20114.trc:
ORA-00313: open failed for members of log group 1 of thread 
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01.log‘
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01a.log‘

[email protected] test11g> startup mount
[email protected] test11g>  alter database drop logfile group 1;
 alter database drop logfile group 1
*
ERROR at line 1:
ORA-01623: log 1 is current log for instance test11g (thread 1) - cannot drop
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01.log‘
ORA-00312: online log 1 thread 1: ‘/u01/app/oracle/oradata/test11g/redo01a.log‘

[email protected] test11g>  recover database until cancel;
Media recovery complete.
[email protected] test11g>  alter database open resetlogs;
Database altered.

做一次rman全备份

--恢复归档日志
RMAN> run
2> {
3> SET ARCHIVELOG DESTINATION TO ‘/u02/archive‘;
4> restore archivelog sequence between 65 and 67;
5> }

--不完全恢复(until scn/time/sequence)
mount下
set until time ‘MAR 21 2005 06:00:00‘
set until scn 1000
set until sequence 9923

RMAN> startup mount;
RMAN> run 
2> {
3>   set until time "to_date(‘20131129 11:29:05‘,‘yyyymmdd hh24:mi:ss‘)";
4>   restore database;
5>   recover database;
6> }
RMAN> alter database open resetlogs;
做一次rman全备份


RMAN> run {
2> restore database from tag=TAG20131209T153042;
3> recover database from tag=TAG20131209T153042;
4> }
做一次rman全备份

如果有rman数据文件备份和控制文件备份,但丢失归档日志,recover的时候会报错
[email protected] test11g> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 2 needs more recovery to be consistent
ORA-01110: data file 2: ‘/u01/app/oracle/oradata/test11g/sysaux01.dbf‘

RMAN> startup nomout;
RMAN> restore controlfile from ‘/u01/backup/20131209_TEST11G_93.bak‘;
RMAN> alter database mount;
RMAN> restore database from tag=TAG20131209T153042;

1、如果有部分归档
这个时候我们只能使用丢失的归档日志前的日志进行恢复。
RMAN> recover database until sequence=2 thread=1;
RMAN> alter database open resetlogs;

[email protected] test11g> recover database until cancel using backup controlfile;
先 auto 再 cancel

2、如果没有归档
mount状态下执行:
[email protected] test11g> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

[email protected] test11g> startup force;
ORACLE instance started.

Total System Global Area  301322240 bytes
Fixed Size                  1336092 bytes
Variable Size             251661540 bytes
Database Buffers           41943040 bytes
Redo Buffers                6381568 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

[email protected] test11g> alter database open resetlogs;

Database altered.

[email protected] test11g> alter system reset "_allow_resetlogs_corruption" scope=spfile;

System altered.

[email protected] test11g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[email protected] test11g> startup
ORACLE instance started.

Total System Global Area  301322240 bytes
Fixed Size                  1336092 bytes
Variable Size             251661540 bytes
Database Buffers           41943040 bytes
Redo Buffers                6381568 bytes
Database mounted.
Database opened.

时间: 2024-10-24 22:31:54

Oracle rman 各种恢复的相关文章

Oracle RMAN备份恢复1-基础篇_超越OCP精通Oracle视频教程培训17

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库RMAN备份恢复基础,如rman作用与体系架构,nocatalog和catalog介绍与catalog配置,详解rman的使用,详解rman常用的命令list,report, backup,configure,set,crosscheck,validate,change,delete,restore,recover,switch,blockrecover,convert等使用. 适用人群 IT相关从

Oracle RMAN备份恢复2-案例篇_超越OCP精通Oracle视频教程培训18

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库如何设计一个TB级数据库的RMAN备份策略,RMAN备份与恢复案例-丢失所有文件,丢失单个数据文件,丢失整个数据和system表空间,丢失控制文件和参数文件,存储损坏数据丢失,丢失REDO重做日志文件,基于时间点,scn,cancel,备份控制文件的不完成恢复案例. 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: http://edu.51c

Oracle RMAN备份恢复3-高级篇_超越OCP精通Oracle视频课程培训19

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库关于RMAN内存缓冲与块跟踪,DBMS_BACKUP_RESTORE,使用RMAN BlockRecover恢复坏块,RMAN Recovery Advisor 案例,RMAN备份压缩技术,RMAN增量备份恢复,RMAN备份加密,RMAN克隆数据库,生产环境RMAN异机恢复的几种经典场景案例 . 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址:

Oracle RMAN备份恢复指导书

目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库... 3 4.1.3 查看备份信息... 3 4.1.4 备份数据库... 5 4.1.5 备份数据文件... 6 4.1.6 备份表空间... 6 4.1.7 备份控制文件... 6 4.1.8 备份归档日志文件... 7 4.1.9 备份闪回区... 8 4.1.10 增量备份... 8 4.2

第22章 oracle RMAN备份恢复

2015-10-24 目录 参考资料 [1] 林树泽.Oracle 11g R2 DBA操作指南[M].北京:清华大学出版社,2013 [2] Oracle备份与恢复介绍(物理备份与逻辑备份) [3] Oracle备份与恢复案例 [4] ORACLE 备份与恢复 [5] Oracle数据库的备份方法 [6] oracle之rman入门指南 [7] ORACLE RMAN备份及还原 [8] rman备份恢复实例(经典) [9] RMAN 备份详解 [10] RMAN 还原与恢复 [11] RMAN

Oracle RMAN 自动恢复

在日常工作中,有时会需要进行Oracle数据库恢复,比如搭建测试环境.查找历史数据.恢复测试等. 可以通过计划任务或nohup等方式来执行恢复脚本从而提高整个操作的效率,特此记录. 这里使用的测试环境如下: OS Platform Red Hat Enterprise Linux Server release 5.4 (Tikanga)- 64bit Database Oracle Database 11g Enterprise Edition Release 11.2.0.1.0- 64bit

关于Oracle RMAN 自动恢复

在日常工作中,有时会需要进行Oracle数据库恢复,比如搭建测试环境.查找历史数据.恢复测试等.可以通过计划任务或nohup等方式来执行恢复脚本从而提高整个操作的效率,特此记录. 这里使用的测试环境如下: OS Platform Red Hat Enterprise Linux Server release 5.4 (Tikanga)- 64bit Database Oracle Database 11g Enterprise Edition Release 11.2.0.1.0- 64bit

Oracle数据库备份恢复高级培训视频课程(案例、实战、深入、全面)

套餐介绍: 介绍:风哥Oracle数据库备份恢复培训(案例.实战.深入.全面),DBA初级到骨灰级的脱变. 内容:风哥Oracle数据库备份恢复及存储容灾基础,控制文件与参数文件详解,存储结构深入分析,Oracle底层技术,数据块解析,BBED深入解析,重做日志Redo深入解析,Undo回滚段深入解析,用户管理模式的备份恢复,RMAN备份恢复,Flashback闪回恢复管理,LogMiner日志挖掘技术,SQL_Loader,Oracle逻辑备份恢复迁移之exp/imp和expdp/impdp.

[转]Oracle DB 使用RMAN执行恢复

? 在丢失关键或非关键数据文件后执行完全恢复 ? 使用增量更新的备份进行恢复 ? 切换到映像副本进行快速恢复 ? 将数据库还原到新主机上 ? 使用备份控制文件进行恢复 使用RMAN RESTORE和RECOVER命令 ? RESTORE命令:从备份中还原数据库文件 ? RECOVER命令:通过应用增量备份和重做日志文件中记录的更改来恢复已还原文件 RMAN> SQL 'ALTER TABLESPACE inv_tbs OFFLINE IMMEDIATE'; RMAN> RESTORE TABL