删除current redo log的恢复

  近日测试删除current redo log的恢复,却不知引发一系列案中案,特记录如下(CentOS 6.3,Oracle 11.2.0).

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1         22   52428800        512          1 YES INACTIVE               1819273 08-SEP-13      1839279 08-SEP-13
         2          1         23   52428800        512          1 NO  CURRENT                1839279 08-SEP-13   2.8147E+14
         3          1         21   52428800        512          1 YES INACTIVE               1798901 08-SEP-13      1819273 08-SEP-13

SQL>insert into t(txt) values('aa');

SQL>commit;

-- commit后,oracle将脏数据写入到redo.log,些时未有switch logfile,故data未写入datafile和archived logfile.此时删除redo02.log,不shutdown

SQL> host rm /db/oracle/app/oracle/oradata/pvm/redo02.log;

SQL>alter system switch logfile;

-- 此时仍可switch logfile,因为switch logfile触发checkpoint,data会写入到datafile.

-- 此时继续switch logfile,而再switch到redo02.log时,因该log已删除,故

SQL>alter system switch logfile;

--会一直停在运行的状态,ctrl+c退出运行

SQL> SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1         25   52428800        512          1 NO  CURRENT                1851152 09-SEP-13   2.8147E+14
         2          1         23   52428800        512          1 NO  INACTIVE               1839279 08-SEP-13      1851142 09-SEP-13
         3          1         24   52428800        512          1 NO  ACTIVE                 1851142 09-SEP-13      1851152 09-SEP-13

--redo02.log status变为inactive,但ARC=no. 因为寻址不到redo02.log,故无法archived.

-- 重建redo02.log

SQL> alter database clear unarchived logfile group 2;

Database altered.
-- 以上command是会重建redolog,但必须redo log非active及current status才可.

-- 因 redo02已写datafile,故data不会丢失,重启db,验证;

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             327158144 bytes
Database Buffers           88080384 bytes
Redo Buffers                6094848 bytes
Database mounted.
Database opened.
SQL> select * from t;

TXT                                                DTE
-------------------------------------------------- ---------
aa                                      07-SEP-13

SQL>

 --以上为redo log删除后,未shutdown的情况下的恢复,若强行shutdown后,恢复就比较麻烦一些

-- 以下再测试删除redo并shutdown后的恢复

-- 同样上面的操作,insert data/commit/rm redo/switch logfile ,此时 删除的redo log status为active,然后强行shutdown abort;,再重启,报错:

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             331352448 bytes
Database Buffers           83886080 bytes
Redo Buffers                6094848 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/db/oracle/app/oracle/oradata/pvm/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
-- 考虑不完全恢复,并用alter database open resetlogs来重建redo log:

SQL> recover database until cancel;
ORA-00279: change 1851860 generated at 09/09/2013 01:13:56 needed for thread 1
ORA-00289: suggestion : /db/oracle/app/oracle/flash_recovery_area/PVM/archivelog/2013_09_09/o1_mf_1_25_%u_.arc
ORA-00280: change 1851860 for thread 1 is in sequence #25


Specify log: {<RET>=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: '/db/oracle/app/oracle/oradata/pvm/system01.dbf'


ORA-01112: media recovery not started


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: '/db/oracle/app/oracle/oradata/pvm/system01.dbf'
--至此,无法打开database.修改参数文件,加上_allow_resetlogs_corruption=true,试强行打开db.

 

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup pfile='/db/oracle/app/oracle/oradata/pvm/initpvm.ora';
LRM-00109: could not open parameter file '/db/oracle/app/oracle/oradata/pvm/initpvm.ora'
ORA-01078: failure in processing system parameters
SQL> startup pfile='/db/oracle/oracle/product/11.2.0/db_1/dbs/initpvm.ora';
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             306186624 bytes
Database Buffers          109051904 bytes
Redo Buffers                6094848 bytes
Database mounted.
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], [1851868], [0], [1851885], [4194432], [], [], [], [], [], []
Process ID: 13554
Session ID: 1 Serial number: 5

 

--出现internal error,再次呜呼唉灾,再次证明,oracle的隐含参数不要轻易使用.

-- 回到linux查,却发现redo01.log生成了,@_@

--于是,退出sqlplus(一定要退出),再login sqlplus

SQL> shutdown abort;
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             331352448 bytes
Database Buffers           83886080 bytes
Redo Buffers                6094848 bytes
Database mounted.
Database opened.
---此时可正常打开.

-- select data

SQL>select * from t;

no rows selected

 

-- data丢失. 不完全恢复找不到redo01.log,只能恢复到未insert data前的状态.

 

总结:

1.出现问题时,不要轻易shutdown

2.不要随便使用oracle的隐含参数

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值