实验报告:损坏当前重做日志的恢复

[复制链接]
查看11 | 回复2 | 2005-10-30 17:05:33 | 显示全部楼层 |阅读模式
数据库处于非归档模式,
1.关闭数据库后备份所有数据文件
2.打开数据库
3.用一个窗口对数据库进行操作:
sqlplus scott/tiger
create table test(name char(20));
begin
for i in 1..1000000
loop
insert into test values('ksikaisdfkasdfdj');
commit;
end loop;
end;
/
4.在以上操作的同时将数据库关闭,使数据文件处于非一至状态
5.删除所有的redo文件.
6.开始恢复操作:
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.0.1.0.0 - Production on Mon Aug 9 13:19:59 2004
(c) Copyright 2001 Oracle Corporation.All rights reserved.
Connected to an idle instance.
SQL> startup restrict mount
ORACLE instance started.
Total System Global Area135038364 bytes
Fixed Size
279964 bytes
Variable Size
83886080 bytes
Database Buffers 50331648 bytes
Redo Buffers
540672 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1:
'/export/home/oracle/oradata/testgdn/redo03.log'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3

SQL> recover database until cancel;
ORA-00279: change 1900920 generated at 08/09/2004 12:58:25 needed for thread 1
ORA-00289: suggestion : /export/home/oracle/901/dbs/arch1_28.dbf
ORA-00280: change 1900920 for thread 1 is in sequence #28

Specify log: {=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: '/app2/oracle/oradata/testgdn/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: '/app2/oracle/oradata/testgdn/system01.dbf'
7,恢复失败,在PFILE中加入参数:_allow_resetlogs_corruption=true
8.再次恢复,结果同上,好象上面加入的参数没起作用,想起来9I中可能使用SPFILE,在启动数据库时指定PFILE:
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount pfile=/export/home/oracle/admin/testgdn/pfile/inittest9.ora
ORACLE instance started.
Total System Global Area135038364 bytes
Fixed Size
279964 bytes
Variable Size
83886080 bytes
Database Buffers 50331648 bytes
Redo Buffers
540672 bytes
Database mounted.
SQL> recover database until cancel
ORA-00279: change 1900920 generated at 08/09/2004 12:58:25 needed for thread 1
ORA-00289: suggestion : /export/home/oracle/901/dbs/arch1_28.dbf
ORA-00280: change 1900920 for thread 1 is in sequence #28

Specify log: {=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: '/app2/oracle/oradata/testgdn/system01.dbf'

ORA-01112: media recovery not started

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced

SQL> shutdown abort
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
SQL> exit
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.0.1.0.0 - Production on Mon Aug 9 13:30:33 2004
(c) Copyright 2001 Oracle Corporation.All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area135038364 bytes
Fixed Size
279964 bytes
Variable Size
83886080 bytes
Database Buffers 50331648 bytes
Redo Buffers
540672 bytes
Database mounted.
Database opened.
恢复成功,数据库打开了!!!
9.别高兴得太早,看看刚操作的表:
SQL> select count(*) from scott.test;
select count(*) from scott.test

*
ERROR at line 1:
ORA-08103: object no longer exists
真的没有吗?
SQL> connect scott/tiger
Connected.
SQL> select * from tab;
TNAME
TABTYPECLUSTERID
------------------------------ ------- ----------
BONUS
TABLE
DEPT
TABLE
EMP
TABLE
SALGRADE
TABLE
TEST
TABLE
表是有的
SQL> select count(*) from test;
select count(*) from test

*
ERROR at line 1:
ORA-08103: object no longer exists
但不能使用
SQL> drop table test;
drop table test
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [4193], [239], [249], [], [], [],
[], []
居然不能DROP!!!
SQL> connect sys/oracle as sysdba;
Connected.
SQL> desc dba_objects;
Name
Null?Type
----------------------------------------- -------- ----------------------------
OWNER
VARCHAR2(30)
OBJECT_NAME
VARCHAR2(128)
SUBOBJECT_NAME
VARCHAR2(30)
OBJECT_ID
NUMBER
DATA_OBJECT_ID
NUMBER
OBJECT_TYPE
VARCHAR2(18)
CREATED
DATE
LAST_DDL_TIME
DATE
TIMESTAMP
VARCHAR2(19)
STATUS
VARCHAR2(7)
TEMPORARY
VARCHAR2(1)
GENERATED
VARCHAR2(1)
SECONDARY
VARCHAR2(1)

SQL> select owner,object_name ,status from dba_objects where object_name='TEST'
SQL> /
OWNER
------------------------------
OBJECT_NAME
--------------------------------------------------------------------------------
STATUS
-------
SCOTT
TEST
VALID

SQL> drop table scott.test;
Table dropped.
用SYS帐户删除了这个表
总结:做好备份和维护,否则即使数据库恢复,也可能存在对象不对访问的严重问题
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
以前piner有篇文章关于备份和恢复的写的很详细,建议参考!
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
用隐含参数_allow_resetlogs_corruption=true来恢复数据库的方法
不到万不得已一般情况下建议不要采用,因为该方法可能导致数据库的不一致。
这种方法通常会丢失当前联机日志中的事务数据和未写入数据文件的已提交或未提交数据。恢复成功之后,记得再做一次数据库的全备份。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行