0% found this document useful (0 votes)
5 views14 pages

Automatic Block Repair

The document discusses the Automatic Block Repair feature in Oracle Active Data Guard, which allows for the automatic repair of corrupt data blocks using uncorrupted copies from a physical standby database. This feature requires specific configurations, including maximum availability mode and real-time query mode on the standby database. It also details the process of detecting corruption, the conditions for successful repair, and the logging of repair actions.

Uploaded by

Ahmet Duruöz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views14 pages

Automatic Block Repair

The document discusses the Automatic Block Repair feature in Oracle Active Data Guard, which allows for the automatic repair of corrupt data blocks using uncorrupted copies from a physical standby database. This feature requires specific configurations, including maximum availability mode and real-time query mode on the standby database. It also details the process of detecting corruption, the conditions for successful repair, and the logging of repair actions.

Uploaded by

Ahmet Duruöz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Automatic Block Media

Reovery in
ACTIVE DATAGUARD
Automatic Block Repair

Automatic block repair allows corrupt data blocks to be automatically repaired as soon as
the corruption is detected.

Automatic block repair requires the use of the Oracle Active Data Guard option so
that you can open a physical standby database for read-write I/O. Also, note that this
feature requires that Oracle Data Guard is running in maximum availability mode
and has the LOG_ARCHIVE_DEST_n initialization parameter set to the SYNC redo
transport mode.

If a corrupt data block is encountered when a primary database is accessed, it is


automatically replaced with an uncorrupted copy of that block from a physical standby
database. This requires the following conditions:

• The physical standby database must be operating in real-time query mode, which
requires an Active Data Guard license.
• The physical standby database must be running real-time apply.

Also keep the following in mind:

• Automatic repair is supported with any Data Guard protection mode. However, the
effectiveness of repairing a corrupt block at the primary using the noncorrupt
version of the block from the standby depends on how closely the standby apply is
synchronized with the redo generated by the primary.
• When an automatic block repair has been performed, a message is written to the
database alert log.
• If automatic block repair is not possible, an ORA-1578 error is returned
ON PRIMARY

SQL> alter system set log_archive_Dest_2=’service=DEMOST SYNC AFFIRM


VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=DEMOS’;

System altered.

SQL>
SQL> ALTER SYSTEM set log_archive_Dest_STATE_2=ENABLE;

System altered.

SQL> select name,database_role,protection_mode from v$database;

NAME DATABASE_ROLE PROTECTION_MODE


——— —————- ——————–
DEMOP PRIMARY MAXIMUM AVAILABILITY

SQL> select name from v$tablespace;

NAME
——————————
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE

6 rows selected.
SQL>
SQL> create tablespace DEMO_CORRUPT datafile
‘/u01/app/oradata/DEMOP/demo_c_01.dbf’ size 500m;

Tablespace created.

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL>
SQL> /

System altered.

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
————–
85
SQL>
SQL>
SQL> create table t (int int) tablespace DEMO_CORRUPT;

Table created.

SQL>
SQL>
SQL> insert into t values (1);

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /
1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /
1 row created.

SQL> /

1 row created.

SQL>
SQL>
SQL>
SQL> commit;

Commit complete.

SQL> select count(*) from t;

COUNT(*)
———-
12
SQL> select min(dbms_rowid.rowid_block_number(rowid))from t;

MIN(DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID))
—————————————–
132

SQL> select name from v$datafile;

NAME
——————————————————————————–
/u01/app/oradata/DEMOP/system01.dbf
/u01/app/oradata/DEMOP/sysaux01.dbf
/u01/app/oradata/DEMOP/undotbs01.dbf
/u01/app/oradata/DEMOP/users01.dbf
/u01/app/oradata/DEMOP/example01.dbf
/u01/app/oradata/DEMOP/demo_c_01.dbf

6 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$ su –
Password:
[root@DGPRIM ~]#
[root@DGPRIM ~]# dd if=/dev/zero of=/u01/app/oradata/DEMOP/demo_c_01.dbf
bs=8192 conv=notrunc seek=134 count=1
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 3.9642e-05 s, 207 MB/s
[root@DGPRIM ~]#
[root@DGPRIM ~]# logout
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$ !sql
sqlplus “/as sysdba”

