今天做了一个关于破坏online日志的恢复测试,主要三个场景:
测试1:正常关闭数据库后删除非当前日志
测试2:正常关库后,删除在线日志文件
测试3:非正常关闭数据库,并删除当前在线日志文件
我的测试环境是Oracle 10.2.0.1 32bit的数据库,OS版本为Red Hat 5.3,下面看具体测试经过:
测试1:正常关闭数据库后删除非当前日志
[oracle@ora10g ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 6月 24 10:34:53 2015
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
SYS@ora10g> select group#,thread#,status,archived from v$log;
GROUP# THREAD# STATUS ARC
---------- ---------- ---------------- ---
1 1 CURRENT NO
2 1 INACTIVE YES
3 1 ACTIVE YES
SYS@ora10g> set line 130 pages 130
SYS@ora10g> col member for a50
SYS@ora10g> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/ora10g/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/ora10g/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/ora10g/redo01.log NO
SYS@ora10g> conn zlm/zlm
Connected.
ZLM@ora10g> create table t1 as select * from dba_objects where 1=2;
Table created.
ZLM@ora10g> insert into t1 select * from dba_objects where rownum<11;
10 rows created.
ZLM@ora10g> select count(*) from t1;
COUNT(*)
----------
10
ZLM@ora10g> commit; (此处不commit也可,因为对在线日志归档的时候会进行commit操作)
Commit complete.
ZLM@ora10g> alter system archive log current;
System altered.
ZLM@ora10g> select group#,thread#,status,archived from v$log;
GROUP# THREAD# STATUS ARC
---------- ---------- ---------------- ---
1 1 ACTIVE YES
2 1 CURRENT NO
3 1 INACTIVE YES
--删除非当前的在线日志文件(ACTIVE的和INACTIVE的)
[oracle@ora10g backupsets]$ cd /u01/app/oracle/oradata/ora10g/
[oracle@ora10g ora10g]$ pwd
/u01/app/oracle/oradata/ora10g
[oracle@ora10g ora10g]$ ls -l
total 1461348
-rw-r----- 1 oracle oinstall 7520256 Jun 24 10:40 control01.ctl
-rw-r----- 1 oracle oinstall 7520256 Jun 24 10:40 control02.ctl
-rw-r----- 1 oracle oinstall 7520256 Jun 24 10:40 control03.ctl
-rw-r----- 1 oracle oinstall 104865792 Jun 24 10:38 example01.dbf
-rw-r----- 1 oracle oinstall 172032 Nov 29 2014 indx01.dbf
-rw-r----- 1 oracle oinstall 52429312 Jun 24 10:39 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jun 24 10:39 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jun 24 10:34 redo03.log
-rw-r----- 1 oracle oinstall 283123712 Jun 24 10:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall 587210752 Jun 24 10:38 system01.dbf
-rw-r----- 1 oracle oinstall 52436992 Jun 23 16:17 temp01.dbf
-rw-r----- 1 oracle oinstall 173023232 Jun 24 10:38 undotbs01.dbf
-rw-r----- 1 oracle oinstall 41951232 Jun 24 10:38 users01.dbf
-rw-r----- 1 oracle oinstall 100671488 Jun 24 10:38 zlm01.dbf
[oracle@ora10g ora10g]$ rm -f redo01.log
[oracle@ora10g ora10g]$ rm -f redo03.log
[oracle@ora10g ora10g]$ ls -l redo*
-rw-r----- 1 oracle oinstall 52429312 Jun 24 10:44 redo02.log
[oracle@ora10g ora10g]$
测试1:正常关闭数据库后删除非当前日志
--正常关闭数据库并重启
ZLM@ora10g> shutdown immediate
ORA-01031: insufficient privileges
ZLM@ora10g> conn / as sysdba
Connected.
SYS@ora10g> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ora10g> startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220384 bytes
Variable Size 318767328 bytes
Database Buffers 201326592 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: '/u01/app/oracle/oradata/ora10g/redo01.log'