Oracle控制文件在缺失归档日志的情况下的恢复

0    283    1

Tags:

👉 本文共约7512个字,系统预计阅读时间或需29分钟。

目录

    众所周知,恢复控制文件时“recover database”命令可能需要使用归档日志。所谓缺失归档日志,是指控制文件从备份还原之后,在执行“recover database”命令恢复时报告找不到相应的日志导致恢复终止的情况。

    这种情况下的恢复操作主要步骤如下:

    ① 首先还原控制文件,方式不限

    ② 执行“recover database”命令将报RMAN-06054错误,即找不到某归档日志

    ③ 查看相关的动态性能视图,对问题定位,确认问题与控制文件,而不是数据文件相关(与数据文件相关必须进行不完全恢复)

    ④ 利用create controlfile 命令重建控制文件

    ⑤ 再次执行“recover database”命令,还会报RMAN-06054错误,这次是找不到另一个归档日志,其序列号应该大于第二步中的

    ⑥ 查看v$log视图确定第5步中所要的是哪个日志

    ⑦ 执行SQLPLUS的”recover database using backup controlfile“命令,等”Specify log:“提示符出现后给出正确的在线日志路径,直到命令成功结束。

    ⑧ 以resetlogs方式打开数据库

    ⑨ 由于创建的控制文件内不会有临时数据文件的信息,需要重新将其添加回临时表空间

    ⑩ 将控制文件内其他丢失的信息用catalog和configure等命令再添加回去。

    当前current**日志序列号为:5**,此时进行控制文件备份

    SQL> archive log list;

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch

    Oldest online log sequence 3

    Next log sequence to archive 5

    Current log sequence 5

    SQL>

    RMAN> backup current controlfile;

    Starting backup at 2015-02-04 16:28:13

    using channel ORA_DISK_1

    channel ORA_DISK_1: starting full datafile backup set

    channel ORA_DISK_1: specifying datafile(s) in backup set

    including current control file in backup set

    channel ORA_DISK_1: starting piece 1 at 2015-02-04 16:28:14

    channel ORA_DISK_1: finished piece 1 at 2015-02-04 16:28:15

    piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/1vpuel4t_1_1 tag=TAG20150204T162813 comment=NONE

    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

    Finished backup at 2015-02-04 16:28:15

    RMAN>

    多次切换日志后,现在的CURRENT**日志是20号,所有控制文件丢失并且第15号归档日志丢失,数据库启动后停留在了nomount状态:**

    SQL> alter system switch logfile;

    。。。。。。。。

    System altered.

    SQL> archive log list;

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch

    Oldest online log sequence 18

    Next log sequence to archive 20

    Current log sequence 20

    SQL>

    RMAN> delete archivelog sequence 15;

    released channel: ORA_DISK_1

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=257 device type=DISK

    List of Archived Log Copies for database with db_unique_name LILOVE

    =====================================================================

    Key Thrd Seq S Low Time


    44 1 15 X 2015-02-04 16:29:58

    ​ Name: /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_15_870711361.dbf

    Do you really want to delete the above objects (enter YES or NO)? yes

    deleted archived log

    archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_15_870711361.dbf RECID=44 STAMP=870798598

    Deleted 1 objects

    RMAN>

    [root@rhel6_lhr ~]# ll /u01/app/oracle/oradata/utf8test/*

    -rw-r----- 1 oracle asmadmin 10076160 Feb 4 16:40 /u01/app/oracle/oradata/utf8test/control01.ctl

    -rw-r----- 1 oracle oinstall 10076160 Feb 4 16:40 /u01/app/oracle/oradata/utf8test/control02.ctl

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/redo01.log

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:40 /u01/app/oracle/oradata/utf8test/redo02.log

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/redo03.log

    -rw-r----- 1 oracle asmadmin 608182272 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/sysaux01.dbf

    -rw-r----- 1 oracle asmadmin 775954432 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/system01.dbf

    -rw-r----- 1 oracle asmadmin 10493952 Feb 3 16:15 /u01/app/oracle/oradata/utf8test/tbs_read01.dbf

    -rw-r----- 1 oracle asmadmin 20979712 Feb 4 11:15 /u01/app/oracle/oradata/utf8test/temp01.dbf

    -rw-r----- 1 oracle asmadmin 52436992 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/undotbs01.dbf

    -rw-r----- 1 oracle asmadmin 10493952 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/users01.dbf

    [root@rhel6_lhr ~]# rm -rf /u01/app/oracle/oradata/utf8test/control0*

    [root@rhel6_lhr ~]# ll /u01/app/oracle/oradata/utf8test/*

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/redo01.log

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:40 /u01/app/oracle/oradata/utf8test/redo02.log

    -rw-r----- 1 oracle asmadmin 52429312 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/redo03.log

    -rw-r----- 1 oracle asmadmin 608182272 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/sysaux01.dbf

    -rw-r----- 1 oracle asmadmin 775954432 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/system01.dbf

    -rw-r----- 1 oracle asmadmin 10493952 Feb 3 16:15 /u01/app/oracle/oradata/utf8test/tbs_read01.dbf

    -rw-r----- 1 oracle asmadmin 20979712 Feb 4 11:15 /u01/app/oracle/oradata/utf8test/temp01.dbf

    -rw-r----- 1 oracle asmadmin 52436992 Feb 4 16:39 /u01/app/oracle/oradata/utf8test/undotbs01.dbf

    -rw-r----- 1 oracle asmadmin 10493952 Feb 4 16:30 /u01/app/oracle/oradata/utf8test/users01.dbf

    [root@rhel6_lhr ~]#

    SQL> startup force;

    ORACLE instance started.

    Total System Global Area 501059584 bytes

    Fixed Size 2229744 bytes

    Variable Size 356518416 bytes

    Database Buffers 134217728 bytes

    Redo Buffers 8093696 bytes

    ORA-00205: error in identifying control file, check alert log for more info

    SQL>

    告警文件报错:

    ALTER DATABASE MOUNT

    ORA-00210: cannot open the specified control file

    ORA-00202: control file: '/u01/app/oracle/oradata/utf8test/control02.ctl'

    ORA-27037: unable to obtain file status

    Linux-x86_64 Error: 2: No such file or directory

    Additional information: 3

    ORA-00210: cannot open the specified control file

    ORA-00202: control file: '/u01/app/oracle/oradata/utf8test/control01.ctl'

    ORA-27037: unable to obtain file status

    Linux-x86_64 Error: 2: No such file or directory

    Additional information: 3

    ORA-205 signalled during: ALTER DATABASE MOUNT...

    下面,我们开始恢复:

    RMAN> restore controlfile from '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/1vpuel4t_1_1';

    Starting restore at 2015-02-04 16:44:10

    using channel ORA_DISK_1

    channel ORA_DISK_1: restoring control file

    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

    output file name=/u01/app/oracle/oradata/utf8test/control01.ctl

    output file name=/u01/app/oracle/oradata/utf8test/control02.ctl

    Finished restore at 2015-02-04 16:44:11

    RMAN>

    查看控制文件的确已经恢复:

    [root@rhel6_lhr ~]# ll /u01/app/oracle/oradata/utf8test/con*

    -rw-r----- 1 oracle asmadmin 10076160 Feb 4 16:44 /u01/app/oracle/oradata/utf8test/control01.ctl

    -rw-r----- 1 oracle asmadmin 10076160 Feb 4 16:44 /u01/app/oracle/oradata/utf8test/control02.ctl

    [root@rhel6_lhr ~]#

    下面我们挂载数据库:

    RMAN> mount database;

    database mounted

    released channel: ORA_DISK_1

    RMAN>

    下边恢复数据库将报错,表示找不到15**号归档文件:**

    RMAN> recover database;

    Starting recover at 2015-02-04 16:47:55

    allocated channel: ORA_DISK_1

    channel ORA_DISK_1: SID=10 device type=DISK

    datafile 5 not processed because file is read-only

    starting media recovery

    archived log for thread 1 with sequence 18 is already on disk as file /u01/app/oracle/oradata/utf8test/redo03.log

    archived log for thread 1 with sequence 19 is already on disk as file /u01/app/oracle/oradata/utf8test/redo01.log

    archived log for thread 1 with sequence 20 is already on disk as file /u01/app/oracle/oradata/utf8test/redo02.log

    archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_5_870711361.dbf thread=1 sequence=5

    archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_6_870711361.dbf thread=1 sequence=6

    archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_870711361.dbf thread=1 sequence=7

    本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
    AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
    验证码:
    获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

    标签:

    Avatar photo

    小麦苗

    学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

    您可能还喜欢...

    发表回复