首页 数据库 mysql教程 online redo日志文件损坏恢复

online redo日志文件损坏恢复

Jun 07, 2016 pm 04:40 PM
数据库

online redo日志文件对数据库是非常重要的,当current日志文件损坏,通常就意味着要丢失数据,但是也不是绝对的,可以通过一定的

online redo日志文件损坏恢复

[日期:2015-01-11] 来源:Linux社区  作者:aaron8219 [字体:]

online redo日志文件对数据库是非常重要的,当current日志文件损坏,通常就意味着要丢失数据,但是也不是绝对的,可以通过一定的手段对redo日志文件进行恢复,运气好的话,未提交数据还是不会丢失的。
 
[Oracle@zlm2 backup]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.3.0 Production on Wed Dec 31 22:53:23 2014
 
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL> conn zlm/zlm
Connected.
 
--创建测试表
SQL> create table test(tbid number(10));
 
Table created.
 
--插入数据
SQL> insert into test values(1);

1 row created.

 

注意,并未对此insert操作commit

 

SQL> select group#,sequence#,status,first_change# from v$log;

 

    GROUP#  SEQUENCE# STATUS           FIRST_CHANGE#

---------- ---------- ---------------- -------------

         1         55 ACTIVE                 1723785

         2         56 CURRENT                1723866

         3         54 INACTIVE               1723562

 

SQL> !

[oracle@zlm2 backup]$ cd /u01/app/oracle/oradata/zlm11g/

[oracle@zlm2 zlm11g]$ ll

total 2572744

-rwxrwxr-x 1 oracle oinstall   9748480 Dec 31 22:56 control01.ctl

-rw-r----- 1 oracle oinstall 362422272 Dec 31 22:49 example01.dbf

-rw-r----- 1 oracle oinstall  52429312 Dec 31 22:51 redo01.log

-rw-r----- 1 oracle oinstall  52429312 Dec 31 22:56 redo02.log

-rw-r----- 1 oracle oinstall  52429312 Dec 31 22:49 redo03.log

-rw-r----- 1 oracle oinstall 608182272 Dec 31 22:55 sysaux01.dbf

-rw-r----- 1 oracle oinstall 775954432 Dec 31 22:55 system01.dbf

-rw-r----- 1 oracle oinstall  20979712 Dec 31 22:05 temp01.dbf

-rw-r----- 1 oracle oinstall 178266112 Dec 31 22:55 undotbs01.dbf

-rw-r----- 1 oracle oinstall  13115392 Dec 31 22:49 users01.dbf

-rw-r----- 1 oracle oinstall 524296192 Dec 31 22:49 zlm01.dbf

 

--模拟在线破坏3个redo日志

[oracle@zlm2 zlm11g]$ echo > redo01.log

[oracle@zlm2 zlm11g]$ echo > redo02.log

[oracle@zlm2 zlm11g]$ echo > redo03.log

[oracle@zlm2 zlm11g]$ exit

exit

 

--关闭数据库

SQL> shutdown immediate

ORA-01031: insufficient privileges

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate

ORA-03113: end-of-file on communication channel

Process ID: 4667

Session ID: 40 Serial number: 105

 

由于redo文件已经被破坏,一致性关闭数据库报错,报ora-03113错误

 

--重启数据库

SQL> startup

ORA-24324: service handle not initialized

ORA-01041: internal error. hostdef extension doesn't exist

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@zlm2 backup]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Wed Dec 31 22:57:34 2014

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  835104768 bytes

Fixed Size                  2232960 bytes

Variable Size             494931328 bytes

Database Buffers          335544320 bytes

Redo Buffers                2396160 bytes

Database mounted.

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/zlm11g/redo02.log'

ORA-27048: skgfifi: file header information is invalid

Additional information: 14

 

发现已无法自动启动到open状态,提示非法文件头信息,报ora-27048错误,以及ora-00313、ora-00312

由于启动数据库的时候会做一致性检查,redo的损坏使一致性检查无法通过,可以通过设置隐含参数_allow_resetlogs_corruption解决

 

--设置隐含参数

 

System altered.

 

--关闭并重启数据库

SQL> shutdown immediate

ORA-01109: database not open

 

 

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  835104768 bytes

Fixed Size                  2232960 bytes

