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 不报错
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 各种恢复的更多相关文章
- Oracle RMAN备份恢复指导书
目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...
- Oracle Rman备份恢复和管理
参考资料: Oracle之Rman入门指南 一步一步学Rman Rman简介 Rman-Recover manager恢复管理工具. Oracle集成了很多环境的一个数据库备份和恢复的工具. Rman ...
- RMAN的恢复篇
Oracle 数据库的恢复实际上包含了两个概念:数据库修复(RESTORE)与数据库恢复(RECOVER): 数据库修复:是指利用备份的数据库文件来替换已经损坏的数据库文件或者将其恢复到一个新的位置. ...
- oracle rman恢复数据库 方式恢复到异地数据库
目的:从某个环境中,获取相关文件,放到异地机器使用rman 恢复. 情况说明:XX系统使用的是oracle数据库,现已从服务器拉下来相关文件,依靠这些文件来早本地的测试机上恢复数据库,方便进行数据 ...
- oracle rman异机恢复
Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.16 ...
- Oracle RMAN 恢复数据库到不同主机(一)
一.RMAN 备份的内容 RMAN做数据库全备时包含了 数据文件.归档日志.控制文件和参数文件和备份日志,如下: arch_20160223_08qukp2t_1_1 arch_20160223_0 ...
- rman恢复方案和oracle异机恢复
这篇文章主要介绍了rman恢复方案和oracle异机恢复,需要的朋友可以参考下 注:①恢复的前提是已经做好备份②完全恢复数据库是数据库遇到故障,在恢复时候没有丢失任何已经提交事物数据的恢复不完全恢复数 ...
- Oracle Rman恢复
(转自:http://blog.chinaunix.net/uid-14779297-id-1988309.html) RMAN的基本概念 Target Database:就是需要RMAN对其进行备份 ...
- Oracle RMAN 学习:恢复
Oracle RMAN 学习:恢复 6 rman恢复 Rman中的恢复对应restore,recover Restore,数据修复,利用备份集的数据文件来替换已损坏的数据文件或将其恢复到另外一个位置, ...
随机推荐
- static 关键字解析(转)
static关键字解析 Java中的static关键字解析 static关键字是很多朋友在编写代码和阅读代码时碰到的比较难以理解的一个关键字,也是各大公司的面试官喜欢在面试时问到的知识点之一.下面 ...
- js保留两位小数,不四舍五入
//不进行四舍五入,保留两位小数 function getKeepTwoDecimals(val) { var newVal = (parseInt(val * 100) / 100).toFixed ...
- el-table中操作一栏怎么根据当前行的信息显示编辑、删除、编辑完成按钮
对每个按钮是否显示,使用v-show绑定变量,因为每一行的v-show绑定的变量必须是唯一的(不然的话操作此行,其他行的状态也会跟着变化),所以不可能提前在.ts中对变量进行初始化,只能使用本行的字段 ...
- 在浏览器中从FTP下载文件
public static class FTPHelper { /// <summary> /// 得到特定FTP目录的文件列表 /// </summary> /// < ...
- 【bzoj2453】维护队列/【bzoj2120】数颜色 分块+二分
题目描述 你小时候玩过弹珠吗? 小朋友A有一些弹珠,A喜欢把它们排成队列,从左到右编号为1到N.为了整个队列鲜艳美观,小朋友想知道某一段连续弹珠中,不同颜色的弹珠有多少.当然,A有时候会依据个人喜好, ...
- Div+Css中transparent制作奥运五环
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- P2563 [AHOI2001]质数和分解
题目描述 任何大于 1 的自然数 n 都可以写成若干个大于等于 2 且小于等于 n 的质数之和表达式(包括只有一个数构成的和表达式的情况),并且可能有不止一种质数和的形式.例如,9 的质数和表达式就有 ...
- [CF45G]Prime Problem
题目大意:将$1$到$n(1<n\leqslant6000)$分成若干组数,要求每组数的和均为质数,若存在一种分配方式,输出每个数所在的组的编号,有多组解输出任意一组解,若不存在,输出$-1$ ...
- [洛谷P1317]低洼地
题目大意:一组数,分别表示地平线的高度变化.高度值为整数,相邻高度用直线连接.找出并统计有多少个可能积水的低洼地?(首尾都为0) 题解:求出其中都多少个不严格下降子段和不严格上升子段所夹的位置,即为答 ...
- 【17.12.22.B】
B 题面描述: 给一个长度为n的序列,a[1], a[2], ... , a[n], 选出连续的k个数,使得这k个数的最大值加这k个数的or值最大. 假设选出的数为a[l], a[l + 1], .. ...