[20160725]备份变大2.txt
--前几天别人又问我备份文件变大的问题,我自己都忘记以前遇到的情况,花了1点时间找到当时的测试:
http://blog.itpub.net/267265/viewspace-1735899/
--仔细检查才发现我当时的测试使用truncate.而且版本是10.0.2.4.今天测试move看看.
1.环境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
-------------------- -------------- ----------------------------------------------------------------------------- ------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
CREATE TABLESPACE LFREE DATAFILE
'D:\APP\ORACLE\ORADATA\TEST\TEST01P\LFREE01.DBF' SIZE 100M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
SCOTT@test01p> create table t tablespace lfree as select * from dba_objects;
Table created.
RMAN> backup tablespace test01p:lfree format 'd:\tmp\lfree1_%U.bak';
Starting backup at 2016-07-25 22:07:33
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00015 name=D:\APP\ORACLE\ORADATA\TEST\TEST01P\LFREE01.DBF
channel ORA_DISK_1: starting piece 1 at 2016-07-25 22:07:34
channel ORA_DISK_1: finished piece 1 at 2016-07-25 22:07:37
piece handle=D:\TMP\LFREE1_12RBK6H6_1_1.BAK tag=TAG20160725T220734 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2016-07-25 22:07:38
Starting Control File and SPFILE Autobackup at 2016-07-25 22:07:38
piece handle=D:\APP\ORACLE\FAST_RECOVERY_AREA\TEST\AUTOBACKUP\2016_07_25\O1_MF_S_918166058_CSD79CGT_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 2016-07-25 22:07:41
D:\tools\rlwrap>ls -l d:\tmp\lfree*
ls -l d:\tmp\lfree*
-rw-rw-rw- 1 user group 13983744 Jul 25 22:07 d:\tmp\LFREE1_12RBK6H6_1_1.BAK
--//备份大小大约13M。
2.move看看:
SCOTT@test01p> alter table t move tablespace lfree;
Table altered.
RMAN> backup tablespace test01p:lfree format 'd:\tmp\lfree2_%U.bak';
....
D:\tools\rlwrap>ls -l d:\tmp\lfree*
ls -l d:\tmp\lfree*
-rw-rw-rw- 1 user group 13983744 Jul 25 22:07 d:\tmp\LFREE1_12RBK6H6_1_1.BAK
-rw-rw-rw- 1 user group 13991936 Jul 25 22:10 d:\tmp\LFREE2_14RBK6N5_1_1.BAK
--//备份大小大约13M。大约差不多。
4.建立还原点,属性是guarantee flashback database:
SYS@test> create restore point test0725 guarantee flashback database;
Restore point created.
D:\tools\rlwrap>ls -l d:\tmp\lfree*
ls -l d:\tmp\lfree*
-rw-rw-rw- 1 user group 13983744 Jul 25 22:07 d:\tmp\LFREE1_12RBK6H6_1_1.BAK
-rw-rw-rw- 1 user group 13991936 Jul 25 22:10 d:\tmp\LFREE2_14RBK6N5_1_1.BAK
-rw-rw-rw- 1 user group 26845184 Jul 25 22:13 d:\tmp\LFREE3_16RBK6RP_1_1.BAK
--//注意看第3次备份文件大小26M,增加了约1倍。
5.为什么呢?
-- //上次我并没有为什么,实际上很简单,就是当你建立guarantee flashback database的还原点,这样备份必须能还原到当时的还原点。
-- //而如果你备份仅仅包含当前使用的块,这样无法通过这个备份还原到指定的还原点。
-- //必须备份全部格式化的数据块。
SYS@test> select * from V$RESTORE_POINT;
SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME RESTORE_POINT_TIME PRE NAME CON_ID
---------- --------------------- --- ------------ ----------------------------- -------------------- --- -------- ------
23519624 2 YES 52428800 2016-07-25 22:12:50.000000000 YES TEST0725 0
SYS@test> drop restore point test0725 ;
Restore point dropped.
--如果你建立的还原点没有guarantee flashback database属性。这样备份集没有保证恢复到原理的还原点的需求,备份就没有这个大。
SYS@test> create restore point test0725 ;
Restore point created.
SYS@test> select * from V$RESTORE_POINT;
SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME RESTORE_POINT_TIME PRE NAME CON_ID
---------- --------------------- --- ------------ ----------------------------- -------------------- --- -------- ------
23520171 2 NO 0 2016-07-25 22:23:57.000000000 NO TEST0725 0
RMAN> backup tablespace test01p:lfree format 'd:\tmp\lfree4_%U.bak';
D:\tools\rlwrap>ls -l d:\tmp\lfree*
ls -l d:\tmp\lfree*
-rw-rw-rw- 1 user group 13983744 Jul 25 22:07 d:\tmp\LFREE1_12RBK6H6_1_1.BAK
-rw-rw-rw- 1 user group 13991936 Jul 25 22:10 d:\tmp\LFREE2_14RBK6N5_1_1.BAK
-rw-rw-rw- 1 user group 26845184 Jul 25 22:13 d:\tmp\LFREE3_16RBK6RP_1_1.BAK
-rw-rw-rw- 1 user group 13991936 Jul 25 22:24 d:\tmp\LFREE4_1ARBK7HG_1_1.BAK
--//注意最后1次备份大小13M。这也必须注意,如果你使用最后1个备份,也许无法还原到特定还原点(没有guarantee flashback database)。