current online redo logfile 丢失的处理方法

昨天做了rm -rf操作后的恢复演练,而且是在没有任何备份的情况下。今天在做破坏性操作前,做了个rman全备,然后在线删除全部数据库文件,包括控制文件,数据文件,在线日志文件,归档文件等。来看看有什么方法可以让数据库恢复运行,由于是current redo logfile丢失,那么本次测试是会丢失数据的,所以可以作为不完全恢复的一个案例。

--登入数据库进行dml操作

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 26 13:40:37 2014

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

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> select * from aaron8219.test1;

INT

----------

1

2

SQL> insert into aaron8219.test1 values(3);

1 row created.

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

GROUP# STATUS              SEQUENCE#

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

1 INACTIVE                  1

2 CURRENT                2

3 INACTIVE                  0

--不提交,另开一个session进行rm -rf操作

[[email protected] ~]# cd /u01/app/oracle/oradata

[[email protected] oradata]# ll

total 4

drwxr-x--- 2 oracle oinstall 4096 Aug 25 16:09 ora10g

[[email protected] oradata]# rm -rf ora10g/

[[email protected] oradata]# ll

total 0

--原session对数据库abort,模拟current online redo logfile丢失

SQL> shutdown abort

--用之前刚生成的rman全备来还原数据库各类文件

[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Aug 26 13:44:58 2014

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

connected to target database: ora10g (not mounted)

RMAN> restore controlfile from ‘/rmanbak/full_ORA10G_4175411955_20140826_02pgtq5h_1_1.bak‘;

Starting restore at 26-AUG-14

using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:04

output filename=/u01/app/oracle/oradata/ora10g/control01.ctl

output filename=/u01/app/oracle/oradata/ora10g/control02.ctl

output filename=/u01/app/oracle/oradata/ora10g/control03.ctl

Finished restore at 26-AUG-14

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 26-AUG-14

Starting implicit crosscheck backup at 26-AUG-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 26-AUG-14

Starting implicit crosscheck copy at 26-AUG-14

using channel ORA_DISK_1

Finished implicit crosscheck copy at 26-AUG-14

searching for all files in the recovery area

cataloging files...

cataloging done

List of Cataloged Files

=======================

File Name: /u01/app/oracle/flash_recovery_area/ORA10G/autobackup/2014_08_26/o1_mf_s_856615092_9zr3snsq_.bkp

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/ora10g/system01.dbf

restoring datafile 00002 to /u01/app/oracle/oradata/ora10g/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/ora10g/sysaux01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/ora10g/users01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/ora10g/example01.dbf

channel ORA_DISK_1: reading from backup piece /rmanbak/full_ORA10G_4175411955_20140826_01pgtq36_1_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/rmanbak/full_ORA10G_4175411955_20140826_01pgtq36_1_1.bak tag=TAG20140826T123653

channel ORA_DISK_1: restore complete, elapsed time: 00:01:46

Finished restore at 26-AUG-14

RMAN> exit

Recovery Manager complete.

由于rman并不备份在线日志文件,刚才的rman只是做了个全库备份和控制文件的备份,可以看到redo01.log,redo02.log,redo03.log这3个文件并不存在

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 26 14:52:35 2014

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

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> select open_mode from v$database;

OPEN_MODE

----------

MOUNTED

SQL> col member for a60

SQL> select group#,member from v$logfile;

GROUP# MEMBER

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

3 /u01/app/oracle/oradata/ora10g/redo03.log

2 /u01/app/oracle/oradata/ora10g/redo02.log

1 /u01/app/oracle/oradata/ora10g/redo01.log

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01110: data file 1: ‘/u01/app/oracle/oradata/ora10g/system01.dbf‘

由于只是restore了数据库,还未recover,数据库是无法打开的

SQL> recover database

ORA-00283: recovery session canceled due to errors

ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

SQL> recover database until cancel;

ORA-00283: recovery session canceled due to errors

ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

SQL> recover database using backup controlfile;

ORA-00279: change 502729 generated at 08/26/2014 15:36:54 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_08_26/o1_mf_1_3_%u_.arc

ORA-00280: change 502729 for thread 1 is in sequence #3

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00308: cannot open archived log

‘/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_08_26/o1_mf_1_3_%u_.arc‘

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

ORA-00308: cannot open archived log

‘/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_08_26/o1_mf_1_3_%u_.arc‘

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

SQL> recover database using backup controlfile until cancel;

ORA-00279: change 502729 generated at 08/26/2014 15:36:54 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_08_26/o1_mf_1_3_%u_.arc

ORA-00280: change 502729 for thread 1 is in sequence #3

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

SQL>

由于之前的归档没有用rman备份,而现在也不存在了,无法recover数据库,就算用resetlogs也无法open数据库。此时,只有通过隐含参数_allow_resetlogs_corruption来open数据库了

SQL> show parameter spfile

NAME                                 TYPE        VALUE

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

spfile                               string      /u01/app/oracle/product/10.2.0

/db_1/dbs/spfileora10g.ora

--创建pfile

SQL> create pfile from spfile;

File created.

--编辑$ORACLE_HOME/dbs/initora10g.ora初始化参数文件,在文件末尾添加*._allow_resetlogs_corruption = true

[[email protected] ora10g]$ vi $ORACLE_HOME/dbs/initora10g.ora

ora10g.__db_cache_size=180355072

ora10g.__java_pool_size=4194304

ora10g.__large_pool_size=4194304

ora10g.__shared_pool_size=92274688

ora10g.__streams_pool_size=0

*.audit_file_dest=‘/u01/app/oracle/admin/ora10g/adump‘

*.background_dump_dest=‘/u01/app/oracle/admin/ora10g/bdump‘

*.compatible=‘10.2.0.1.0‘

*.control_files=‘/u01/app/oracle/oradata/ora10g/control01.ctl‘,‘/u01/app/oracle/oradata/ora10g/control02.ctl‘,‘/u01/app/oracle/oradata/ora10g/control03.ctl‘#Restore Controlfile

*.core_dump_dest=‘/u01/app/oracle/admin/ora10g/cdump‘

*.db_block_size=8192

*.db_domain=‘‘

*.db_file_multiblock_read_count=16

*.db_name=‘ora10g‘

*.db_recovery_file_dest=‘/u01/app/oracle/flash_recovery_area‘

*.db_recovery_file_dest_size=2147483648

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=ora10gXDB)‘

