[20160704]Block recover using RMAN.txt
[20160704]Block recover using RMAN.txt
--总结一下使用rman恢复坏块.
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> create table emp2 tablespace tea as select * from emp ;
Table created.
SCOTT@book> select rowid from emp2 where rownum<=1;
ROWID
------------------
AAAXKZAAHAAAACDAAA
SCOTT@book> @ &r/rowid AAAXKZAAHAAAACDAAA
OBJECT FILE BLOCK ROW DBA TEXT
---------- ---------- ---------- ---------- -------------------- ----------------------------------------
94873 7 131 0 7,131 alter system dump datafile 7 block 131 ;
2.备份:
RMAN> backup datafile 7 format '/home/oracle/backup/datafile_7_20160704.bak';
Starting backup at 2016-07-04 09:53:39
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=123 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=134 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=145 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-07-04 09:53:40
channel ORA_DISK_1: finished piece 1 at 2016-07-04 09:53:41
piece handle=/home/oracle/backup/datafile_7_20160704.bak tag=TAG20160704T095340 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-07-04 09:53:41
Starting Control File and SPFILE Autobackup at 2016-07-04 09:53:41
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2016_07_04/o1_mf_s_916307621_cqmjf5o4_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2016-07-04 09:53:42
3.破坏使用dd命令:
$ dd if=/dev/null of=/mnt/ramdisk/book/tea01.dbf bs=8192 count=1 seek=131 conv=notrunc
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.5781e-05 seconds, 0.0 kB/s
--注意if使用/dev/null 不行.另外注意加conv=notrunc,不要在生产系统做这个测试.
$ dd if=/dev/zero of=/mnt/ramdisk/book/tea01.dbf bs=8192 count=1 seek=131 conv=notrunc
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 3.4219e-05 seconds, 239 MB/s
SCOTT@book> select * from emp2 where rownum<=2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30
--//因为数据还在缓存中,如果清除缓存,就报错了.
SCOTT@book> alter system flush buffer_cache;
System altered.
SCOTT@book> select * from emp2 where rownum<=2;
select * from emp2 where rownum<=2
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 131)
ORA-01110: data file 7: '/mnt/ramdisk/book/tea01.dbf'
SCOTT@book> select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
7 131 1 0 ALL ZERO
--//使用rman检查:
RMAN> validate datafile 7;
Starting validate at 2016-07-04 10:02:24
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00007 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 FAILED 0 169 2305 13243764038
File Name: /mnt/ramdisk/book/tea01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 1924
Index 0 0
Other 1 211
validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_59407.trc for details
Finished validate at 2016-07-04 10:02:25
$ dbv file=/mnt/ramdisk/book/tea01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Jul 4 10:03:19 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/book/tea01.dbf
Page 131 is marked corrupt
Corrupt block relative dba: 0x01c00083 (file 7, block 131)
Completely zero block found during dbv:
DBVERIFY - Verification complete
Total Pages Examined : 2304
Total Pages Processed (Data) : 1924
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 210
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 169
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 358862150 (3.358862150)
4.使用rman修复:
RMAN> blockrecover datafile 7 block 131;
Starting recover at 2016-07-04 10:04:24
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00007
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/datafile_7_20160704.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/datafile_7_20160704.bak tag=TAG20160704T095340
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 2016-07-04 10:04:26
SCOTT@book> select * from emp2 where rownum<=2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30
--如果坏块很多,可以使用blockrecover corruption list;
--重复测试:
$ dd if=/dev/zero of=/mnt/ramdisk/book/tea01.dbf bs=8192 count=1 seek=131 conv=notrunc
--//注意一个细节,dbv可以检查文件,但是错误不会出现视图v$database_block_corruption;
--//同样select * from emp2 where rownum<=2;报ORA-01578,有时候也不出现在视图v$database_block_corruption中.
SCOTT@book> select * from emp2 where rownum<=2;
select * from emp2 where rownum<=2
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 7, block # 131)
ORA-01110: data file 7: '/mnt/ramdisk/book/tea01.dbf'
SCOTT@book> select * from v$database_block_corruption;
no rows selected
--//仅仅在rman下使用validate datafile 7;或者validate database或者validate tablespace才可以.
RMAN> validate tablespace tea;
Starting validate at 2016-07-04 10:09:50
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00007 name=/mnt/ramdisk/book/tea01.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7 FAILED 0 169 2305 13243764038
File Name: /mnt/ramdisk/book/tea01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 1924
Index 0 0
Other 1 211
validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_59407.trc for details
Finished validate at 2016-07-04 10:09:51
SCOTT@book> select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
7 131 1 0 ALL ZERO
--//这个测试blockrecover corruption list;忽略.
SCOTT@book> @ &r/convrdba 7 131
RDBA16 RDBA
-------------- ----------
1c00083 29360259
--还可以直接使用rdba地址.
--recover datafile 7 29360259; 不行
--recover tablespace tea dba 0x1c00083 ; 不行,必须使用十进制数.
RMAN> recover tablespace tea dba 29360259 ;
Starting recover at 2016-07-04 10:15:15
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00007
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/datafile_7_20160704.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/datafile_7_20160704.bak tag=TAG20160704T095340
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 2016-07-04 10:15:18
SCOTT@book> select * from v$database_block_corruption;
no rows selected
SCOTT@book> select * from emp2 where rownum<=2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30
--实际上还可以这样写:
RMAN> recover datafile 7 block 131;
Starting recover at 2016-07-04 10:18:01
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00007
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/datafile_7_20160704.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/datafile_7_20160704.bak tag=TAG20160704T095340
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:03
--//感觉这个更加人性化.
5.总结:
blockrecover datafile &file# block &block#
blockrecover corruption list;
recover tablespace tea dba 29360259;
recover datafile &file# block &block#
--//注意一个问题就是仅仅在rman下使用命令validate ,有问题的块才会记录在v$database_block_corruption视图中.
--//以此做一个全面总结.
[20160704]Block recover using RMAN.txt相关推荐
- 是用bbed工具模拟对块的破坏,并使用rman bock recover进行块恢复
第一部分 . 概述 一. 实验环境 运行环境: [root@localhost ~]# lsb_release -a LSB Version: :core-3.1-ia ...
- ORACLE 12c rac备份异机单实例恢复(RMAN recover database出现RMAN-06054)
1.首先在源rac 环境创造 数据,任何能体现与恢复环境不同的情况都可以. 本次模拟环境的目标机器上有一个db名与rac库一致的单实例db简略部分步骤 insert into test.table1 ...
- ORACLE 备份恢复之RMAN详解
一.连接方式 (一).连接本地数据库 [oracle@oracle ~]$ rman target / (二).连接远程数据库 [oracle@oracle ~]$ rman target sys/o ...
- Oracle RMAN中备份表空间名为'TEST'时需要注意的问题
'TEST'算是oracle的一个保留字,因此在有些地方使用时要注意,目前我发现在rman中备份时oracle把它作为保留字对待. TEST在rman里确实是保留字... 备份其它表空间时只需要直接写 ...
- 基于rman 全备+归档在线搭建DG
主从两台主机hosts配置 192.168.1.197 oradb1(从) 192.168.1.198 oradb2(主) 二:搭建数据库 主库的操作: 1.确认主库参数 SQL> select ...
- 【转】RMAN 高级恢复
来源:http://blog.csdn.net/tianlesoftware/article/details/5722174 1. 不完全恢复 2. 基于RMAN 的恢复主题 3. 表空间时间点恢复 ...
- Oracle corrupt block(坏块) 详解
转自:http://blog.csdn.net/tianlesoftware/article/details/5024966 一. 坏块说明 1.1 相关链接 在看坏块之前,先看几个相关的链接,在后面 ...
- RMAN的备份与恢复
文章目录 1 物理备份 1.1 完全备份(full) 1.2 差异/增量备份(differential) 1.2.1 0级备份 1.2.2 差异增量1级备份 1.2.3 差异增量2级备份 1.3 累积 ...
- 053试题 193 - recover 命令
题目: 193.What is the purpose of the recover command? (Choose all that apply.) A. Recover database dat ...
最新文章
- 蓝桥杯_算法训练_矩阵乘法
- java有画图的库吗_Java画图
- python子进程关闭fd_如果创建了multiprocessing.Pool,Python子进程wait()将失败
- ubuntu18.10终端的方块改成竖线
- MYSQL性能优化详解(二)
- (转)Cortex-M3 (NXP LPC1788)之GPIO
- android 访问服务器sql_一次服务器被传webshell事件溯源
- java中怎样调用抽象类中的非抽象方法?(对原文做修改,加入一点自己理解)
- nc财务系统适配的java_用友NC系统使用过程中常见问题和解决方法!财会必看!...
- 双光耦开关电源电路图_开关电源光耦的工作原理及典型接法
- C语言中文网的资源的使用——链接索引
- 论文阅读笔记 | Enemy At the Gateways:Censorship-Resilient Proxy Distribution Using Game Theory(NDSS 2019)
- 利用AUI实现多种多样的timeline时间轴样式
- Unity中图片挖洞
- 无线网络-何为ISM频段?
- 三星M8 智能显示器 评测
- python-docx对Word文档的指定位置(批量)插入图片
- 加边的无向图(并查集)
- 日常电脑操作小技能篇(生活无处不精彩)
- 国内外十大ERP软件系统排名!
热门文章
- AD的备份与标准还原:深入浅出Active Directory系列(四)
- 2003单网卡实现***,nat共享网络
- Node-ipc 热门包作者投毒“社死‘’,谁来保护开源软件供应链安全?
- php自定义函数记录一
- 转] 两种自定义表单设计方案
- MySQL中的几类日志文件介绍
- 一步一步利用django创建博客应用(三)
- 面向对象(二) 继承/里氏替换
- 不重启程序使用最新版package
- Linux/Unix服务端和客户端Socket编程入门实例(含源码下载)