[20160816]11G dataguard坏块修复.txt
--11GR2 不仅仅支持在备库在只读的情况下,日志应用(ACTIVE Data Guard),还提供主备库的坏块修复.自己以前也做过相关测试,
--我记得上次测试的仅仅是主库数据块损坏,没有测试备库的数据块损坏.补充一些测试:
1.环境:
SYS@test> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.3.0 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
DGMGRL> show configuration
Configuration - study
Protection Mode: MaxPerformance
Databases:
test - Primary database
testdg - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
2.建立测试数据块:
create table empx tablespace testmssm as select * fromo emp ;
SCOTT@test> select rowid,empx.* from empx where rownum=1;
ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
AABLsNAAJAAAACJAAA 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
SCOTT@test> @ &r/rowid AABLsNAAJAAAACJAAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
310029 9 137 0 0x2400089 9,137 alter system dump datafile 9 block 137 ;
--//安全起见,备份数据文件.
RMAN> backup datafile 9 format '/data/testtest/testmssm_%U';
Starting backup at 2016-08-16 10:11:44
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/u01/app/oracle11g/oradata/test/testmssm01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-08-16 10:11:46
channel ORA_DISK_1: finished piece 1 at 2016-08-16 10:11:49
piece handle=/data/testtest/testmssm_bhrdcsr2_1_1 tag=TAG20160816T101145 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2016-08-16 10:11:50
Starting Control File and SPFILE Autobackup at 2016-08-16 10:11:51
piece handle=/u01/app/oracle11g/flash_recovery_area/TEST/autobackup/2016_08_16/o1_mf_s_920023912_cv4xmb2m_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2016-08-16 10:11:55
SCOTT@test> alter system checkpoint;
System altered.
SCOTT@test> alter system flush buffer_cache;
System altered.
3.使用bbed破坏(主库):
BBED> set dba 9,137
DBA 0x02400089 (37748873 9,137)
BBED> corrupt
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Block marked media corrupt.
--测试:
SCOTT@test> select rowid,empx.* from empx where rownum=1;
select rowid,empx.* from empx where rownum=1
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 9, block # 137)
ORA-01110: data file 9: '/u01/app/oracle11g/oradata/test/testmssm01.dbf'
SCOTT@test> select rowid,empx.* from empx where rownum=1;
ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
AABLsNAAJAAAACJAAA 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
--检查主库alert*.log
Tue Aug 16 10:13:11 2016
Errors in file /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_11093_127_0_0_1.trc (incident=3145807):
ORA-01578: ORACLE data block corrupted (file # 9, block # 137)
ORA-01110: data file 9: '/u01/app/oracle11g/oradata/test/testmssm01.dbf'
Incident details in: /u01/app/oracle11g/diag/rdbms/test/test/incident/incdir_3145807/test_ora_11093_i3145807.trc
Tue Aug 16 10:13:16 2016
Sweep [inc][3145807]: completed
Tue Aug 16 10:13:16 2016
Dumping diagnostic data in directory=[cdmp_20160816101316], requested by (instance=1, osid=11093), summary=[incident=3145807].
Tue Aug 16 10:13:17 2016
Sweep [inc2][3145807]: completed
Checker run found 1 new persistent data failures
Tue Aug 16 10:13:26 2016
Errors in file /u01/app/oracle11g/diag/rdbms/test/test/trace/test_ora_11093_127_0_0_1.trc (incident=3145808):
ORA-01578: ORACLE data block corrupted (file # 9, block # 137)
ORA-01110: data file 9: '/u01/app/oracle11g/oradata/test/testmssm01.dbf'
Incident details in: /u01/app/oracle11g/diag/rdbms/test/test/incident/incdir_3145808/test_ora_11093_i3145808.trc
Tue Aug 16 10:13:28 2016
Dumping diagnostic data in directory=[cdmp_20160816101328], requested by (instance=1, osid=11093), summary=[incident=3145808].
Starting background process ABMR
Tue Aug 16 10:13:29 2016
ABMR started with pid=46, OS id=17268
Automatic block media recovery service is active.
Automatic block media recovery requested for (file# 9, block# 137)
Tue Aug 16 10:13:30 2016
Automatic block media recovery successful for (file# 9, block# 137)
Automatic block media recovery successful for (file# 9, block# 137)
4.使用bbed破坏(备库):
BBED> set dba 9,137
DBA 0x02400089 (37748873 9,137)
BBED> corrupt
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Block marked media corrupt.
--测试:
SCOTT@testdg> select rowid,empx.* from empx where rownum=1;
select rowid,empx.* from empx where rownum=1
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 9, block # 137)
ORA-01110: data file 9: '/u01/app/oracle11g/oradata/test/testmssm01.dbf'
SCOTT@testdg> select rowid,empx.* from empx where rownum=1;
ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
AABLsNAAJAAAACJAAA 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20
--检查备库alert*.log
Dumping diagnostic data in directory=[cdmp_20160816101617], requested by (instance=1, osid=6960), summary=[incident=152714].
Automatic block media recovery requested for (file# 9, block# 137)
Automatic block media recovery successful for (file# 9, block# 137)
Errors in file /u01/app/oracle11g/diag/rdbms/testdg/testdg/trace/testdg_ora_6960_127_0_0_1.trc (incident=152715):
ORA-01578: ORACLE data block corrupted (file # 9, block # 137)
ORA-01110: data file 9: '/u01/app/oracle11g/oradata/test/testmssm01.dbf'
Incident details in: /u01/app/oracle11g/diag/rdbms/testdg/testdg/incident/incdir_152715/testdg_ora_6960_i152715.trc
Tue Aug 16 10:16:20 2016
Automatic block media recovery requested for (file# 9, block# 137)
Automatic block media recovery successful for (file# 9, block# 137)
Dumping diagnostic data in directory=[cdmp_20160816101621], requested by (instance=1, osid=6960), summary=[incident=152715].
--仔细检查可以发现如果备库发现问题,不会启动ambr进程,而是通过主库传输
--备库:
$ ps -ef | grep abm[r]
--主库:
$ ps -ef | grep abm[r]
503 17268 1 0 10:13 ? 00:00:00 ora_abmr_test