Oracle 12c 新特性 --- Oracle Data Guard Database Compare

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/leo__1990/article/details/90057173

概念

This new tool compares data blocks stored in an Oracle Data Guard primary database and its physical standby databases. Use this tool to find disk errors (such as lost write) that cannot be detected by other tools like the DBVERIFY utility.
这个新工具比较了存储在Oracle数据保护主数据库和物理备用数据库中的数据块。使用此工具可查找无法通过其他工具(如DBVERIFY实用程序)检测的磁盘错误(如丢失的写)。
An administrator can validate that a standby database does not contain silent corruptions introduced independently by the I/O stack at a standby database. Oracle Data Guard already performs validation on hot data (data being read or changed) at either the primary or standby database, but this new tool provides comprehensive validation, including cold data that has not been read or changed by Oracle Data Guard. This ability provides the administrator with complete confidence that the standby database is free of physical corruption.
管理员可以验证备用数据库不包含独立于备用数据库中的I / O堆栈独立引入的silent corruptions。Oracle Data Guard已经在主数据库或备用数据库中执行对热点数据(正在读取或更改的数据)的验证,但是这个新工具提供了全面的验证,包括没有被Oracle数据保护读取或更改的冷数据。此功能为管理员提供了完全的信心,即备用数据库不存在物理损坏。
You can use the PL/SQL procedure, DBMS_DBCOMP.DBCOMP, to detect lost writes and also to detect inconsistencies between a primary database and physical standby databases.
您可以使用PL / SQL过程,DBMS_DBCOMP。DBCOMP,检测丢失的写,也检测主数据库和物理备用数据库之间的不一致性。
The DBMS_DBCOMP.DBCOMP procedure compares the same data blocks on the primary and physical standby databases. The procedure can be executed at any time. (It does not require that the DB_LOST_WRITE_PROTECT initialization parameter be enabled.) 
You can monitor the progress of an on-going block comparison operation by querying the V$SESSION_LONGOPS view.

DBMS_DBCOMP。DBCOMP过程比较了主和物理备用数据库上的相同数据块。程序可以在任何时候执行。(它不需要启用DB_LOST_WRITE_PROTECT初始化参数。)
您可以通过查询V $ SESSION_LONGOPS视图来监视正在运行的块比较操作的进度。

实验

1)存储过程sys.dbms_dbcomp.dbcomp说明
Syntax
DBMS_DBCOMP.DBCOMP (
  datafile IN varchar2, --文件名称或编号(ALL所有文件)
  outputfile IN varchar2, --输出文件的名称
  block_dump IN boolean); --这是一个布尔参数,用于指定如果一对主数据库和备用数据库的块不相同,是否应该将块内容转储到输出文件中。此参数不能保证转储所有不同的块对。默认值为FALSE。


SQL> SELECT target_desc, sofar, totalwork FROM V$SESSION_LONGOPS WHERE opname = 'Block Compare';

TARGET_DESC			      SOFAR  TOTALWORK
-------------------------------- ---------- ----------
Compared Blocks 		     350080	350080
Lost Writes				  0	     0
详细内容参考官方文件:
http://docs.oracle.com/database/122/ARPLS/DBMS_DBCOMP.htm#ARPLS-GUID-4A248C6E-F52E-4841-B26B-139DD33012B1

2) 环境说明
环境是12.2.0.1.0 DG环境,主库的unique_name 是pdbcndba_p,备库pdbcndba_s ,
主备库的SID:cndba
3) 比较主备库的全部数据文件
SQL> exec sys.dbms_dbcomp.dbcomp('ALL','standbypdbComparison', true);

PL/SQL procedure successfully completed.

[oracle@dg1 dbs]$ ll

-rw-r-----. 1 oracle oinstall     3842 Aug 15 14:12 standbypdbComparison
-rw-r--r--. 1 oracle oinstall     2394 Aug 15 14:10 standbypdbComparison_pdbcndba_s_1
-rw-r--r--. 1 oracle oinstall     2326 Aug 15 14:11 standbypdbComparison_pdbcndba_s_10
-rw-r--r--. 1 oracle oinstall   213670 Aug 15 14:12 standbypdbComparison_pdbcndba_s_11
-rw-r--r--. 1 oracle oinstall     1623 Aug 15 14:12 standbypdbComparison_pdbcndba_s_12
-rw-r--r--. 1 oracle oinstall     2394 Aug 15 14:10 standbypdbComparison_pdbcndba_s_3
-rw-r--r--. 1 oracle oinstall  5318400 Aug 15 14:10 standbypdbComparison_pdbcndba_s_4
-rw-r--r--. 1 oracle oinstall     2324 Aug 15 14:11 standbypdbComparison_pdbcndba_s_5
-rw-r--r--. 1 oracle oinstall     2324 Aug 15 14:11 standbypdbComparison_pdbcndba_s_6
-rw-r--r--. 1 oracle oinstall     1613 Aug 15 14:11 standbypdbComparison_pdbcndba_s_7
-rw-r--r--. 1 oracle oinstall     1779 Aug 15 14:11 standbypdbComparison_pdbcndba_s_8
-rw-r--r--. 1 oracle oinstall    55354 Aug 15 14:11 standbypdbComparison_pdbcndba_s_9
4)默认输出的文件在$ORACLE_HOME/dbs 下,因为我这个环境是刚搭建的 查看数据文件1,没有块损坏。
[oracle@dg1 dbs]$ cat standbypdbComparison_pdbcndba_s_1
Client is connected to database pdbcndba_p, the role is primary database.
Remote database is pdbcndba_s, the role is physical standby

