Detection ofFractured Blocks During Open Backups
One danger in making online backups is thepossibility of inconsistent data within a block. For example, assume that youare backing up block 100 in datafile users.dbf. Also, assumethat the copy utility reads the entire block while DBWR is in the middle ofupdating the block. In this case, the copy utility may read the old data in thetop half of the block and the new data in the bottom top half of the block. Theresult is called a fractured block, meaningthat the data contained in this block is not consistent. at a given SCN.
When performing backups of an opentablespace without using RMAN, you must put tablespaces in backupmode to prevent the creation of fractured blocks in your backup. Whennot in backup mode, the database records only changed bytes in the redo stream.When a tablespace is in backup mode, each time a block is changed the databasewrites the before-image of the entire block to the redo stream before modifyingthe block. Then, the database also records the changes to the block in the redolog. During user-managed recovery using SQL*Plus, the database applies both thecaptured block images and the recorded block changes from the redo logs.Applying the block images repairs any possible fractured blocks in the backupbeing restored and recovered.
RMAN does not require that you putdatafiles into backup mode. During an RMAN backup, a database server sessionreads each block of the datafile and checks whether each block is fractured bycomparing the block header and footer. If a block is fractured, the sessionre-reads the block. If the same fracture is found, then the block is consideredpermanently corrupt. If MAXCORRUPT is exceeded,the backup stops.
实验证明:
SQL> col name for a10
SQL> select b.name,a.value fromv$sysstat a,v$statname b where b.namelike '%redo size%' and a.STATISTIC# =b.STATISTIC#;
NAME VALUE
---------- ----------
redo size 55436588
SQL> insert into t values (3,'xl',10);
已创建 1 行。
SQL> select b.name,a.value fromv$sysstat a,v$statname b where b.namelike '%redo size%' and a.STATISTIC# =b.STATISTIC#;
NAME VALUE
---------- ----------
redo size 55437056
SQL> select 55437056 - 55436588 from dual;
55437056-55436588
-----------------
468
SQL> alter tablespaceZXNTAGL_TS_DATA_TAGL begin backup;
表空间已更改。
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ---------------------------------------------- --------------
1NOT ACTIVE 157372534 10-2月 -12
2NOT ACTIVE 157372534 10-2月 -12
3NOT ACTIVE 157372534 10-2月 -12
4NOT ACTIVE 157372534 10-2月 -12
5ACTIVE 157376625 11-2月 -12
6NOT ACTIVE 157372534 10-2月 -12
7NOT ACTIVE 157372534 10-2月 -12
已选择7行。
SQL> select b.name,a.value fromv$sysstat a,v$statname b where b.namelike '%redo size%' and a.STATISTIC# =b.STATISTIC#;
NAME VALUE
---------- ----------
redo size 55440792
SQL> insert into t values (3,'xl',10);
已创建 1 行。
SQL> select b.name,a.value fromv$sysstat a,v$statname b where b.namelike '%redo size%' and a.STATISTIC# =b.STATISTIC#;
NAME VALUE
---------- ----------
redo size 55454740
SQL> select 55454740 - 55440792 from dual;
55454740-55440792
-----------------
13948
SQL> select 13948 - 468 from dual;
13948-468
----------
13480