Freeze file header, freezefileheader
SQL> select * from v $ version where rownum = 1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-Production
We can use alter tablespace... begin backup puts the tablespace in the online backup mode, and then uses the operating system command to physically copy the data files to achieve the backup purpose. In this process, the data files are still online, and perform normal data insertion, but more REDO records will be generated than normal. A large number of REDO records are generated by Hot Standby, because the copy/ocopy command is used during Hot Standby. This is an operating system command, it is irrelevant to Oracle and cannot interact with internal Oracle processes such as dbwr, because when the Operating System reads data files, its IO size is not the size of block size, generally, it will be smaller. This will cause a data block to be read multiple times, and the parts obtained each time are inconsistent (data is constantly updated, resulting in a split block ), in order to restore this broken Hot Standby block, Oracle performs the data block pre-image operation. When the backup mode data file block is affected by DML for the first time, first, COPY the entire data block to REDO. Subsequent DML will record the UNDO and normal REDO information. When restoring the data file, the first data block pre-image will be applied first, then there is the subsequent REDO record information. More log records are generated by the previous image. This cannot be confused with UNDO. It is the entire data block, not a simple row record, since Oracle itself does not know how to copy The blocks may be hot standby, so as long as there are DML blocks during BACKUP, it will be processed according to the above situation, so if a large number of batch processing programs are run during backup, log information increases. This is mainly the starting SCN for data file recovery in the future. After the begin backup is issued, the system needs to perform a checkpoint on the table space, all transaction applications before the Check Point are solidified to the data file, and then the SCN is frozen until the end backup is used to END the BACKUP process, and then updated to the new SCN, the reason for freezing is that when you use an operating system command to copy a data file, he cannot ensure that the first block to be read is the data file header. If it is not frozen, it may start from the backup, the file header has been updated multiple times, but the file header has not been copied. After the file header is copied, its SCN is far greater than the SCN of other data blocks in the data file, in this way, it is unrealistic to locate the restoration start point from the SCN of the file header. Http://blog.itpub.net/7728585/viewspace-545610)
Next we will simulate this process (taking the system tablespace as an example ):
SQL> alter session set events 'immediate trace name file_hdrs level 10 ';
The session has been changed.
SQL> select value from v $ diag_info where name = 'default Trace file ';
VALUE
--------------------------------------------------------------------------------
/U01/app/oracle/diag/rdbms/orcl3939/orcl3939/trace/orcl3939_ora_4862.trc
Data file #1:
Name #7:/u01/app/oracle/oradata/orcl3939/system01.dbf
Creation size = 0 block size = 8192 status = 0xe head = 7 tail = 7 dup = 1
Tablespace 0, index = 1 krfil = 1 prev_file = 0
Unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt: 1223 scn: 0x0000. 0080ab79 05/22/2015 23:01:37
Stop scn: 0xffff. ffffffff 05/21/2015 12:23:57
Creation Checkpointed at scn: 0x0000.00000007 08/13/2009 23:00:53
Thread: 0 rba :( 0x0. 0.0)
...
...
Offline scn: 0x0000. 000b8337 prev_range: 0
Online Checkpointed at scn: 0x0000. 000b8338 09/28/2014 17:41:34
Thread: 1 rba :( 0x1. 2.0)
...
...
Hot Backup end marker scn: 0x0000.00000000
Aux_file is NOT DEFINED
Plugged readony: NO
Plugin scnscn: 0x0000.00000000
Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Online move state: 0
V10 style file header:
Compatibility Vsn = 186646528 = 0xb200000
Db ID = 3848072073 = 0xe55ceb89, Db Name = 'orcl3939'
Activation ID = 0 = 0x0
Control Seq = 17079 = 0x42b7, File size = 103680 = 0x19500
File Number = 1, blksiz= 8192, File Type = 3 DATA
Tablespace #0-SYSTEM rel_fn: 1
Creation at scn: 0x0000.00000007 08/13/2009 23:00:53
Backup taken at scn: 0x0000. 00773f1c 05/05/2015 19:12:20 thread: 1
Reset logs count: 0x333ab14e scn: 0x0000. 000b8338
Prev reset logs count: 0x296a3120 scn: 0x0000.00000001
Recovered at 05/20/2015 14:09:45
Status: 0x2004 root dba: 0x00400208 chkpt cnt: 1223 ctl cnt: 1222
Begin-hot-backup file size: 103680
Checkpointed at scn: 0x0000. 0080ab79 05/22/2015 23:01:37
Thread: 1 rba :( 0x1ee. 2.10)
....
....
========================================================== ====================================
SQL> alter tablespace system begin backup;
The tablespace has been changed.
SQL> select * from v $ backup where status = 'active ';
FILE # status change # TIME
----------------------------------------------------
1 ACTIVE 8440239 22-5 months-15
Data file #1:
Name #7:/u01/app/oracle/oradata/orcl3939/system01.dbf
Creation size = 0 block size = 8192 status = 0xe head = 7 tail = 7 dup = 1
Tablespace 0, index = 1 krfil = 1 prev_file = 0
Unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt: 1224 scn: 0x0000. 0080c9af 05/22/2015 23:58:23
Stop scn: 0xffff. ffffffff 05/21/2015 12:23:57
Creation Checkpointed at scn: 0x0000.00000007 08/13/2009 23:00:53
Thread: 0 rba :( 0x0. 0.0)
....
....
Aux_file is NOT DEFINED
Plugged readony: NO
Plugin scnscn: 0x0000.00000000
Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Online move state: 0
V10 style file header:
Compatibility Vsn = 186646528 = 0xb200000
Db ID = 3848072073 = 0xe55ceb89, Db Name = 'orcl3939'
Activation ID = 0 = 0x0
Control Seq = 17091 = 0x42c3, File size = 103680 = 0x19500
File Number = 1, blksiz= 8192, File Type = 3 DATA
Tablespace #0-SYSTEM rel_fn: 1
Creation at scn: 0x0000.00000007 08/13/2009 23:00:53
Backup taken at scn: 0x0000. 0080c9af 05/22/2015 23:58:23 thread: 1
Reset logs count: 0x333ab14e scn: 0x0000. 000b8338
Prev reset logs count: 0x296a3120 scn: 0x0000.00000001
Recovered at 05/20/2015 14:09:45
Status: 0x2001 root dba: 0x00400208 chkpt cnt: 1224 ctl cnt: 1223
Begin-hot-backup file size: 103680
Checkpointed at scn: V10 style file header: 05/22/2015 23:58:23
Thread: 1 rba :( 0x1ee. fe0c. 10)
.....
.....
========================================================== ================================
SQL> alter tablespace system end backup;
The tablespace has been changed.
SQL> select * from v $ backup where status = 'active'; no row is selected
Data file #1:
Name #7:/u01/app/oracle/oradata/orcl3939/system01.dbf
Creation size = 0 block size = 8192 status = 0xe head = 7 tail = 7 dup = 1
Tablespace 0, index = 1 krfil = 1 prev_file = 0
Unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt: 1225 scn: 0x0000. 0080c9af 05/22/2015 23:58:23
Stop scn: 0xffff. ffffffff 05/21/2015 12:23:57
Creation Checkpointed at scn: 0x0000.00000007 08/13/2009 23:00:53
Thread: 0 rba :( 0x0. 0.0)
.....
.....
Hot Backup end marker scn: 0x0000.00000000
Aux_file is NOT DEFINED
Plugged readony: NO
Plugin scnscn: 0x0000.00000000
Plugin resetlogs scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign creation scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Foreign checkpoint scn/timescn: 0x0000.00000000 01/01/1988 00:00:00
Online move state: 0
V10 style file header:
Compatibility Vsn = 186646528 = 0xb200000
Db ID = 3848072073 = 0xe55ceb89, Db Name = 'orcl3939'
Activation ID = 0 = 0x0
Control Seq = 17097 = 0x42c9, File size = 103680 = 0x19500
File Number = 1, blksiz= 8192, File Type = 3 DATA
Tablespace #0-SYSTEM rel_fn: 1
Creation at scn: 0x0000.00000007 08/13/2009 23:00:53
Backup taken at scn: 0x0000. 0080c9af 05/22/2015 23:58:23 thread: 1
Reset logs count: 0x333ab14e scn: 0x0000. 000b8338
Prev reset logs count: 0x296a3120 scn: 0x0000.00000001
Recovered at 05/20/2015 14:09:45
Status: 0x2004 root dba: 0x00400208 chkpt cnt: 1225 ctl cnt: 1224
Begin-hot-backup file size: 103680
Checkpointed at scn: 0x0000. 0080c9af 05/22/2015 23:58:23
Thread: 1 rba :( 0x1ee. fe0c. 10)
.....
.....
Backup Checkpointed at scn: 0x0000. 0080c9af 05/22/2015 23:58:23
Thread: 1 rba :( 0x1ee. fe0c. 10)
....
....
========================================================== =
Data file #1:
The content here is from the Control File
V10 style file header:
The content here is from the data file header
Database consistency check also compares the information in the data file header and control file,
First, check whether the ckpt cnt recorded in the data file header is equal to the ckpt cnt recorded in the control file. If it is equal, perform the next test,
Check whether the checkpoint scn at the beginning of the data file header is consistent with the checkpoint scn at the end of the control file. If the checkpoint scn is consistent, open the database. Otherwise, restore the database.
We can see from the above three parts of the dump that the checkpoint scn has not changed since the end of the hot standby, but the ckpt cnt has not been frozen,
In this process, the scn is frozen.