回顾一下:在线重做日志的状态
1.unused -- 未使用状态
2.current -- 当前状态 3.active -- 活动状态 4.inactive -- 非活动状态1.unused & inactive 状态的日志丢失 如果是inactive状态,那么说明: 该日志记录的数据库的变化,都已经同步到数据文件; 实例恢复也不需要这个日志文件存在。 那么,这样的日志文件损坏,于数据无影响; 将日志文件本身修复即可;> startup mount;ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instanceORACLE instance started.Total System Global Area 422670336 bytes
Fixed Size 1345380 bytesVariable Size 322963612 bytesDatabase Buffers 92274688 bytesRedo Buffers 6086656 bytesDatabase mounted.> select group#,status from v$log;GROUP# STATUS
---------- ---------------- 1 INACTIVE 3 UNUSED 2 CURRENT --破坏inactive & unused状态的日志文件 [oracle@db253 trace]$ cd /u01/app/oracle/oradata/orcl11g [oracle@db253 orcl11g]$ cp /etc/passwd redo01.log [oracle@db253 orcl11g]$ cp /etc/passwd redo03.log > alter database open;alter database open*ERROR at line 1:ORA-03113: end-of-file on communication channelProcess ID: 10685Session ID: 125 Serial number: 5 > conn / as sysdbaConnected to an idle instance.> startup mount;ORACLE instance started.Total System Global Area 835104768 bytes
Fixed Size 2232960 bytesVariable Size 520097152 bytesDatabase Buffers 306184192 bytesRedo Buffers 6590464 bytesDatabase mounted.> select group#,status from v$log;
GROUP# STATUS
---------- ---------------- 1 INACTIVE 3 INACTIVE 2 CURRENT--清理日志组即可,oracle会自动创建新的日志文件出来,状态为unused
> alter database clear logfile group 1;> alter database clear logfile group 3; --清理之后的日志状态> select group#,status from v$log;GROUP# STATUS
---------- ---------------- 1 UNUSED 3 UNUSED 2 CURRENT--正常打开数据库
> alter database open;2.active状态的日志文件损坏 --数据更新> update hr.employees set salary=salary+1;> commit; --切换日志,更新操作保留在active状态的日志中> alter system switch logfile;> select group#,status from v$log;GROUP# STATUS
---------- ---------------- 1 CURRENT 2 ACTIVE 3 UNUSED--查看当前的归档状态
> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /u01/app/oracle/archOldest online log sequence 2Next log sequence to archive 3Current log sequence 3 --为了保留active状态,只能shutdown abort> shutdown abort;ORACLE instance shut down.--启动到mount
> startup mount;ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instanceORACLE instance started.Total System Global Area 422670336 bytes
Fixed Size 1345380 bytesVariable Size 322963612 bytesDatabase Buffers 92274688 bytesRedo Buffers 6086656 bytesDatabase mounted.> select group#,status from v$log;GROUP# STATUS
---------- ---------------- 1 CURRENT 3 UNUSED 2 ACTIVE-- 破坏2号日志组日志文件
> host cp /etc/passwd /u01/app/oracle/oradata/orcl11g/redo02.log --打开数据库> alter database open;alter database open*ERROR at line 1:ORA-00313: open failed for members of log group 2 of thread 1ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/orcl11g/redo02.log'ORA-27048: skgfifi: file header information is invalidAdditional information: 14 --因为,存在归档,所以,可以直接恢复数据库> select sequence#,group#,status from v$log;SEQUENCE# GROUP# STATUS
---------- ---------- ---------------- 75 1 CURRENT 73 3 INACTIVE 74 2 ACTIVE > recover database until cancel;ORA-00279: change 1763218 generated at 06/24/2013 12:02:00 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/arch/1_74_816622368.dbfORA-00280: change 1763218 for thread 1 is in sequence #74 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/u01/app/oracle/arch/1_74_816622368.dbfORA-00279: change 1769094 generated at 06/24/2013 13:34:43 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/arch/1_75_816622368.dbfORA-00280: change 1769094 for thread 1 is in sequence #75ORA-00278: log file '/u01/app/oracle/arch/1_74_816622368.dbf' no longer neededfor this recovery Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/u01/app/oracle/oradata/orcl11g/redo01.logLog applied.Media recovery complete.> alter database open resetlogs;
Database altered.
> select group#,status from v$log;
GROUP# STATUS
---------- ---------------- 1 CURRENT 2 UNUSED 3 UNUSED--查看一下数据情况
--数据不会有丢失的情况,因为所有的日志都被recover了;3.current状态的日志损坏
> update hr.employees set salary=salary+1;
> commit;> alter system switch logfile;> select salary from hr.employees where employee_id=100;SALARY
---------- 31948> update hr.employees set salary=salary+1;
> commit;> select salary from hr.employees where employee_id=100;SALARY
---------- 31949--日志状态
> select group#,sequence#,status from v$log;GROUP# SEQUENCE# STATUS
---------- ---------- ---------------- 1 1 INACTIVE 2 2 ACTIVE 3 3 CURRENT--模拟实例崩溃,current状态的日志文件损坏
> shutdown abort;ORACLE instance shut down.> startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instanceORACLE instance started.Total System Global Area 422670336 bytes
Fixed Size 1345380 bytesVariable Size 322963612 bytesDatabase Buffers 92274688 bytesRedo Buffers 6086656 bytesDatabase mounted.> select group#,status from v$log;GROUP# STATUS
---------- ---------------- 1 INACTIVE 3 CURRENT 2 ACTIVE> host cp /etc/passwd /u01/app/oracle/oradata/orcl11g/redo03.log
--open database打开数据库
> alter database open;alter database open*ERROR at line 1:ORA-00313: open failed for members of log group 3 of thread 1ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl11g/redo03.log'ORA-27048: skgfifi: file header information is invalidAdditional information: 14--查看隐藏参数
> show parameter "_allow_resetlogs_corruption";NAME TYPE VALUE
------------------------------------ ----------- ------------------------------_allow_resetlogs_corruption boolean TRUE--如果这个参数为false,修改为true
--alter system set "_allow_resetlogs_corruption"=true scope=spfile; --shutdown abort; --startup mount; --修复数据库> recover database until cancel;ORA-00279: change 1789650 generated at 06/24/2013 13:40:21 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/arch/1_2_818948248.dbfORA-00280: change 1789650 for thread 1 is in sequence #2 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/u01/app/oracle/arch/1_2_818948248.dbfORA-00279: change 1789904 generated at 06/24/2013 13:41:02 needed for thread 1ORA-00289: suggestion : /u01/app/oracle/arch/1_3_818948248.dbfORA-00280: change 1789904 for thread 1 is in sequence #3ORA-00278: log file '/u01/app/oracle/arch/1_2_818948248.dbf' no longer neededfor this recovery Specify log: {<RET>=suggested | filename | AUTO | CANCEL}cancelORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error belowORA-01194: file 1 needs more recovery to be consistentORA-01110: data file 1: '/u01/app/oracle/oradata/orcl11g/system01.dbf' ORA-01112: media recovery not started > alter database open resetlogs;Database altered.
--查看数据情况
> select salary from hr.employees where employee_id=100;SALARY
---------- 31948