在用RMAN备份是时候,系统会自动备份一份 SNAPSHOT CONTROLFILE,我们来看看这个 SNAPSHOT CONTROLFILE 到底有什么用途,有如下文档
RMAN needs to get a consistent view of the control file when it sets out to make backup of every datafile. It only needs to know the most recent checkpoint information and file schematic information at the time backup begins. After the backup starts, RMAN needs this information to stay consistent for duration of the backup operation; in other words, it needs a read consistent view of the control file. With the constant updates from the database, this is nearly impossible - unless RMAN were to lock the control file for the duration of the backup. But that would mean the database could not advance checkpoint or switch logs or produce new archive logs. Impossible.
To get around this, RMAN uses the snapshot control file, an exact copy of your control file that is only used by RMAN during backup and resync operations. At the beginning of these operations, RMAN refreshes the snapshot control file from the actual control file, thus putting a momentary lock on the control file. Then, RMAN switches to the snapshot and uses it for the duration of the backup; in this way, it has read consistency without holding up database activity.
根据我的理解:
snapshot control file只有在同步catalog的时候用到或者在控制文件备份的时候用到,主要作用是在备份控制文件是代替控制文件,使得rman在备份控制文件时能够锁定控制文件从而保证控制文件的一致性。
----------------------------------------------------------
SNAPSHOT CONTROLFILE 的用途,顾名思义,应该是用来恢复控制文件的,下面是我的测试结果:
结论是:
1.SNAPSHOT CONTROLFILE 能直接copy成control file也能通过rman恢复为control file
2.可以通过rman,将SNAPSHOT CONTROLFILE 恢复成控制文件
3.如果数据库没有shutdown,可以直接copy SNAPSHOT CONTROLFILE 成控制文件,但仍需要恢复(因为他是旧的)
下面是演示通过copy snapshot controlfile进行控制文件恢复的测试步骤:
---------------------------------------
查看snapshot controlfile的备份设置:
RMAN> show snapshot controlfile name;
RMAN configuration parameters are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_czmmiao.f'; # default
下面模拟控制文件丢失的恢复
$ ls
control01.ctl example01.dbf redo01.log sysaux01.dbf temp.dbf
control02.ctl example.dbf redo02.log system01.dbf undotbs01.dbf
control03.ctl nk_tbs.dbf redo03.log temp01.dbf users01.dbf
$ rm control0*
$ ls
example01.dbf nk_tbs.dbf redo02.log sysaux01.dbf temp01.dbf undotbs01.dbf
example.dbf redo01.log redo03.log system01.dbf temp.dbf users01.dbf
在控制文件被删除后,数据库还能正常操作:
SQL> create table test(id int);
Table created.
SQL> insert into test values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> alter system checkpoint;
System altered.
重新启动数据库:
SQL> shutdown immediate;
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/czmmiao/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information:
没有了控制文件了,shutdown immediate出错
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 373293056 bytes
Fixed Size 1219496 bytes
Variable Size 125830232 bytes
Database Buffers 243269632 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
没有控制文件,数据库不能mount,现在把SNAPSHOT CONTROLFILE copy到对应目录
$ cp /u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_czmmiao.f control01.ctl
$ cp control01.ctl control02.ctl
$ cp control01.ctl control03.ctl
将数据库启动到mount状态
SQL> alter database mount;
Database altered.
由于控制文件是“旧”的,所以需要恢复数据库
RMAN> recover database;
Starting recover at 31-OCT-11
Starting implicit crosscheck backup at 31-OCT-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 14 objects
Finished implicit crosscheck backup at 31-OCT-11
Starting implicit crosscheck copy at 31-OCT-11
using channel ORA_DISK_1
Finished implicit crosscheck copy at 31-OCT-11
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/CZMMIAO/backupset/2011_10_29/o1_mf_ncsnf_TAG20111029T200617_7bqv39wc_.bkp
File Name: /u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_16_7bwrp8ps_.arc
File Name: /u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_15_7bwrp6w2_.arc
using channel ORA_DISK_1
datafile 4 not processed because file is read-only
starting media recovery
archive log thread 1 sequence 15 is already on disk as file /u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_15_7bwrp6w2_.arc
archive log thread 1 sequence 16 is already on disk as file /u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_16_7bwrp8ps_.arc
archive log thread 1 sequence 17 is already on disk as file /u01/app/oracle/oradata/czmmiao/redo03.log
archive log filename=/u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_15_7bwrp6w2_.arc thread=1 sequence=15
archive log filename=/u01/app/oracle/flash_recovery_area/CZMMIAO/archivelog/2011_10_31/o1_mf_1_16_7bwrp8ps_.arc thread=1 sequence=16
archive log filename=/u01/app/oracle/oradata/czmmiao/redo03.log thread=1 sequence=17
media recovery complete, elapsed time: 00:00:02
Finished recover at 31-OCT-11
以resetlogs的方式打开数据库
SQL> alter database open resetlogs;
Database altered.
SQL> select * from test;
ID
----------
1
数据仍在,恢复成功!
如果希望采用rman方式进行控制文件的恢复,只需要执行如下命令即可
RMAN> restore controlfile from ' /u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_czmmiao.f';
参考至:http://jqs.itpub.net/post/140/479103
https://forums.oracle.com/forums/thread.jspa?threadID=942113
本文原创,转载请注明出处、作者
如有错误,欢迎指正
邮箱:czmcj@163.com
相关推荐
对数据库进行完整备份是常见的备份策略之一。可以通过以下命令实现: ``` backup database plus archivelog delete input; ``` 此命令备份所有数据文件和归档日志,并删除归档日志。 **3.4 备份表空间** 可以...
Oracle 数据库 RMAN 环境配置详解 Oracle 数据库 RMAN 环境配置是指在 Oracle 数据库中使用 ...RMAN> configure snapshot controlfile name to '/oracle/10g/oracle/product/10.2.0/db_1/dbs/snapcf_oralife_test.f';
RMAN> show SNAPSHOT CONTROLFILE NAME; ``` - 配置快照控制文件的具体位置: ```sql CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\ORA92\DATABASE\SNCFTESTHH.ORA'; ``` #### 三、执行备份 完成上述...
### Oracle RMAN 自动备份详解 #### 一、概述 Oracle RMAN(Recovery Manager)是一种功能强大的工具,用于管理数据库备份、恢复以及灾难恢复。本文档旨在介绍如何通过RMAN实现Oracle数据库的自动备份,并提供了...
configure snapshot controlfile name to 'c:\oracle\control01.ctl'; configure channel device type disk format 'c:\oracle\backup\%U'; ``` 2. **编写RMAN备份脚本**:创建一个RMAN命令脚本(如`backup_...
- **快照控制文件(SNAPSHOT CONTROLFILE NAME)**:定义快照控制文件的位置,用于记录最近的RMAN操作。 理解并正确配置这些RMAN参数,可以有效地管理数据库备份,确保在需要时能够快速恢复数据,同时优化存储和...
- 快照控制文件的生成路径可以通过`CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_TestDB12.f';`命令进行配置。对于RAC环境,建议将其放置在共享存储上。 #### ...
configure snapshot controlfile name to '/backup/controlfile.ctl'; configure backup destination for disk to '/backup/oracle'; ``` 4. **创建备份策略**:定义备份类型和保留策略,例如: ``` configure...
- `CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘C:ORACLE…SNCFTEST.ORA’;` 设置快照控制文件的路径和名称,用于一致性读取。 - **备份格式**: - `CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘C:…%d_DB_%u_%s...
解决方法是将快照控制文件配置到共享位置,如`CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+DATADG/snapcf_mesdb78.f';`。 2. 将新的控制文件复制到备库服务器(10.132.136.24),可以使用`scp`命令完成此操作。 3. 在...
### Oracle数据库基本操作知识点 #### 一、表空间操作 **1.... - **创建表空间:** - **数据表空间:** ```sql CREATE TABLESPACE tablespace_name LOGGING DATAFILE '/XXX/xxx/datafile_name1.ora' SIZE 4095M;...
DBMS_DG.DG_CONFIGURE_SNAPSHOT('primary_db', 'snap_primary', 600); ``` #### 4.7 配置物理备数据库 ```sql DBMS_DG.DG_CONFIGURE_STANDBY('standby_db', 'snap_primary', 'PHYSICAL'); ``` #### 4.8 执行故障...
Oracle数据库是世界上最广泛使用的数据库系统之一,其强大的功能和丰富的SQL命令集使得它在企业级应用中占据主导地位。在管理Oracle数据库时,理解和掌握这些命令是至关重要的。以下是一些Oracle SQL命令的关键点,...