*.job_queue_processes=10

*.log_archive_format=‘%t_%s_%r.dbf‘

*.nls_language=‘SIMPLIFIED CHINESE‘

*.nls_territory=‘CHINA‘

*.open_cursors=300

*.pga_aggregate_target=94371840

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.sga_target=285212672

*.undo_management=‘AUTO‘

*.undo_tablespace=‘UNDOTBS1‘

*.user_dump_dest=‘/u01/app/oracle/admin/ora10g/udump‘

*._allow_resetlogs_corruption=TRUE

--关闭数据库实例,用pfile启动

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup pfile=$ORACLE_HOME/dbs/initora10g.ora

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             100664912 bytes

Database Buffers          180355072 bytes

Redo Buffers                2973696 bytes

Database mounted.

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

--最后用resetlogs打开数据库

SQL> alter database open resetlogs;

Database altered.

SQL>

[[email protected] ora10g]$ ll

total 1051020

-rw-r----- 1 oracle oinstall   7061504 Aug 26 16:03 control01.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 26 16:03 control02.ctl

-rw-r----- 1 oracle oinstall   7061504 Aug 26 16:03 control03.ctl

-rw-r----- 1 oracle oinstall 104865792 Aug 26 16:03 example01.dbf

-rw-r----- 1 oracle oinstall  52429312 Aug 26 16:03 redo01.log

-rw-r----- 1 oracle oinstall  52429312 Aug 26 16:03 redo02.log

-rw-r----- 1 oracle oinstall  52429312 Aug 26 16:03 redo03.log

-rw-r----- 1 oracle oinstall 251666432 Aug 26 16:03 sysaux01.dbf

-rw-r----- 1 oracle oinstall 503324672 Aug 26 16:03 system01.dbf

-rw-r----- 1 oracle oinstall  20979712 Aug 26 16:03 temp01.dbf

-rw-r----- 1 oracle oinstall  31465472 Aug 26 16:03 undotbs01.dbf

-rw-r----- 1 oracle oinstall   5251072 Aug 26 16:03 users01.dbf

[[email protected] ora10g]$

再次查看数据文件,发现重新生成了3个online redo logfile了

--resetlogs把SEQUENCE#序列号重新变成1

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

GROUP#  SEQUENCE#

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

1          0

2          1

3          0

--测试表只留下了原来的数据库,因为没有commit,新插入的第3条记录丢失,就算commit,也是会丢数据的,因为redo logfile也被删除了

SQL> select * from aaron8219.test1;

INT

----------

1

2

