IT开放社区

重做日志文件(inactive状态)故障恢复实验

环境:

OS:centos7.3

DB:oracle11.2.0.4

重做日志文件inactive状态故障恢复

1.查看日志组状态及文件位置;

centos@SYS> select group#,members,archived,status from v$log;
    GROUP#    MEMBERS ARC STATUS
---------- ---------- --- ----------------
         1          2 NO  CURRENT
         2          2 YES INACTIVE
         3          2 YES INACTIVE
centos@SYS> select group#,member from v$logfile order by 1;
    GROUP# MEMBER
---------- --------------------------------------------------
         1 /u01/app/oracle/oradata/centos/redo01.log
         1 /u01/app/oracle/flash/redoa1.log
         2 /u01/app/oracle/flash/redob2.log
         2 /u01/app/oracle/oradata/centos/redo02.log
         3 /u01/app/oracle/flash/redoc3.log
         3 /u01/app/oracle/oradata/centos/redo03.log
6 rows selected.
centos@SYS>

2.模拟故障rm删除inactive状态日志组3;

centos@SYS> !rm /u01/app/oracle/oradata/centos/redo03.log
centos@SYS> !ls /u01/app/oracle/oradata/centos/redo03.log
ls: cannot access /u01/app/oracle/oradata/centos/redo03.log: No such file or directory
centos@SYS>

3.恢复方法一在数据库未重启的情况下重建日志组文件;

centos@SYS> alter database drop logfile group 3;
Database altered.
centos@SYS> alter database add logfile group 3('/u01/app/oracle/oradata/centos/redo03.log') size 50M;
Database altered.
centos@SYS> select group#,member from v$logfile order by 1;
    GROUP# MEMBER
---------- --------------------------------------------------
         1 /u01/app/oracle/oradata/centos/redo01.log
         1 /u01/app/oracle/flash/redoa1.log
         2 /u01/app/oracle/flash/redob2.log
         2 /u01/app/oracle/oradata/centos/redo02.log
         3 /u01/app/oracle/oradata/centos/redo03.log
centos@SYS> !ls /u01/app/oracle/oradata/centos/redo03.log
/u01/app/oracle/oradata/centos/redo03.log
centos@SYS>

4.手动切换日志文件验证恢复后的日志文件是否可用;

centos@SYS> alter system switch logfile;
System altered.
centos@SYS> select group#,members,archived,status from v$log;
    GROUP#    MEMBERS ARC STATUS
---------- ---------- --- ----------------
         1          1 NO  CURRENT
         2          1 YES INACTIVE
         3          1 YES ACTIVE
centos@SYS> alter system switch logfile;
System altered.
centos@SYS> select group#,members,archived,status from v$log;
    GROUP#    MEMBERS ARC STATUS
---------- ---------- --- ----------------
         1          1 YES ACTIVE
         2          1 NO  CURRENT
         3          1 YES ACTIVE
centos@SYS> alter system switch logfile;
System altered.
centos@SYS> select group#,members,archived,status from v$log;
    GROUP#    MEMBERS ARC STATUS
---------- ---------- --- ----------------
         1          1 YES ACTIVE
         2          1 YES ACTIVE
         3          1 NO  CURRENT
centos@SYS>

5.恢复方法二重启数据库后报错后恢复;

centos@SYS> !rm /u01/app/oracle/oradata/centos/redo02.log
centos@SYS> !ls /u01/app/oracle/oradata/centos/redo02.log
ls: cannot access /u01/app/oracle/oradata/centos/redo02.log: No such file or directory
centos@SYS> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
centos@SYS> startup
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size                2257800 bytes
Variable Size             587205752 bytes
Database Buffers          239075328 bytes
Redo Buffers              2392064 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 122901
Session ID: 1 Serial number: 5

centos@SYS>
centos@SYS> startup mount;
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size                2257800 bytes
Variable Size             587205752 bytes
Database Buffers          239075328 bytes
Redo Buffers              2392064 bytes
Database mounted.
centos@SYS> alter database clear logfile group 2;
Database altered.
centos@SYS> alter database open;
Database altered.
centos@SYS>

查看日志文件是否恢复;

centos@SYS> !ls /u01/app/oracle/oradata/centos/redo02.log
/u01/app/oracle/oradata/centos/redo02.log
centos@SYS> select group#,member from v$logfile order by 1;
    GROUP# MEMBER
---------- --------------------------------------------------
         1 /u01/app/oracle/oradata/centos/redo01.log
         2 /u01/app/oracle/oradata/centos/redo02.log
         3 /u01/app/oracle/oradata/centos/redo03.log
centos@SYS>


---END---

相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类
最新文章
    随机文章
      站点信息
      • 文章总数:113
      • 页面总数:2
      • 分类总数:3
      • 标签总数:1
      • 评论总数:0
      • 浏览总数:45518
      左邻右舍

      BlogPowerBy Z-BlogPHP 1.5 Zero ;Theme By 爱墙纸

      IT开放社区:京ICP备13044647号.初创于Oracle DBA实战班.邮箱:admin@itkaifang.com

      分享:

      支付宝

      微信