Oracle current日志文件损坏

复制代码
请手工删除之前所有的归档日志和备份文件,并对现在的数据库做一个全备
RMAN> backup database; // 全库备份

查看当前日志状态

SQL> select a.group#, a.member, b.status from v$logfile a, v$log b where a.group#=b.group# order by group#;

    GROUP# MEMBER                                             STATUS
---------- -------------------------------------------------- ------------
         1 /u01/app/oracle/oradata/orcltest/redo01.log        INACTIVE
         2 /u01/app/oracle/oradata/orcltest/redo02.log        INACTIVE
         3 /u01/app/oracle/oradata/orcltest/redo03.log        CURRENT
SQL> create table scott.t02 as select * from dba_users;

模拟故障:current日志文件清空
echo ‘’ > /u01/app/oracle/oradata/orcltest/redo03.log

现象:前台正常的增删改查不受影响,但一旦出现切换日志数据库宕机
SQL> create table scott.t03 as select * from dba_users;
SQL> alter system switch logfile;

alter system switch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 3758
Session ID: 1 Serial number: 9
查看alert日志

Errors in file /u01/app/oracle/diag/rdbms/orcltest/orcltest/trace/orcltest_lgwr_8969.trc:
ORA-00316: log 2 of thread 1, type 0 in header is not log file
ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcltest/redo02.log'
LGWR (ospid: 8969): terminating the instance due to error 316
Instance terminated by LGWR, pid = 3458
恢复:使用不完全恢复打开
sqlplus / as sysdba
SQL> startup mount
SQL> recover database until cancel; // 不完全恢复

ORA-00279: change 1117792 generated at 03/19/2020 14:42:10 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/oradata/orcltest/archivelog/1_15_1035459690.dbf
ORA-00280: change 1117792 for thread 1 is in sequence #15

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel // 这里输入cancel,因为当前日志组已经损坏

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcltest/system01.dbf'
SQL> alter database open resetlogs; // 会发现启库失败

alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcltest/system01.dbf'
这个时候就需要加入隐含参数,再启动
SQL> alter system set “_allow_resetlogs_corruption”=true scope=spfile;
SQL> shutdown abort
SQL> startup mount
SQL> recover database until cancel; // 不完全恢复
输入cancel
SQL> alter database open resetlogs;

说明:a. 使用该方式恢复的库,可能会造成数据的丢失,而且也并不能保证一定成功。
b. 恢复成功后,应将表全部使用expdp导出,重建库。
c. 上面的实验每个日志组都只有一个member,如果每个日志组有两个member又是什么样子呢?先说下我的结论:损坏其中任何一个member对数据库没什么影响,只是在切换到有member损坏的日志组时,会在alert日志中提示告警ORA-00313 ORA-00312 ORA-27048,解决办法就是删掉这个member,重新添加,不需要对数据库进行重启,实验过程我就不展示了。所以最好是每组日志中设置2个成员。

复制代码

posted on   数据与人文  阅读(2)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2024-01-29 Linux如何查询是哪些进程占用了端口
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示