[20160803]关于SNAPSHOT CONTROLFILE.txt
--当使用rman备份时,rman会建立一个SNAPSHOT CONTROLFILE,具体位置由参数
RMAN> show SNAPSHOT CONTROLFILE NAME ;
RMAN configuration parameters for database with db_unique_name BOOK are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f'; # default
--官方文档介绍:Snapshot Controlfile
When RMAN needs to resynchronize from a read-consistent version of the control file, it creates a temporary snapshot
control file. The default name for the snapshot control file is port-specific. Use the set snapshot controlfile name
command to change the name of the snapshot control file; subsequent snapshot control files that RMAN creates use the
name specified in the command.
--//做一些测试来说明问题:
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.在rman下执行:
host "date +'%Y/%m/%d %T'>>/tmp/aa.log";
backup spfile format '/home/oracle/backup/spfile_%U';
$ cat /tmp/aa.log
2016/08/03 16:17:10
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:17:12 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
--基本可以确定在备份时建立的。对比真正控制文件大小。到底在备份前还是备份后,看下面的测试:
SCOTT@book> show parameter control_files
NAME TYPE VALUE
------------- ------ -----------------------------------------------------------------
control_files string /mnt/ramdisk/book/control01.ctl, /mnt/ramdisk/book/control02.ctl
$ ls -l /mnt/ramdisk/book/control0[12].ctl
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:18:53 /mnt/ramdisk/book/control01.ctl
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:18:53 /mnt/ramdisk/book/control02.ctl
--//大小一样,都是10141696字节。
3.继续测试:
--为了减慢备份速度,设置如下:
configure channel 1 device type disk rate 10M;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
--执行如下备份,在执行的工程中在增加1个数据文件看看:
backup database format '/u01/backup/full0803_%U.bak' filesperset=1 tag='full0803';
--在备份的过程中增加1个建立一个数据文件:
ALTER TABLESPACE TEA ADD DATAFILE '/mnt/ramdisk/book/tea02.dbf' SIZE 100M AUTOEXTEND OFF;
$ zdate
2016/08/03 16:38:40
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:26:26 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
~~~~~~~~~~~~~~~~~~~
RMAN> backup database format '/u01/backup/full0803_%U.bak' filesperset=1 tag='full0803';
Starting backup at 2016-08-03 16:36:56
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=145 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-08-03 16:36:56
....
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2016-08-03 16:46:02
channel ORA_DISK_1: finished piece 1 at 2016-08-03 16:46:03
piece handle=/u01/backup/full0803_7arcbb2a_1_1.bak tag=FULL0803 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-08-03 16:46:03
--//备份使用了10分钟。
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:46:03 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
--你可以发现在开始备份时并没有建立SNAPSHOT CONTROLFILE。你可以发现是备份完成再建立snapshot congtrolfile。
RMAN> report schema ;
Report of database schema for database with db_unique_name BOOK
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 780 SYSTEM *** /mnt/ramdisk/book/system01.dbf
2 2180 SYSAUX *** /mnt/ramdisk/book/sysaux01.dbf
3 1435 UNDOTBS1 *** /mnt/ramdisk/book/undotbs01.dbf
4 200 USERS *** /mnt/ramdisk/book/users01.dbf
5 346 EXAMPLE *** /mnt/ramdisk/book/example01.dbf
6 100 SUGAR *** /mnt/ramdisk/book/sugar01.dbf
7 5 TEA *** /mnt/ramdisk/book/tea01.dbf
8 100 TEA *** /mnt/ramdisk/book/tea02.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 100 TEMP 32767 /mnt/ramdisk/book/temp01.dbf
RMAN> list backupset of datafile 7,8;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
121 Full 1.03M DISK 00:00:01 2016-08-03 16:46:00
BP Key: 122 Status: AVAILABLE Compressed: NO Tag: FULL0803
Piece Name: /u01/backup/full0803_79rcbb27_1_1.bak
List of Datafiles in backup set 121
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
7 Full 13245327669 2016-08-03 16:45:59 /mnt/ramdisk/book/tea01.dbf
--你可以发现并没有备份数据文件8.
3.删除备份再做一个删除数据文件的测试:
RMAN> delete backupset completed before 'sysdate-1/1440';
RMAN> configure channel 1 device type disk rate 20M;
old RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 10 M;
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 20 M;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1
--有点慢,加快1点。
--执行如下:
backup database format '/u01/backup/full0803x_%U.bak' filesperset=1 tag='full0803x';
--在执行备份过程中,执行如下:
ALTER TABLESPACE TEA drop DATAFILE '/mnt/ramdisk/book/tea02.dbf' ;
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:56:15 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
RMAN> backup database format '/u01/backup/full0803x_%U.bak' filesperset=1 tag='full0803x';
Starting backup at 2016-08-03 16:59:05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=145 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-08-03 16:59:05
...
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:56:15 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
--//确实在备份时没有建立snapshot。删除1个数据文件看看:
SCOTT@book> ALTER TABLESPACE TEA drop DATAFILE '/mnt/ramdisk/book/tea02.dbf' ;
Tablespace altered.
piece handle=/u01/backup/full0803x_7grcbc3d_1_1.bak tag=FULL0803X comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: throttle time: 0:00:05
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
channel ORA_DISK_1: throttle time: 0:00:05
..
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 08/03/2016 17:03:48
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01110: data file 8: 'No file with this number, file does not exist'
--//报错,因为我在备份的过程中删除了一个数据文件。
$ ls -l /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
-rw-r----- 1 oracle oinstall 10141696 2016-08-03 16:56:15 /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f
--//依旧是旧的,因为备份没有完成。
--//从这个角度可以看出snapshot controlfile仅仅包含当时备份时的数据文件信息。只不过在完成时在保存在这里
--/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_book.f。
总结:
从以上测试可以说明做好不要在备份期间做增加数据文件的操作。