Datafile No: 1 /u01/app/oracle/oradata/cndba/system01.dbf
 
*******************************************************************************
                       TOTAL: total no. of blocks found
                         |
   +--------+------------+-------+---------+---------+
   |        |                    |         |         |
   |      DIFFV:             LOST_WRITE    |       CORR: corrupted blocks
 SAMEV     diff ver              |       SKIPPED:
   |       block pairs        +--+--+      direct load, empty blocks,
+--+--+--+                    |     |      RMAN optimized blocks,
|  |  |  |                    |     |      flashback optimized blocks
|  |  | SAMEV&C:              |     |
|  |  |  same ver &           |   LWLOC: lost writes at local db
|  |  |  same checksum &     LWRMT: lost writes at remote db
|  |  |  same contents
|  |  |
|  | SAMEV_NO_CHKSUM: same ver & same contents but diff checksum
|  |                  (checksum can be diff but identical contents)
|  |
| DIFFPAIR: same ver but differrent contents (data inconsistency)
|
ENCERR: undecided block pairs due to encryption related issue
        (e.g. when Wallet is not open)


ID TOTAL   CORR SKIPPED DIFFV   SAMEV   SAMEV&C ENCERR  LWLOC  LWRMT DIFFPAIR
00 0017229 0000 0017229 0000000 0000000 0000000 0000000 000000 000000 0000000
02 0000036 0000 0000031 0000001 0000004 0000004 0000000 000000 000000 0000000
06 0080257 0000 0000950 0000051 0079256 0079256 0000000 000000 000000 0000000
14 0000001 0000 0000000 0000001 0000000 0000000 0000000 000000 000000 0000000
16 0002024 0000 0000000 0000003 0002021 0002021 0000000 000000 000000 0000000
23 0000157 0000 0000000 0000000 0000157 0000157 0000000 000000 000000 0000000
25 0000157 0000 0000000 0000000 0000157 0000157 0000000 000000 000000 0000000
26 0000005 0000 0000000 0000000 0000005 0000005 0000000 000000 000000 0000000
27 0001856 0000 0000000 0000000 0001856 0001856 0000000 000000 000000 0000000
29 0000001 0000 0000000 0000001 0000000 0000000 0000000 000000 000000 0000000
30 0000125 0000 0000000 0000001 0000124 0000124 0000000 000000 000000 0000000
58 0000531 0000 0000531 0000000 0000000 0000000 0000000 000000 000000 0000000
70 0000019 0000 0000019 0000000 0000000 0000000 0000000 000000 000000 0000000

MOS 文档 ID 2230545.1 
错误信息如下:
Client is connected to database orcl, the role is primary database.
Remote database is orcls, the role is physical standby

Datafile No: 12 /u01/app/oracle/oradata/ORCL/48F8959D774A1BD5E0530100007F7088/datafile/o1_mf_users_dbp1f6wb_.dbf

DBCOMP rmi block kcbh check fail (2 6 135)

 ID TOTAL    CORR SKIPPED DIFFV     SAMEV    SAMEV&C ENCERR LWLOC LWRMT DIFFPAIR

00 0000504  0000 0000504 0000000 0000000 0000000 0000000 000000 000000 0000000
06 0000005  0001 0000000 0000000 0000004 0000004 0000000 000000 000000 0000000  ====> CORR column has 0001 for ID 06 which is data block

When the block is accessed, error will be thrown in alert log.

SQL> select * from tabtest;
ERROR:
ORA-01578: ORACLE data block corrupted (file # 19, block # 135)
ORA-01110: data file 19: '/u01/app/oracle/oradata/ORCLDR/userspdb01.dbf'

Alert log has reported

PDB2(4):Reading datafile '/u01/app/oracle/oradata/ORCLDR/userspdb01.dbf' for corruption at rdba: 0x04c00087 (file 19, block 135)
PDB2(4):Reread (file 19, block 135) found same corrupt data (no logical check)
Errors in file /u01/app/oracle/diag/rdbms/orcldr/orcldr/trace/orcldr_ora_30909.trc (incident=14665) (PDBNAME=PDB2):
ORA-01578: ORACLE data block corrupted (file # 19, block # 135)
ORA-01110: data file 19: '/u01/app/oracle/oradata/ORCLDR/userspdb01.dbf'
PDB2(4):Incident details in: /u01/app/oracle/diag/rdbms/orcldr/orcldr/incident/incdir_14665/orcldr_ora_30909_i14665.trc

参考文档

http://docs.oracle.com/database/122/ARPLS/DBMS_DBCOMP.htm#ARPLS-GUID-4A248C6E-F52E-4841-B26B-139DD33012B1

http://docs.oracle.com/database/122/NEWFT/new-features.htm#GUID-2BB1F8C7-EF8A-4E53-B5A7-A552D5768B76

http://docs.oracle.com/database/122/SBYDB/examples-of-using-oracle-data-guard.htm#SBYDB4898 

猜你喜欢

转载自blog.csdn.net/leo__1990/article/details/90057173