Heim  >  Artikel  >  Datenbank  >  恢复控制文件后如何避免resetlogs打开数据库?

恢复控制文件后如何避免resetlogs打开数据库?

WBOY
WBOYOriginal
2016-06-07 16:45:331051Durchsuche

恢复控制文件后,数据库使用resetlogs方式打开,在线日志的序列被重置。

恢复控制文件后,数据库使用resetlogs方式打开,在线日志的序列被重置。

SYS@practice >select group#,sequence#,archived,status,first_change#,next_change# from v$log;

    GROUP#  SEQUENCE# ARC STATUS          FIRST_CHANGE# NEXT_CHANGE#
---------- ---------- --- ---------------- ------------- ------------
        1          1 NO  CURRENT                1014415  2.8147E+14
        2          0 YES UNUSED                      0            0
        3          0 YES UNUSED                      0            0

如果没有被resetlog截断的话当前日志的序列号应该是7,8,9
SYS@practice >select recid,sequence#,first_change#,next_change# from v$log_history;

    RECID  SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
---------- ---------- ------------- ------------
        1          1        925702      955284
        2          2        955284      955847
        3          3        955847      971151
        4          4        971151      987800
        5          5        987800      997957
        6          6        997957      1010981
        7          1      1010981      1013463
        8          2      1013463      1013471
        9          3      1013471      1014415

如果恢复完控制文件,不使用resetlogs是打不开数据库的。

我们可以采取手工创建控制文件的方法打开数据库,保持联机日志的sequence#连续。下面的实验来演示具体操作过程。

在实验之前先手工切换3次日志,使得在线日志的序列号产生变化。在恢复结束后作为参考。
SYS@practice >alter system archive log current;

SYS@practice >alter system archive log current;

SYS@practice >alter system archive log current;

切换后当前连接日志状态如下
SYS@practice >select group#,sequence#,archived,status,first_change#,next_change# from v$log;

    GROUP#  SEQUENCE# ARC STATUS          FIRST_CHANGE# NEXT_CHANGE#
---------- ---------- --- ---------------- ------------- ------------
        1          4 NO  CURRENT                1030130  2.8147E+14
        2          2 YES INACTIVE              1030109      1030117
        3          3 YES ACTIVE                1030117      1030130

1,恢复控制文件
RMAN> startup force nomount;

Oracle instance started

Total System Global Area    580395008 bytes

Fixed Size                    2255392 bytes
Variable Size                402654688 bytes
Database Buffers            171966464 bytes
Redo Buffers                  3518464 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 06-OCT-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

recovery area destination: /u01/fast_recovery_area
database name (or database unique name) used for search: PRACTICE
channel ORA_DISK_1: AUTOBACKUP /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251717_b35s05gm_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20141006
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/fast_recovery_area/PRACTICE/autobackup/2014_10_06/o1_mf_s_860251717_b35s05gm_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/oradata/practice/control01.ctl
output file name=/u01/fast_recovery_area/practice/control02.ctl
Finished restore at 06-OCT-14

2,启动数据库到mount状态
RMAN> mount database;

database mounted
released channel: ORA_DISK_1

3,恢复数据库
RMAN> recover database;

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn