Oracle Dataguard 下块修复技术-用户数据表(二)

简介:
已经介绍了Oracle 11gr2 的ABCR功能,当有损坏的数据库被检索到时,会自动修复。

现在测试一下,当数据库块损坏并强制关闭实例的情况下,数据库还会不会做自动修复。
首先测试普通用户表 BAIYANG.T_OBJS
(一)当前主备环境

# 数据库版本
sys@ORCL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

# 数据库打开状态
sys@ORCL>  select dbid,current_scn,RESETLOGS_CHANGE#,flashback_on from v$database;

      DBID CURRENT_SCN RESETLOGS_CHANGE# FLASHBACK_ON
---------- ----------- ----------------- ------------------
1520403684     3039036           2917000 YES

# DG同步状态
DGMGRL> show configuration

Configuration - orcl

  Protection Mode: MaxPerformance
  Databases:
    orcl    - Primary database
    standby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

# 备库DG同步
SQL> select archived,max(sequence#),applied from v$archived_log group by archived,applied;

ARC MAX(SEQUENCE#) APPLIED
--- -------------- ---------
YES              9 IN-MEMORY

# 隐含参数 _auto_bmr 当前是开启的
col NAME for a30
col VALUE for a30
col describ for a40 

SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ FROM x$ksppi x,x$ksppcv y
  WHERE x.inst_id = USERENV ('Instance')
   AND y.inst_id = USERENV ('Instance')
   AND x.indx = y.indx
   AND x.ksppinm LIKE '%_auto_bmr%';
   
   
NAME                           VALUE                          DESCRIB
------------------------------ ------------------------------ ----------------------------------------
_auto_bmr                      ENABLED                        enable/disable Auto BMR
_auto_bmr_req_timeout          60                             Auto BMR Requester Timeout
_auto_bmr_sess_threshold       30                             Auto BMR Request Session Threshold
_auto_bmr_pub_timeout          10                             Auto BMR Publish Timeout
_auto_bmr_fc_time              60                             Auto BMR Flood Control Time
_auto_bmr_bg_time              3600                           Auto BMR Process Run Time
_auto_bmr_sys_threshold        100                            Auto BMR Request System Threshold
_auto_bmr_max_rowno            1024                           x$krbabrstat Max number of rows

8 rows selected.

(二)备份主库

RMAN> backup database;

(三)查看对象T_OBJS的segment分配

sys@ORCL> select segment_name,header_file , header_block,blocks from dba_segments where OWNER ='BAIYANG' and  segment_name ='T_OBJS';

SEGMENT_NAME                                                                      HEADER_FILE HEADER_BLOCK     BLOCKS
--------------------------------------------------------------------------------- ----------- ------------ ----------
T_OBJS                                                                                      4          298         48


sys@ORCL> select name ,file# from v$datafile;

NAME                                                                                                      FILE#
---------------------------------------------------------------------------------------------------- ----------
/u01/app/oracle/oradata/standby/datafile/system01.dbf                                                         1
/u01/app/oracle/oradata/standby/datafile/sysaux01.dbf                                                         2
/u01/app/oracle/oradata/standby/datafile/undotbs01.dbf                                                        3
/u01/app/oracle/oradata/standby/datafile/users01.dbf                                                          4
/u01/app/oracle/product/11.2.0/db_1/dbs/lxx2.dbf                                                              7

(四)接下来搞破坏并强制关闭主库

dd if=/dev/zero of=/u01/app/oracle/oradata/standby/datafile/users01.dbf bs=8192 seek=298 count=3 conv=notrunc
2+0 records in
2+0 records out
16384 bytes (16 kB) copied, 0.000394806 s, 41.5 MB/s

dd if=/dev/zero of=/u01/app/oracle/oradata/standby/datafile/users01.dbf bs=8192 seek=300 count=2 conv=notrunc
2+0 records in
2+0 records out
16384 bytes (16 kB) copied, 0.000394806 s, 41.5 MB/s

# 强制关闭数据库
sys@ORCL> shutdown abort
ORACLE instance shut down.

# 打开数据库,数据库可以正常打开
sys@ORCL> startup
ORACLE instance started.

Total System Global Area 2455228416 bytes
Fixed Size                  2255712 bytes
Variable Size             620758176 bytes
Database Buffers         1811939328 bytes
Redo Buffers               20275200 bytes
Database mounted.
Database opened.

(五)如果这时直接查询表,那么坏块会被自动修复;先使用RMAN验证下数据,并确认有坏块

RMAN> backup validate database datafile 4;

sys@ORCL> select * from v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         4        304          2                  0 ALL ZERO
         4        299          3                  0 ALL ZERO

(六)查询表

sys@ORCL> select count(*) from BAIYANG.T_OBJS;

  COUNT(*)
----------
      7513

# 以下全表查询时会检索有所的数据块,此时会修复坏块 
sys@ORCL> select * from BAIYANG.T_OBJS;
…………     
DBA_STREAMS_STMT_HANDLERS
_DBA_STREAMS_STMTS
DBA_STREAMS_STMTS
DBA_STREAMS_STMTS
_DBA_APPLY_CHANGE_HANDLERS
DBA_APPLY_CHANGE_HANDLERS
DBA_APPLY_CHANGE_HANDLERS

8001 rows selected.

# alter_orcl.log
Corrupt Block Found
         TSN = 4, TSNAME = USERS
         RFN = 4, BLK = 299, RDBA = 16777515
         OBJN = 87356, OBJD = 87356, OBJECT = T_OBJS, SUBOBJECT = 
         SEGMENT OWNER = BAIYANG, SEGMENT TYPE = Table Segment
Corrupt Block Found
         TSN = 4, TSNAME = USERS
         RFN = 4, BLK = 300, RDBA = 16777516
         OBJN = 87356, OBJD = 87356, OBJECT = T_OBJS, SUBOBJECT = 
         SEGMENT OWNER = BAIYANG, SEGMENT TYPE = Table Segment
Sat Dec 08 13:50:31 2018
Automatic block media recovery successful for (file# 4, block# 301)
Sat Dec 08 13:50:31 2018
Automatic block media recovery successful for (file# 4, block# 299)
Automatic block media recovery successful for (file# 4, block# 299)
………………

Corrupt Block Found
         TSN = 4, TSNAME = USERS
         RFN = 4, BLK = 304, RDBA = 16777520
         OBJN = 87356, OBJD = 87356, OBJECT = T_OBJS, SUBOBJECT = 
         SEGMENT OWNER = BAIYANG, SEGMENT TYPE = Table Segment
Automatic block media recovery successful for (file# 4, block# 305)
Automatic block media recovery successful for (file# 4, block# 304)
Automatic block media recovery successful for (file# 4, block# 304)
Automatic block media recovery successful for (file# 4, block# 305)

(七)再次查询还有没有坏块

sys@ORCL> select * from v$database_block_corruption;

no rows selected

普通用户表块损坏不影响实例启动,启动时不验证用户表是否正常;
启动后在ADG情况下访问数据表时,会自动修复坏块。

目录
相关文章
|
3月前
|
Oracle 关系型数据库 数据库
手把手教你Oracle DataGuard主备切换(switchover)
手把手教你Oracle DataGuard主备切换(switchover)
546 4
|
6月前
|
运维 Oracle 容灾
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
Oracle dataguard 容灾技术实战(笔记),教你一种更清晰的Linux运维架构
|
3月前
|
Oracle 网络协议 安全
Oracle 11g DataGuard搭建保姆级教程
Oracle 11g DataGuard搭建保姆级教程
221 4
|
3月前
|
Oracle 网络协议 关系型数据库
Oracle DataGuard主备切换之自动切换
Oracle DataGuard主备切换之自动切换
168 2
|
3月前
|
SQL 存储 Oracle
"挑战极限!Oracle数据库精英试炼场:夺命连环5问,你能否一路披荆斩棘,登顶技术巅峰?"
【8月更文挑战第9天】Oracle,数据库领域的巨擘,以卓越的数据处理能力、稳定性和安全性成为企业级应用首选。今天我们带来“Oracle夺命连环25问”。首问:核心组件有哪些?答:实例(含内存结构和后台进程)、物理存储(数据文件、控制文件等)及逻辑存储(表空间、段等)。第二问:如何理解事务隔离级别?答:Oracle支持四种级别,默认READ COMMITTED,避免脏读,但可能遇到不可重复读和幻读。
47 0
|
5月前
|
弹性计算 Oracle 关系型数据库
技术好文共享:谁说阿里云不能跑Oracle,让驻云架构师告诉你怎么办!
技术好文共享:谁说阿里云不能跑Oracle,让驻云架构师告诉你怎么办!
46 0
|
6月前
|
Oracle 关系型数据库
oracle 19c 搭建dataguard 简要命令
通过service 完成dg 搭建。
159 0
|
Oracle 关系型数据库 数据安全/隐私保护
|
Oracle 关系型数据库 数据安全/隐私保护
oracle用户创建及权限设置
oracle用户创建及权限设置 权限:   create session   create table   unlimited tablespace   connect   resource   dba   例:   #sqlplus /nolog   SQL> conn / as sysdb...
928 0
|
Oracle 关系型数据库 数据安全/隐私保护
oracle用户创建及权限设置
 权限:   create session   create table   unlimited tablespace   connect   resource   dba   例:   #...
718 0

推荐镜像

更多
下一篇
无影云桌面