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

概念

 

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 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章