注意,最后要把刚才设置的隐含参数_allow_resetlogs_corruption = true去掉,否则数据库将来会有引起不一致的风险,设置该隐含参数只是下下策,为了能让数据库open而不得已为之,丢失数据库是肯定的了,因为这是在极端情况下得测试,通常只有在丢失了状态为current的online redo logfile才会丢失数据,如果只是inactive的redo logfile,就算使用alter database open resetlogs;也不意味着100%丢数据。

时间: 2024-10-09 22:30:40

current online redo logfile 丢失的处理方法的相关文章

Current online Redo 和 Undo 损坏的处理方法

转自:http://blog.csdn.net/tianlesoftware/article/details/6261475 Oracle 不同故障的恢复方案 http://blog.csdn.net/tianlesoftware/archive/2010/12/30/6106178.aspx Oracle undo 表空间管理 http://blog.csdn.net/tianlesoftware/archive/2010/07/11/5689558.aspx 上面的2篇Blog 讲到了Ora

用Jquery动态append方式加入标签时Css样式丢失的解决方法

一般在Jquery中会用下面的方式来添加新标签: var obj = "<fieldset data-role='controlgroup' data-type='vertical' data-role='fieldcontain'> <input id='menu0" type='checkbox'/><label for='menu0'> 复选框 </label> </fieldset>";  //按个人要求拼接

电脑故障pci.sys丢失的解决方法

今天在单位碰到了这个问题:开机后在要进入XP系统的时候提示c:windowssystem32driverspci.sys 丢失从提示中看,似乎是pci.sys文件丢失造成的.第一个想到的办法是用XP的故障恢复控制台重新从XP安装光盘 copy pci.sys文件到硬盘里.于是将安装光盘放入光驱,设置好光驱启动,进入XP的安装界面,却提示如下错误:SETUPDD.exe无法载入,error 14,安装无法继续(只能记得大概的提示)前几天 这张系统盘还用的好好的,应该不是盘的问题,难道说硬盘出了问题

ORACLE 非归档模式下REDO日志丢失修复

第一步:全备datafile,controlfile,spfile/pfile 第二步:恢复日志.(原冷备的日志没有用,千万不要用!) SQL> select member from v$logfile;                         /ora/app/oracle/oradata/orcl/redo03.log /ora/app/oracle/oradata/orcl/redo02.log /ora/app/oracle/oradata/orcl/redo01.log SQL

oracle - redo 损坏或删除处理方法

OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 数据库打开模式,非归档模式,非当前日志损坏 SQL> archive log list;Database log mode No Archive ModeAutomatic archival DisabledArchive destination USE_DB_RE

asp.net session丢失的解决方法小结

现在我就把原因和解决办法写出来. ASP.NET Session丢失原因: 由于Asp.net程序是默认配置,所以Web.Config文件中关于Session的设定如下: < sessionState mode='InProc' stateConnectionString='tcpip=127.0.0.1:42424' sqlConnectionString='data source=127.0.0.1;Trusted_Connection=yes' cookieless='true' time

Oracle number类型查询精度丢失的解决方法

Oracle number类型查询时,有时候会遇到精度丢失的问题,下面为您介绍了一个解决Oracle number类型查询精度丢失的方法,供您参考. 一.Oracle number类型查询需求中要求查到一个字段的值然后保持小数点后2位//如果采用如下方法从ResultSet得到一个数字,而这个数字大于40000,则得到的数据将不准确 floatzcxxhj+=rss.getFloat(3); //而如果采用double就没有问题 doublezcxxhj+=rss.getDouble(3); /

Android Studio 新建项目的R文件丢失的解决方法

最近Android Studio炒的比较热,于是笔者决定赶赶时髦,从Eclipse转到了Android Studio.不幸的是,用Android Studio创建项目的时候就遇到了一个比较尖锐的问题——R文件丢失,如下图. error提示为“Error:Execution failed for task ‘:app:compileDebugAidl‘.> aidl is missing” . 经过多方查阅及研究,有了一个简单明了的解决方法. 其实问题的焦点就在Build Tool 23.0.0

ConnectionString连接字符串-密码丢失的解决方法

今天遇到一个问题,EF,asp.net  web端登录成功,退出,再登录就异常了, 登出成功时, EF 中 dbcontext.Database.Connection.ConnectionString=data source=.;initial catalog=ZhpGame;user id=sa;password=456;MultipleActiveResultSets=True;App=EntityFramework 再次登录时,遇到鬼了dbcontext.Database.Connecti