关于 Current redo log丢失恢复情况的实验!

关于 CURRENT REDO LOG 丢失恢复的实验:

以下分几种情况测试:

情况一: Archive模式 + 没有 commit + 正常关闭


[oracle@RAC1 ~]$ export ORACLE_SID=hongye2
[oracle@RAC1 ~]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 4 17:39:05 2010

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

IDEL > conn /as sysdba
Connected.

SYS:145@HONGYE2 > archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     8
Next log sequence to archive   10
Current log sequence           10

SYS:145@HONGYE2 > @get_allfile

FILE_NAME                                                                 SIZE_MB
---------------------------------------------------------------------- ----------
/oracle/oradata/hongye2/system01.dbf                                          300
/oracle/oradata/hongye2/undotbs01.dbf                                         200
/oracle/oradata/hongye2/sysaux01.dbf                                          120
/oracle/oradata/hongye2/users01.dbf                                             5
/oracle/oradata/hongye2/temp01.dbf                                             20
/oracle/oradata/hongye2/redo01.log                                             50
/oracle/oradata/hongye2/redo02.log                                             50
/oracle/oradata/hongye2/redo03.log                                             50
/oracle/oradata/hongye2/control01.ctl                                           0
/oracle/oradata/hongye2/control02.ctl                                           0
/oracle/oradata/hongye2/control03.ctl                                           0

11 rows selected.

SYS:145@HONGYE2 > create pfile='/home/oracle/hongye2/pfile.ora' from spfile;

File created.

SYS:145@HONGYE2 > shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS:145@HONGYE2 > exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

