--恢复整个数据库
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 不报错
SYS@ 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'

SYS@ test11g> alter system switch logfile;
System altered.

SYS@ test11g> alter database drop logfile member '/u01/app/oracle/oradata/test11g/redo01a.log';
Database altered.

SYS@ 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)
SYS@ 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'

SYS@ test11g> startup mount
SYS@ 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'

SYS@ test11g>  recover database until cancel;
Media recovery complete.
SYS@ 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的时候会报错
SYS@ 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;

SYS@ test11g> recover database until cancel using backup controlfile;
先 auto 再 cancel

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

System altered.

SYS@ 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

SYS@ test11g> alter database open resetlogs;

Database altered.

SYS@ test11g> alter system reset "_allow_resetlogs_corruption" scope=spfile;

System altered.

SYS@ test11g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ 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.

Oracle rman 各种恢复的更多相关文章

  1. Oracle RMAN备份恢复指导书

    目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...

  2. Oracle Rman备份恢复和管理

    参考资料: Oracle之Rman入门指南 一步一步学Rman Rman简介 Rman-Recover manager恢复管理工具. Oracle集成了很多环境的一个数据库备份和恢复的工具. Rman ...

  3. RMAN的恢复篇

    Oracle 数据库的恢复实际上包含了两个概念:数据库修复(RESTORE)与数据库恢复(RECOVER): 数据库修复:是指利用备份的数据库文件来替换已经损坏的数据库文件或者将其恢复到一个新的位置. ...

  4. oracle rman恢复数据库 方式恢复到异地数据库

    目的:从某个环境中,获取相关文件,放到异地机器使用rman 恢复.   情况说明:XX系统使用的是oracle数据库,现已从服务器拉下来相关文件,依靠这些文件来早本地的测试机上恢复数据库,方便进行数据 ...

  5. oracle rman异机恢复

      Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.16 ...

  6. Oracle RMAN 恢复数据库到不同主机(一)

    一.RMAN 备份的内容 RMAN做数据库全备时包含了 数据文件.归档日志.控制文件和参数文件和备份日志,如下: arch_20160223_08qukp2t_1_1  arch_20160223_0 ...

  7. rman恢复方案和oracle异机恢复

    这篇文章主要介绍了rman恢复方案和oracle异机恢复,需要的朋友可以参考下 注:①恢复的前提是已经做好备份②完全恢复数据库是数据库遇到故障,在恢复时候没有丢失任何已经提交事物数据的恢复不完全恢复数 ...

  8. Oracle Rman恢复

    (转自:http://blog.chinaunix.net/uid-14779297-id-1988309.html) RMAN的基本概念 Target Database:就是需要RMAN对其进行备份 ...

  9. Oracle RMAN 学习:恢复

    Oracle RMAN 学习:恢复 6 rman恢复 Rman中的恢复对应restore,recover Restore,数据修复,利用备份集的数据文件来替换已损坏的数据文件或将其恢复到另外一个位置, ...

随机推荐

  1. centos7使用Gogs搭建Git服务器

    一.初次接触Gogs,记录一下搭建过程 二.平台环境 Linux: CentOS7.5.1804 MySQL: 5.6.35 安装步骤: linux服务器新建git用户: 下载.解压gogs安装包: ...

  2. Python 3.6 爬取BD电影网

    2018-07-10 #coding:utf-8 #coding:utf-8 from lxml import etree import requests import pandas import t ...

  3. 学习bash——环境配置

    一.环境配置文件的重要性 Bash在启动时直接读取这些配置文件,以规划好bash的操作环境. 即使注销bash,我们的设置仍然保存. 二.login shell 通过完整的登录流程取得的bash,称为 ...

  4. Week1 Team Homework #2 from Z.XML-Introduction of team member with photos

    <Z.XML Introduction of each team member, with photos Z=周敏轩; X=肖俊鹏&薛亚杰; M= 毛宇 & 马辰; L=  李孟 ...

  5. mysql数据库,编码错误解决

    在写代码的过程中,经常会遇见,将中文字符输入到mysql数据库中,但是查看的时候,却发现,中文显示为乱码的情况,让人相当的头疼,今天正好解决了一个这样遇到的问题,所以简单总结一下: 1.首先查看数据库 ...

  6. Python 随笔01---列表

    列表 1.取出列表中的元素方法?? 2.删除列表中的元素del.remove对比?? 3.linux 常用操作命令

  7. 给Python初学者的一些编程建议

    Python是一种非常富有表现力的语言.它为我们提供了一个庞大的标准库和许多内置模块,帮助我们快速完成工作.然而,许多人可能会迷失在它提供的功能中,不能充分利用标准库,过度重视单行脚本,以及误解Pyt ...

  8. java csv list cant not repeat

    require: /** * before: * file A1.csv {1,2,3,4,5} * file A2.csv {2,3,9,10,11} * file B1.csv {5,12,13, ...

  9. 【bzoj1977】[BeiJing2010组队]次小生成树 Tree 最小生成树+权值线段树合并

    题目描述 求一张图的严格次小生成树的边权和,保证存在. 输入 第一行包含两个整数N 和M,表示无向图的点数与边数. 接下来 M行,每行 3个数x y z 表示,点 x 和点y之间有一条边,边的权值为z ...

  10. 感觉自己应该重新读一次Javascript

    我自己也有一本Javascript书籍,是自己上大学的时候学校给提供的,现在,我依旧带着这本书.我决定要把这本书在重新温习一下.然后,开启下面的Javascript之旅.这是我看到博客园一位园友写的, ...