Variable Size             494931328 bytes

Database Buffers          335544320 bytes

Redo Buffers                2396160 bytes

Database mounted.

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/zlm11g/redo02.log'

ORA-27048: skgfifi: file header information is invalid

Additional information: 14

 

 

SQL> show parameter _allow_resetlogs_corruption

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

_allow_resetlogs_corruption          boolean     TRUE

 

可以看到,刚才设置的隐含参数已经生效

 

--做一次基于cancel的不完全恢复

SQL> recover database until cancel;

ORA-00279: change 1723866 generated at 12/31/2014 22:51:41 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/fast_recovery_area/ZLM11G/archivelog/2014_12_31/o1_mf_1_56_%u_.a

rc

ORA-00280: change 1723866 for thread 1 is in sequence #56

 

 

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

auto

ORA-00308: cannot open archived log

'/u01/app/oracle/fast_recovery_area/ZLM11G/archivelog/2014_12_31/o1_mf_1_56_%u_.

arc'

ORA-27037: unable to obtain file status

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

Additional information: 3

 

 

ORA-00308: cannot open archived log

'/u01/app/oracle/fast_recovery_area/ZLM11G/archivelog/2014_12_31/o1_mf_1_56_%u_.

arc'

ORA-27037: unable to obtain file status

Linux-x86_64 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/app/oracle/oradata/zlm11g/system01.dbf'

 

 

SQL> !

[oracle@zlm2 backup]$ cd /u01/app/oracle/fast_recovery_area/ZLM11G/archivelog/2014_12_31/

[oracle@zlm2 2014_12_31]$ ll

total 56076

-rw-r----- 1 oracle oinstall 33343488 Dec 31 20:59 o1_mf_1_50_bb7wtcln_.arc

-rw-r----- 1 oracle oinstall    30720 Dec 31 21:02 o1_mf_1_51_bb7wzzlk_.arc

-rw-r----- 1 oracle oinstall 23774208 Dec 31 22:38 o1_mf_1_52_bb82m1dp_.arc

-rw-r----- 1 oracle oinstall   172032 Dec 31 22:41 o1_mf_1_53_bb82rsqv_.arc

-rw-r----- 1 oracle oinstall     6656 Dec 31 22:49 o1_mf_1_54_bb837jy3_.arc

-rw-r----- 1 oracle oinstall    14848 Dec 31 22:51 o1_mf_1_55_bb83cxqy_.arc

 

最新的归档只有到55,第56号归档还没有生成,用auto最多只能恢复到55号归档

 

--再次执行recover database until cancel,这次输入cancel

SQL> recover database until cancel;

ORA-00279: change 1723866 generated at 12/31/2014 22:51:41 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/fast_recovery_area/ZLM11G/archivelog/2014_12_31/o1_mf_1_56_%u_.a

rc

ORA-00280: change 1723866 for thread 1 is in sequence #56

 

 

