显然,在将users表空间置于backup状态的时候,相应的datafile的文件头的scn就不会再发生改变,发生检查点也不会改变。
SQL> alter system checkpoint; System altered. SQL> select NAME,TABLESPACE_NAME,STATUS,CHECKPOINT_CHANGE# from |
下面end backup,看看scn
SQL> alter tablespace users end backup; Tablespace altered. SQL> alter system checkpoint; System altered. SQL>select NAME,TABLESPACE_NAME,STATUS,CHECKPOINT_CHANGE# from |
再说说rman备份
个人认为理解了用户管理的热备份,rman就已经理解了一大半了
rman 备份是针对块一级的,支持增量备份,稍后说怎么做的增量备份
Rman备份并不需要将数据库或者表空间置于backup状态,但是它会把scn记录
在catalog中对应你的backupset准备在恢复的时候来使用
对users表空间做一个完全备份
$ rman target sys/oracle nocatalog
RMAN> run {
2> allocate channel d1 type disk;
3> backup
4> format='/u03/oraclebk/%d_%N_%s.bk' tablespace users;
5> release channel d1;
6> } |
看一下备份集里都有什么,注意看Ckp SCN 546792,
RMAN> list backup of tablespace users; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 3 Full 1M DISK 00:00:02 31-MAR-05 BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20050331T153729 Piece Name: /u03/oraclebk/SALES_USERS_4.bk List of Datafiles in backup set 3 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 4 Full 546792 31-MAR-05 /u02/oradata/sales/users01.dbf |
恢复的时候应用546792开始到现在的归档日志和重做日志。
---------------
rman的增量备份的基本原理
其实原理很简单,主要就是弄明白怎么样在做增量备份时确定某个数据块需要备份,哪个不需要
rman在做1级备份的时候怎么来确定0级备份之后都有哪些数据块做了修改呢?看下面一段
Each data block in a datafile contains a system change number (SCN), which is the
SCN at which the most recent change was made to the block. During an incremental
backup, RMAN reads the SCN of each data block in the input file and compares it to
the checkpoint SCN of the parent incremental backup. If the SCN in the input data
block is greater than or equal to the checkpoint SCN of the parent, then RMAN copies
the block.
原来block里边也有一个change scn
也就是说在做level 1级备份的时候,需要扫描所有的数据块并且用块中记录修改的SCN
跟level 0备份时的SCN做比较(备份记录中的Ckp SCN),来确定这个块是否需要备份。
所以扫描整个数据文件是不可避免的 !
这是传统的rman做增量备份
在10g中rman做增量备份不再需要扫描整个数据文件了
10g引入的新特性 block change tracking:
Block change tracking进程记录自从上一次备份以来数据块的变化,并把这些信息记录在跟踪文件中。
RMAN使用这个文件判断增量备份中需要备份的变更数据。这极大的促进了备份性能,
RMAN可以不再扫描整个文件以查找变更数据。
RMAN's change tracking feature for incremental backups improves incremental
backup performance by recording changed blocks in each datafile in a change tracking
file. If change tracking is enabled, RMAN uses the change tracking file to identify
changed blocks for incremental backup, thus avoiding the need to scan every block in
the datafile.
估计是使用的位图文件做的记录!
附:
有兴趣的可以看看dump的数据块
通过下面的查询找一个表对应的数据块
SQL> select file_id,block_id,blocks
2 from dba_extents
3 where segment_name='EMPLOYEES';
FILE_ID BLOCK_ID BLOCKS
---------- ---------- ----------
5 81 8 |
dump一个块到udump的trc文件
SQL> alter system dump datafile 5 block 81;
System altered.
在udump目录找到对应的trc文件,找到dump那段
Start dump data blocks tsn: 6 file#: 5 minblk 81 maxblk 81 buffer tsn: 6 rdba: 0x01400051 (5/81) scn: 0x0000.00086c4d seq: 0x01 flg: 0x04 tail: 0x4b502001 |
后面省略了
scn: 0x0000.00086c4d是16进制你可以换算过来552013
你可以尝试做一下修改,不过一定要保证对应的块被修改了,并且被写了,才能反映出来。

