温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

RAC控制文件恢复的三种不同情况分别是什么

发布时间:2021-11-09 16:50:53 来源:亿速云 阅读:120 作者:柒染 栏目:建站服务器

RAC控制文件恢复的三种不同情况分别是什么,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

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: {<RET>=suggested | filename | AUTO | CANCEL}
+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: {<RET>=suggested | filename | AUTO | CANCEL}
+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: {<RET>=suggested | filename | AUTO | CANCEL}
+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: {<RET>=suggested | filename | AUTO | CANCEL}
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控制文件恢复的三种不同情况分别是什么问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

rac
AI