[oracle@RAC1 ~]$ cd hongye2/
[oracle@RAC1 hongye2]$ ls -l
total 4
drwxr-x---  2 oracle oinstall 4096 Dec  4 17:19 scripts
[oracle@RAC1 hongye2]$ cp /oracle/oradata/hongye2/* .
[oracle@RAC1 hongye2]$ ls -l
total 827420
-rw-r-----  1 oracle oinstall   7061504 Dec  4 17:56 control01.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 17:56 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 17:56 control03.ctl
-rw-r--r--  1 oracle oinstall       964 Dec  4 18:01 pfile.ora
-rw-r-----  1 oracle oinstall  52429312 Dec  4 17:56 redo01.log
-rw-r-----  1 oracle oinstall  52429312 Dec  4 17:56 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Dec  4 17:56 redo03.log
drwxr-x---  2 oracle oinstall      4096 Dec  4 17:19 scripts
-rw-r-----  1 oracle oinstall 125837312 Dec  4 17:58 sysaux01.dbf
-rw-r-----  1 oracle oinstall 314580992 Dec  4 17:58 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Dec  4 17:58 temp01.dbf
-rw-r-----  1 oracle oinstall 209723392 Dec  4 17:58 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Dec  4 17:58 users01.dbf
[oracle@RAC1 hongye2]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 4 18:02:34 2010

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

IDEL > conn hongye/hongye
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory

IDEL > conn /as sysdba
Connected to an idle instance.
IDEL > startup
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              62916852 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
IDEL > @get_hide_param
Enter value for par: resetlog
old   5: x.indx=y.indx and x.ksppinm like '%&par%'
new   5: x.indx=y.indx and x.ksppinm like '%resetlog%'

NAME                 VALUE                          ISDEFAULT DESCRIBE
-------------------- ------------------------------ --------- ----------------------------------------------------------------------
_allow_resetlogs_corruption  FALSE                          TRUE      allow resetlogs even if it will cause corruption
_no_recovery_through_resetlogs  FALSE                          TRUE      no recovery through this resetlogs operation

IDEL > conn /as sysdba
Connected.
SYS:159@HONGYE2 > @get_allfile

FILE_NAME                                                                 SIZE_MB
---------------------------------------------------------------------- ----------
/oracle/oradata/hongye2/system01.dbf                                          300
/oracle/oradata/hongye2/undotbs01.dbf                                         200
/oracle/oradata/hongye2/sysaux01.dbf                                          120
/oracle/oradata/hongye2/users01.dbf                                             5
/oracle/oradata/hongye2/temp01.dbf                                             20
/oracle/oradata/hongye2/redo01.log                                             50
/oracle/oradata/hongye2/redo02.log                                             50
/oracle/oradata/hongye2/redo03.log                                             50
/oracle/oradata/hongye2/control01.ctl                                           0
/oracle/oradata/hongye2/control02.ctl                                           0
/oracle/oradata/hongye2/control03.ctl                                           0

11 rows selected.

SYS:159@HONGYE2 > create table test1(id number,name varchar2(100));

Table created.

SYS:159@HONGYE2 > insert into test1 values(1,'before switch log!');

1 row created.

SYS:159@HONGYE2 > alter system switch logfile;

System altered.

SYS:159@HONGYE2 > insert into test1 values(2,'after switch log!');

1 row created.

SYS:159@HONGYE2 > alter system checkpoint;

SYS:159@HONGYE2 > select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1         10   52428800          1 NO  CURRENT                 151962 04-DEC-10
         2          1          8   52428800          1 YES INACTIVE                131755 04-DEC-10
         3          1          9   52428800          1 YES INACTIVE                146947 04-DEC-10

SYS:159@HONGYE2 > col member for a60
SYS:159@HONGYE2 > select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                                       IS_
---------- ------- ------- ------------------------------------------------------------ ---
         1         ONLINE  /oracle/oradata/hongye2/redo01.log                           NO
         2         ONLINE  /oracle/oradata/hongye2/redo02.log                           NO
         3         ONLINE  /oracle/oradata/hongye2/redo03.log                           NO

SYS:159@HONGYE2 > shutdown abort
ORACLE instance shut down.
SYS:159@HONGYE2 > exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@RAC1 hongye2]$ cd /oracle/oradata/hongye2/
[oracle@RAC1 hongye2]$ ls -l
total 827416
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control01.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control03.ctl
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:13 redo01.log
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:03 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:12 redo03.log
-rw-r-----  1 oracle oinstall 125837312 Dec  4 18:13 sysaux01.dbf
-rw-r-----  1 oracle oinstall 314580992 Dec  4 18:13 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Dec  4 17:32 temp01.dbf
-rw-r-----  1 oracle oinstall 209723392 Dec  4 18:13 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Dec  4 18:13 users01.dbf
[oracle@RAC1 hongye2]$ mv redo01.log redo01.bak
[oracle@RAC1 hongye2]$ ls -l
total 827416
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control01.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Dec  4 18:14 control03.ctl
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:13 redo01.bak
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:03 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Dec  4 18:12 redo03.log
-rw-r-----  1 oracle oinstall 125837312 Dec  4 18:13 sysaux01.dbf
-rw-r-----  1 oracle oinstall 314580992 Dec  4 18:13 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Dec  4 17:32 temp01.dbf
-rw-r-----  1 oracle oinstall 209723392 Dec  4 18:13 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Dec  4 18:13 users01.dbf
[oracle@RAC1 hongye2]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Dec 4 18:16:38 2010

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

IDEL > conn /as sysdba
Connected to an idle instance.
IDEL > startup
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              62916852 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/oracle/oradata/hongye2/redo01.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

IDEL > 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 hongye2 (thread 1) - cannot drop
ORA-00312: online log 1 thread 1: '/oracle/oradata/hongye2/redo01.log'

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

IDEL > alter database recover database until cancel;
alter database recover database until cancel
*
ERROR at line 1:
ORA-00275: media recovery has already been started

IDEL > recover database;
ORA-00275: media recovery has already been started


IDEL > alter system set allow_resetlogs_corruption=true;
alter system set allow_resetlogs_corruption=true
                 *
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM

IDEL > alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

IDEL > shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
IDEL > startup
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              62916852 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

IDEL > aler database open resetlogs;
SP2-0734: unknown command beginning "aler datab..." - rest of line ignored.
IDEL > alter database open resetlogs;

Database altered.

IDEL > select open_mode from v$database;

OPEN_MODE
----------
READ WRITE

IDEL > select * from test1;

no rows selected

IDEL > select * from v$log
  2  ;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1          1   52428800          1 NO  CURRENT                 151982 04-DEC-10
         2          1          0   52428800          1 YES UNUSED                       0
         3          1          0   52428800          1 YES UNUSED                       0

haveattach.gifget_allfile.sql
(2010-12-07 15:14:32, Size: 554 B , Downloads: 0)


haveattach.gifget_hide_parameter.sql
(2010-12-07 15:14:32, Size: 462 B , Downloads: 0)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24465008/viewspace-681092/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24465008/viewspace-681092/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
redolog是MySQL数据库中的一种日志文件,用于记录对数据库的修改操作。当数据库发生故障或崩溃时,可以利用redolog恢复数据,保证数据的一致性和完整性。 redolog恢复数据的过程主要分为以下几个步骤: 1. 检查数据库状态:首先要检查数据库的状态,确定数据库是否处于正常可用的状态。如果数据库无法正常启动,需要采取相应的修复措施,例如修复损坏的文件或恢复备份等。 2. 恢复redo日志:在数据库启动后,系统会自动检查redolog文件,将未完成的事务进行回滚或者重做。系统会根据redo日志中的记录,将已提交的事务重新应用到数据库中,以恢复数据库的一致性。 3. 事务回滚:对于未提交的事务,系统会根据redo日志中的记录,将其进行回滚操作。通过回滚操作,可以将未提交的事务中对数据库所做的修改操作撤销,以保证数据的完整性。 4. 数据库恢复完成:当redo日志中的所有记录都被应用到数据库中,并且未提交的事务都被回滚完成后,数据库恢复过程就完成了。此时数据库可以正常使用,并且数据的一致性和完整性得到了保证。 需要注意的是,redolog恢复过程是自动进行的,数据库会自动检查和应用redolog文件中的记录。在正常情况下,用户不需要手动介入redolog恢复过程。但在某些特殊情况下,如数据库崩溃后无法自动恢复,可能需要进行手动的redolog恢复操作。这种情况下,一般需要借助MySQL提供的相关工具和命令来进行操作。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值