博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
当前联机日志损坏恢复
阅读量:5950 次
发布时间:2019-06-19

本文共 5887 字,大约阅读时间需要 19 分钟。

hot3.png

环境模拟

删除状态为active的联机日志,然后强行关闭数据库

处理过程

SQL> startup
ORACLE instance started.

Total System Global Area 167772160 bytes

Fixed Size 1260720 bytes
Variable Size 142607184 bytes
Database Buffers 16777216 bytes
Redo Buffers 7127040 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/oradata/xienfei/redo01.log’
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

Alert.log 日志中错误

Wed Aug 24 00:26:33 2011
Errors in file /u01/admin/xienfei/udump/xff_ora_9186.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/oradata/xienfei/redo01.log’
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

xff_ora_9186.trc文件中错误

ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/oradata/xienfei/redo01.log’
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

查询当前日志组状态

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

GROUP# STATUS MEMBER

———- —————- ———————————————
1 CURRENT /u01/oradata/xienfei/redo01.log
3 INACTIVE /u01/oradata/xienfei/redo03.log
2 ACTIVE /u01/oradata/xienfei/redo02.log

尝试删除redo日志

SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01623: log 1 is current log for instance xff (thread 1) – cannot drop
ORA-00312: online log 1 thread 1: ‘/u01/oradata/xienfei/redo01.log’

发现是当前日志不能被删除,尝试切换日志

SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open

在数据库未打开状态,不能切换日志,只能尝试清空日志

SQL> alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance xff (thread 1)
ORA-00312: online log 1 thread 1: ‘/u01/oradata/xienfei/redo01.log’

因为数据库恢复需要使用,不能被清空,尝试不完成恢复

SQL> recover database until cancel;
ORA-00279: change 1272687 generated at 08/24/2011 00:20:05 needed for thread 1
ORA-00289: suggestion : /u01/archive/1_27_756841839.arc
ORA-00280: change 1272687 for thread 1 is in sequence #27

Specify log: {=suggested | filename | AUTO | CANCEL}

auto
ORA-00279: change 1272903 generated at 08/24/2011 00:25:17 needed for thread 1
ORA-00289: suggestion : /u01/archive/1_28_756841839.arc
ORA-00280: change 1272903 for thread 1 is in sequence #28
ORA-00278: log file ‘/u01/archive/1_27_756841839.arc’ no longer needed for this
recovery

ORA-00308: cannot open archived log ‘/u01/archive/1_28_756841839.arc’

ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

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/oradata/xienfei/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/oradata/xienfei/system01.dbf’

创建pfile文件,添加隐含参数,使之不进行检查点一致性校验

SQL> create pfile=’/tmp/pfile’ from spfile;

File created.

修改pfile ,添加以下参数

*._allow_resetlogs_corruption=TRUE
*._allow_error_simulation=TRUE

SQL> shutdown abort

ORACLE instance shut down.

使用pfile打开数据库

SQL> startup pfile=’/tmp/pfile’
ORACLE instance started.

Total System Global Area 167772160 bytes

Fixed Size 1260720 bytes
Variable Size 150995792 bytes
Database Buffers 8388608 bytes
Redo Buffers 7127040 bytes
Database mounted.
ORA-38760: This database instance failed to turn on flashback database

发现flashback导致数据库不能被正常打开,尝试关闭它

SQL> alter database flashback off;

Database altered.

尝试直接open数据库

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

根据提示,使用resetlogs打开数据库

SQL> alter database open resetlogs;

Database altered.

查询日志状态

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

GROUP# STATUS MEMBER

———- —————- ———————————————
3 UNUSED /u01/oradata/xienfei/redo03.log
2 UNUSED /u01/oradata/xienfei/redo02.log
1 CURRENT /u01/oradata/xienfei/redo01.log

因为group1错误,而当前日志组在group 1上,所以切换日志组

SQL> alter system switch logfile;

System altered.

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

GROUP# STATUS MEMBER

———- —————- ———————————————
3 UNUSED /u01/oradata/xienfei/redo03.log
2 CURRENT /u01/oradata/xienfei/redo02.log
1 ACTIVE /u01/oradata/xienfei/redo01.log

SQL> alter system checkpoint;

System altered.

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

GROUP# STATUS MEMBER

———- —————- ———————————————
3 UNUSED /u01/oradata/xienfei/redo03.log
2 CURRENT /u01/oradata/xienfei/redo02.log
1 INACTIVE /u01/oradata/xienfei/redo01.log
删除有问题的group 1日志组
SQL> alter database drop logfile group 1;

Database altered.

SQL> alter system switch logfile;

System altered.

添加日志组并检查是否正确

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

GROUP# STATUS MEMBER

———- —————- ———————————————
3 CURRENT /u01/oradata/xienfei/redo03.log
2 ACTIVE /u01/oradata/xienfei/redo02.log

SQL> alter database add logfile group 1 ‘/u01/oradata/xienfei/redo01.log’ size 50m reuse;

Database altered.

SQL> alter system switch logfile;

System altered.

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

GROUP# STATUS MEMBER

———- —————- ———————————————
3 ACTIVE /u01/oradata/xienfei/redo03.log
2 ACTIVE /u01/oradata/xienfei/redo02.log
1 CURRENT /u01/oradata/xienfei/redo01.log

注意:根据oracle官方建议,使用oracle隐含参数运行数据库可能存在很多不稳定因素,建议立即导出数据库数据,然后新建库,重新导入数据

 

更多精彩Oracle内容 请关注我:

转载于:https://my.oschina.net/5486002/blog/684048

你可能感兴趣的文章
windows服务器远程关机或重启
查看>>
WPF老矣,尚能饭否——且说说WPF今生未来(中):策略
查看>>
redux-form(V7.4.2)笔记(三)之Flow简介
查看>>
通过迁移的方式解决Active Directory服务器问题之6
查看>>
使用kibana和elasticsearch日志实时绘制图表
查看>>
Gevent Tutorial
查看>>
Reactive Extensions入门(6):使用Rx进行单元测试
查看>>
利用OpenCV在picture控件中显示图片
查看>>
灵活的数据管理和展示javascript类库 - Recline.js
查看>>
XslTransform.Transform方法将结果输出到字符串
查看>>
在shell中获取当前机器的ip地址
查看>>
win8 开发之旅(5) --五子棋游戏开发
查看>>
单例HashTable例子
查看>>
[CareerCup][Google Interview] Find kth number in a BST
查看>>
解决Putty中左边 alt+b 不工作的问题
查看>>
ORACLE批量更新四种方法比较
查看>>
web开发人员必备的提高开发水平的20个参考手册
查看>>
socat: Linux / UNIX TCP Port Forwarder
查看>>
HDOJ 2056
查看>>
2012年最佳免费网站和移动应用 PSD 界面素材揭晓
查看>>