RAC控制文件恢复的三种不同情况分别是什么,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
成都创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都网站设计、成都网站制作、外贸网站建设、宝清网络推广、小程序制作、宝清网络营销、宝清企业策划、宝清品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联公司为所有大学生创业者提供宝清建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com
RAC控制文件恢复(三种不同情况)
测试环境:
系统:LINUX-64
数据库:10.2.0.1
二节点的RAC(RACDB1,RACDB2),存储用的ASM
有备份情况下,丢失控制文件,我们改如何恢复?
一:使用备份的控制文件恢复,最后需要使用resetlogs打开。
(1) 备份控制文件
RMAN> backup current controlfile;
(2) 进行日志切换和数据修改
RACDB1>alter system switch logfile;
System altered.
RACDB1>create table test2 as select * from dba_users;
Table created.
RACDB1>alter system switch logfile;
System altered.
RACDB1>SELECT thread#,group#,sequence#,status FROM V$log;
THREAD# GROUP# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
1 1 5 ACTIVE
1 2 6 CURRENT
2 3 3 CURRENT
2 4 2 INACTIVE
1 5 4 INACTIVE
(3) 关闭数据库,删除控制文件
RACDB1>shutdown abort;
RACDB2>shutdown abort;
ASMCMD> pwd
+rac_disk/racdb/controlfile
ASMCMD> ls
Current.256.794232615
ASMCMD> rm *
(4) 启动数据库,无控制文件,所以只能到nomount
RACDB1>startup
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 2019448 bytes
Variable Size 142610312 bytes
Database Buffers 37748736 bytes
Redo Buffers 2170880 bytes
ORA-00205: error in identifying control file, check alert log for more info
(5) 恢复控制文件
RMAN> restore controlfile from '+RAC_DISK/racdb/backupset/2012_09_28/ncnnf0_tag20120928t003933_0.272.795141579';
RACDB1>alter database mount;
Database altered.
RACDB1>SELECT thread#,group#,sequence#,status FROM V$log;
THREAD# GROUP# SEQUENCE# STATUS
---------- ---------- ---------- ----------------
1 1 2 CURRENT
1 2 0 UNUSED
1 5 1 INACTIVE
2 4 0 UNUSED
2 3 1 CURRENT
(6) 恢复数据库
先使用auto,恢复到current联机日志,oracle会提示找不到归档,这时候需要自己手动输入联机日志。如下:
RACDB1>recover database using backup controlfile;
ORA-00279: change 1185078 generated at 09/28/2012 00:40:37 needed for thread 1
ORA-00289: suggestion : +RAC_DISK/racdb/flashback/1_6_795092359.dbf
ORA-00280: change 1185078 for thread 1 is in sequence #6
Specify log: {
+rac_disk/racdb/onlinelog/group_2.258.794232619 --输入RACDB1的current联机日志
ORA-00279: change 1185078 generated at 09/28/2012 00:40:10 needed for thread 2
ORA-00289: suggestion : +RAC_DISK/racdb/flashback/2_2_795092359.dbf
ORA-00280: change 1185078 for thread 2 is in sequence #2
Specify log: {
+rac_disk/racdb/onlinelog/group_4.266.794234285 --这个不是RACDB2的current联机日志,其实也可以输入归档。
ORA-00279: change 1185082 generated at 09/28/2012 00:40:38 needed for thread 2
ORA-00289: suggestion : +RAC_DISK/racdb/flashback/2_3_795092359.dbf
ORA-00280: change 1185082 for thread 2 is in sequence #3
ORA-00278: log file '+rac_disk/racdb/onlinelog/group_4.266.794234285' no longer
needed for this recovery
Specify log: {
+rac_disk/racdb/onlinelog/group_3.265.794234279 --这个是RACDB2的current联机日志
Log applied.
Media recovery complete.
总结:RAC环境下,要使用current联机日志时,必须要用的每个节点的联机日志。
(7) 打开数据库,以resetlogs方式。
RACDB1>alter database open resetlogs;
Database altered.
RACDB2>startup
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 2019448 bytes
Variable Size 138416008 bytes
Database Buffers 41943040 bytes
Redo Buffers 2170880 bytes
Database mounted.
Database opened.
RACDB1>select count(*) from test2;
COUNT(*)
----------
11
二:用noresetlogs方法重建控制文件
(1) 备份控制文件
RMAN> backup current controlfile;
(2) 切换日志和操作数据
RACDB1>alter system switch logfile;
System altered.
RACDB1>create table test3 as select * from dba_data_files;
Table created.
RACDB1>alter system switch logfile;
System altered.
(3) 关闭数据库,删除控制文件
RACDB1>shutdown abort
RACDB2>shutdown abort
ASMCMD> pwd
+rac_disk/racdb/controlfile
ASMCMD> ls
Current.256.795142367
ASMCMD> rm *
RACDB1>startup
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 2019448 bytes
Variable Size 146804616 bytes
Database Buffers 33554432 bytes
Redo Buffers 2170880 bytes
ORA-00205: error in identifying control file, check alert log for more info
(4) 恢复控制文件
RMAN> restore controlfile from '+RAC_DISK/racdb/backupset/2012_09_28/ncnnf0_tag20120928t015109_0.285.795145873';
RACDB1>alter database mount;
Database altered.
RACDB1>alter database backup controlfile to trace; --把控制文件备份到trace文件
Database altered.
(5) 重建控制文件。
RACDB1>shutdown immediate
删除控制文件。
RACDB1>startup nomount;
(6) 用noresetlogs方式重建控制文件
由于是RAC环境,所以先需要修改如下参数:
不修改参数报错如下:
ORA-01503: CREATE CONTROLFILE failed
ORA-12720: operation requires database is in EXCLUSIVE mode
RACDB1>alter system set cluster_database=FALSE scope=spfile sid='*';
System altered.
RACDB1>shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
RACDB1>startup nomount;
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 2019448 bytes
Variable Size 146804616 bytes
Database Buffers 33554432 bytes
Redo Buffers 2170880 bytes
CREATE CONTROLFILE REUSE DATABASE "RACDB" NORESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'+RAC_DISK/racdb/onlinelog/group_1.257.795091225',
'+RAC_DISK/racdb/onlinelog/group_1.295.795091229'
) SIZE 50M,
GROUP 2 '+RAC_DISK/racdb/onlinelog/group_2.258.794232619' SIZE 50M,
GROUP 3 '+RAC_DISK/racdb/onlinelog/group_3.265.794234279' SIZE 50M,
GROUP 4 '+RAC_DISK/racdb/onlinelog/group_4.266.794234285' SIZE 50M,
GROUP 5 (
'+RAC_DISK/racdb/onlinelog/group_5.269.795092365',
'+RAC_DISK/racdb/onlinelog/group_5.296.795092369'
) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'+RAC_DISK/racdb/datafile/system.259.794232627',
'+RAC_DISK/racdb/datafile/undotbs1.260.794232647',
'+RAC_DISK/racdb/datafile/sysaux.261.794232657',
'+RAC_DISK/racdb/datafile/undotbs2.263.794232675',
'+RAC_DISK/racdb/datafile/users.264.794232683'
CHARACTER SET ZHS16GBK
;
27
CREATE CONTROLFILE REUSE DATABASE "RACDB" NORESETLOGS ARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01276: Cannot add file +RAC_DISK/racdb/controlfile/current.256.795146237.
File has an Oracle Managed Files file name. -–由于使用OMF方式,所以需先在参数文件中注释掉controlfile。
RACDB1>show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +RAC_DISK/racdb/controlfile/cu
rrent.256.795146237
RACDB1>alter system set control_files=false scope=spfile sid='*';
System altered.
RACDB1>alter system reset control_files scope=spfile sid='*';
System altered.
RACDB1>shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
RACDB1>startup nomount;
ORACLE instance started.
Total System Global Area 184549376 bytes
Fixed Size 2019448 bytes
Variable Size 146804616 bytes
Database Buffers 33554432 bytes
Redo Buffers 2170880 bytes
RACDB1>show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/product/10.2.0
/db_1/dbs/cntrlRACDB1.dbf
CREATE CONTROLFILE REUSE DATABASE "RACDB" NORESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'+RAC_DISK/racdb/onlinelog/group_1.257.795091225',
'+RAC_DISK/racdb/onlinelog/group_1.295.795091229'
) SIZE 50M,
GROUP 2 '+RAC_DISK/racdb/onlinelog/group_2.258.794232619' SIZE 50M,
GROUP 3 '+RAC_DISK/racdb/onlinelog/group_3.265.794234279' SIZE 50M,
GROUP 4 '+RAC_DISK/racdb/onlinelog/group_4.266.794234285' SIZE 50M,
GROUP 5 (
'+RAC_DISK/racdb/onlinelog/group_5.269.795092365',
'+RAC_DISK/racdb/onlinelog/group_5.296.795092369'
) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'+RAC_DISK/racdb/datafile/system.259.794232627',
'+RAC_DISK/racdb/datafile/undotbs1.260.794232647',
'+RAC_DISK/racdb/datafile/sysaux.261.794232657',
'+RAC_DISK/racdb/datafile/undotbs2.263.794232675',
'+RAC_DISK/racdb/datafile/users.264.794232683'
CHARACTER SET ZHS16GBK
27 ;
Control file created.
RACDB1>RACDB1>show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +RAC_DISK/racdb/controlfile/cu
rrent.256.795147383, +RAC_DISK
/racdb/controlfile/current.279
.795147383
RACDB1>alter system set cluster_database=true scope=spfile sid='*'; --勿忘
System altered.
(7) 恢复数据库
RACDB1>recover database;
ORA-00279: change 1185480 generated at 09/28/2012 01:45:00 needed for thread 1
ORA-00289: suggestion : +RAC_DISK/racdb/flashback/1_1_795145477.dbf
ORA-00280: change 1185480 for thread 1 is in sequence #1
Specify log: {
auto
Log applied.
Media recovery complete.
(8) 打开数据库
RACDB1>alter database open;
Database altered.
三:用resetlogs方法重建控制文件。此方法恢复过程和使用备份的控制文件类似。这里就不在叙述。最后也需要使用resetlogs方式打开。
值得注意的是,create controlfile resetlogs/noresetlogs 这两种重建方法的却别在于,noresetlogs重建控制文件时,控制文件中datafile checkpoint来自online logs中的current log头。而用resetlogs重建控制文件时,控制文件中datafile checkpoint来自各数据文件头。
关于RAC控制文件恢复的三种不同情况分别是什么问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。