SQL*Plus: Release 11.2.0.3.0 Production on Sun May 27 09:47:03 2018

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@DGPRIM BACKUP]$ dbv file=/u01/app/oradata/DEMOP/demo_c_01.dbf

DBVERIFY: Release 11.2.0.3.0 – Production on Sun May 27 09:47:23 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

DBVERIFY – Verification starting : FILE = /u01/app/oradata/DEMOP/demo_c_01.dbf


Page 134 is marked corrupt
Corrupt block relative dba: 0x01800086 (file 6, block 134)
Completely zero block found during dbv:

DBVERIFY – Verification complete

Total Pages Examined : 64000


Total Pages Processed (Data) : 0
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 127
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 63872
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1160745 (0.1160745)
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$
[oracle@DGPRIM BACKUP]$ !sql
sqlplus “/as sysdba”

SQL*Plus: Release 11.2.0.3.0 Production on Sun May 27 09:47:54 2018

Copyright (c) 1982, 2011, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> commit;

Commit complete.

SQL> alter system flush buffer_cache;

System altered.

SQL>analyze table t validate structure cascade;

It takes much time to analyze .

SQL> select count(*) from t;

COUNT(*)
———-
12

SQL> select * from v$recover_file;

no rows selected

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

ON STANDBY

SQL> select name,database_role,protection_mode from v$database;


NAME DATABASE_ROLE PROTECTION_MODE
——— —————- ——————–
DEMOP PHYSICAL STANDBY MAXIMUM AVAILABILITY

SQL> select name from v$tablespace;

NAME
——————————
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE

6 rows selected.

SQL> show parameter standby

NAME TYPE VALUE


———————————— ———– ——————————
standby_archive_dest string ?/dbs/arch
standby_file_management string AUTO
SQL>
SQL> select open_mode from v$database;

OPEN_MODE
——————–
MOUNTED

SQL> alter database open;


Database altered.

SQL> alter database recover managed standby database using current logfile disconnect
from session;

Database altered.

SQL> select name from v$tablespace;

NAME
——————————
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EXAMPLE
DEMO_CORRUPT

7 rows selected.

SQL> select max(sequence#) from v$archived_log where applied=’YES’;

MAX(SEQUENCE#)
————–
84

SQL> select count(*) from t;

COUNT(*)
———-
12
SQL> select count(*) from t;

COUNT(*)
———-
12

SQL> /

COUNT(*)
———-
12

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

ALERT LOG OF PRIMARY DATABASE

Sun May 27 09:57:09 2018


ALTER SYSTEM: Flushing buffer cache
Hex dump of (file 6, block 134) in trace file
/u01/app/oracle/diag/rdbms/demop/DEMOP/trace/DEMOP_ora_3275.trc
Corrupt block relative dba: 0x01800086 (file 6, block 134)
Completely zero block found during multiblock buffer read
Reading datafile ‘/u01/app/oradata/DEMOP/demo_c_01.dbf’ for corruption at rdba:
0x01800086 (file 6, block 134)
Reread (file 6, block 134) found same corrupt data (no logical check)
Starting background process ABMR
Sun May 27 09:57:19 2018
ABMR started with pid=30, OS id=3277
Automatic block media recovery service is active.
Automatic block media recovery requested for (file# 6, block# 134)
Sun May 27 09:58:07 2018
ALTER SYSTEM SET log_archive_dest_state_2=’ENABLE’ SCOPE=BOTH;
Sun May 27 09:58:07 2018
Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED
******************************************************************
LGWR: Setting ‘active’ archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected to archive thread 1 sequence 91
LGWR: Standby redo logfile selected for thread 1 sequence 91 for destination
LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 91 (LGWR switch)
Current log# 1 seq# 91 mem# 0: /u01/app/oradata/DEMOP/redo01.log
Sun May 27 09:58:07 2018
Archived Log entry 148 added for thread 1 sequence 90 ID 0xe849771f dest 1:
Sun May 27 09:58:07 2018
ARC3: Standby redo logfile selected for thread 1 sequence 90 for destination
LOG_ARCHIVE_DEST_2
Sun May 27 09:58:08 2018
Automatic block media recovery successful for (file# 6, block# 134)
Sun May 27 09:58:08 2018
Automatic block media recovery successful for (file# 6, block# 134)

You might also like