[20160803]关于SNAPSHOT CONTROLFILE.txt

简介: [20160803]关于SNAPSHOT CONTROLFILE.txt --当使用rman备份时,rman会建立一个SNAPSHOT CONTROLFILE,具体位置由参数 RMAN> show SNAPSHOT CONTROLFILE NAME  ; ...

[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。


总结:
从以上测试可以说明做好不要在备份期间做增加数据文件的操作。

目录
相关文章
|
Oracle 关系型数据库 Linux
[20180115]RMAN-06820.txt
[20180115]RMAN-06820.txt --//在备库做归档备份出现RMAN-06820的问题。就是如果在备库做全表,因为要做主库日志切换,一般执行rman target /会出现问题。
1418 0
|
Oracle 关系型数据库 Shell
[20171121]rman backup as copy 2.txt
[20171121]rman backup as copy 2.txt --//昨天测试backup as copy ,备份时备份文件的文件头什么时候更新.是最后完成后还是顺序写入备份文件.
1011 0
|
Oracle 关系型数据库 Linux
[20171121]rman backup as copy.txt
[20171121]rman backup as copy.txt --//上个星期做数据文件块头恢复时,提到使用rman备份数据文件时,文件头数据库信息是最后写入备份集文件的,在filesperset=1的情况 --//下写入备份集文件中的倒数第2块就是文件头的备份.
1227 0
|
Oracle 关系型数据库 Linux
[20171101]rman to destination.txt
[20171101]rman to destination.txt --//国庆放假,看了一些rman方面的书,看到一个不常用的参数to destination,测试看看.
940 0
|
Oracle 关系型数据库 数据库
[20170616]recover copy of datafile 6.txt
[20170616]no copy of datafile 6 found to recover.txt --//最近几天一直被这个问题纠缠,我虽然不知道问题在哪来,还是找到简单的解决方法,做1个记录: --//链接:http://www.
1152 0
|
SQL Oracle 关系型数据库
通过Snapshot Control File 恢复控制文件
大家好! 今天AningDBA和大家分享的是通过rman 快照控制文件恢复控制文件的方法: 我今天测试使用的oracle版本是10.2.01 由于版本问题,实验结果可能会存在差异。
1012 0
|
Oracle 关系型数据库 Linux
[20170302]关于snapshot standby.txt
[20170302]关于alter database convert to snapshot standby.txt --//这是很久以前但是关于alter database activate standby database的讨论: --//链接: http://www.
961 0