Specify log: {=suggested | filename | AUTO | 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/zlm11g/system01.dbf'

 

 

ORA-01112: media recovery not started

 

 

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

 

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00600: internal error code, arguments: [2662], [0], [1723874], [0],

[1724203], [4194432], [], [], [], [], [], []

Process ID: 5139

Session ID: 1 Serial number: 5

 

用resetlogs打开数据库,报了一个600错误,先不用理会

 

SQL> select open_mode from v$database;

ERROR:

ORA-03114: not connected to ORACLE

 

此时提示未连接上数据库

 

SQL> conn / as sysdba

Connected to an idle instance.

SQL> select open_mode from v$database;

select open_mode from v$database

*

ERROR at line 1:

ORA-01034: ORACLE not available

Process ID: 0

Session ID: 0 Serial number: 0

 

提示数据库实例未启动

 

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  835104768 bytes

Fixed Size                  2232960 bytes

Variable Size             494931328 bytes

Database Buffers          335544320 bytes

Redo Buffers                2396160 bytes

Database mounted.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01139: RESETLOGS option only valid after an incomplete database recovery

 

 

SQL> recover database until cancel;

ORA-00283: recovery session canceled due to errors

ORA-16433: The database must be opened in read/write mode.

 

 

SQL> alter database open;

 

Database altered.

 

 

SQL> select count(*) from zlm.test;

 

  COUNT(*)

----------

         1

 

SQL> select * from zlm.test;

 

      TBID

----------

         1

 

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Java教程
1663
14
CakePHP 教程
1420
52
Laravel 教程
1315
25
PHP教程
1266
29
C# 教程
1239
24
iOS 18 新增'已恢复”相册功能 可找回丢失或损坏的照片 iOS 18 新增'已恢复”相册功能 可找回丢失或损坏的照片 Jul 18, 2024 am 05:48 AM

苹果公司最新发布的iOS18、iPadOS18以及macOSSequoia系统为Photos应用增添了一项重要功能,旨在帮助用户轻松恢复因各种原因丢失或损坏的照片和视频。这项新功能在Photos应用的"工具"部分引入了一个名为"已恢复"的相册,当用户设备中存在未纳入其照片库的图片或视频时,该相册将自动显示。"已恢复"相册的出现为因数据库损坏、相机应用未正确保存至照片库或第三方应用管理照片库时照片和视频丢失提供了解决方案。用户只需简单几步

Hibernate 如何实现多态映射? Hibernate 如何实现多态映射? Apr 17, 2024 pm 12:09 PM

Hibernate多态映射可映射继承类到数据库,提供以下映射类型:joined-subclass:为子类创建单独表,包含父类所有列。table-per-class:为子类创建单独表,仅包含子类特有列。union-subclass:类似joined-subclass,但父类表联合所有子类列。

在PHP中使用MySQLi建立数据库连接的详尽教程 在PHP中使用MySQLi建立数据库连接的详尽教程 Jun 04, 2024 pm 01:42 PM

如何在PHP中使用MySQLi建立数据库连接:包含MySQLi扩展(require_once)创建连接函数(functionconnect_to_db)调用连接函数($conn=connect_to_db())执行查询($result=$conn->query())关闭连接($conn->close())

如何在PHP中处理数据库连接错误 如何在PHP中处理数据库连接错误 Jun 05, 2024 pm 02:16 PM

PHP中处理数据库连接报错,可以使用以下步骤:使用mysqli_connect_errno()获取错误代码。使用mysqli_connect_error()获取错误消息。通过捕获并记录这些错误信息,可以轻松识别并解决数据库连接问题,确保应用程序的顺畅运行。

如何在 Golang 中使用数据库回调函数? 如何在 Golang 中使用数据库回调函数? Jun 03, 2024 pm 02:20 PM

在Golang中使用数据库回调函数可以实现:在指定数据库操作完成后执行自定义代码。通过单独的函数添加自定义行为,无需编写额外代码。回调函数可用于插入、更新、删除和查询操作。必须使用sql.Exec、sql.QueryRow或sql.Query函数才能使用回调函数。

如何在 Golang 中将 JSON 数据保存到数据库中? 如何在 Golang 中将 JSON 数据保存到数据库中? Jun 06, 2024 am 11:24 AM

可以通过使用gjson库或json.Unmarshal函数将JSON数据保存到MySQL数据库中。gjson库提供了方便的方法来解析JSON字段,而json.Unmarshal函数需要一个目标类型指针来解组JSON数据。这两种方法都需要准备SQL语句和执行插入操作来将数据持久化到数据库中。

如何用 Golang 连接远程数据库? 如何用 Golang 连接远程数据库? Jun 01, 2024 pm 08:31 PM

通过Go标准库database/sql包,可以连接到MySQL、PostgreSQL或SQLite等远程数据库:创建包含数据库连接信息的连接字符串。使用sql.Open()函数打开数据库连接。执行SQL查询和插入操作等数据库操作。使用defer关闭数据库连接以释放资源。

PHP与不同数据库的连接:MySQL、PostgreSQL、Oracle和更多 PHP与不同数据库的连接:MySQL、PostgreSQL、Oracle和更多 Jun 01, 2024 pm 03:02 PM

PHP连接数据库指南:MySQL:安装MySQLi扩展,创建连接(servername、username、password、dbname)。PostgreSQL:安装PgSQL扩展,创建连接(host、dbname、user、password)。Oracle:安装OracleOCI8扩展,创建连接(servername、username、password)。实战案例:获取MySQL数据、PostgreSQL查询、OracleOCI8更新记录。

See all articles