oracle测试主要做什么的,Oracle恢复测试

用隐含参数_allow_resetlogs_corruption和重建undo tablespace 问题:

某个现场做数据库恢复的时侯有一个问题:DB恢复需要这个归档日志文件1_33160.dbf,但是在备份中没有。

SQL> recover database using backup controlfile until cancel;

ORA-00279: change 4207433305 generated at 04/23/2008 02:00:33 needed for thread 1

ORA-00289: suggestion :

/opt/oracle/db02/app/oracle/oradata/ORCL/archive/1_33160.dbf

ORA-00280: change 4207433305 for thread 1 is in sequence #33160

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log

'/opt/oracle/db02/app/oracle/oradata/ORCL/archive/1_33160.dbf'

ORA-27037: unable to obtain file status

SVR4 Error: 2: No such file or directory

Additional information: 3

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01195: online backup of file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/opt/oracle/db02/app/oracle/oradata/ORCL/system01.dbf'

解决过程:

SunOS 5.8

login: oracle

Password:

Last login: Sun May 4 10:39:57 from 172.19.136.49

Sun Microsystems Inc. SunOS 5.8 Generic Patch February 2004

$ ls

db01 db02 db03 db04 lost+found

$ sqlplus '/as sysdba'

SQL*Plus: Release 9.2.0.4.0 - Production on Sun May 4 11:49:10 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination /opt/oracle/db02/app/oracle/oradata/ORCL/archive

Oldest online log sequence 33159

Next log sequence to archive 33161

Current log sequence 33161

SQL> alter database open;

alter database open

*

ERROR at line 1:

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-01195: online backup of file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/opt/oracle/db02/app/oracle/oradata/ORCL/system01.dbf'

resetlogs的字面意思是重置重做日志。在创建控制文件的时候如果不需要在线重做日志的话可以用resetlogs选项,第二种情况是在做不完全恢复后,数据文件和重做日志的内容不同步了,这个时候打开数据库一定要用resetlogs选项。resetlogs 的时候数据库其实做了很多事,最主要的还是清空重做日志的内容,选定一个重做日志作为当前日志并将日志序列号重置为1,把resetlogs count和resetlogs scn写入控制文件、数据文件头部和重做日志的头部,当然还会做很多其它的事情。

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

尝试一下基于时间点的不完全恢复:

SQL> recover database using backup controlfile until time '2008-04-30 01:00:00';

ORA-00279: change 4207433305 generated at 04/23/2008 02:00:33 needed for thread 1

ORA-00289: suggestion :

/opt/oracle/db02/app/oracle/oradata/ORCL/archive/1_33160.dbf

ORA-00280: change 4207433305 for thread 1 is in sequence #33160

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log

'/opt/oracle/db02/app/oracle/oradata/ORCL/archive/1_33160.dbf'

ORA-27037: unable to obtain file status

SVR4 Error: 2: No such file or directory

Additional information: 3

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01195: online backup of file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/opt/oracle/db02/app/oracle/oradata/ORCL/system01.dbf'

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01195: online backup of file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/opt/oracle/db02/app/oracle/oradata/ORCL/system01.dbf'

准备使用隐含参数_allow_resetlogs_corruption强制启动DB:

SQL> show parameter spfile;

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

spfile string

SQL> create spfile from pfile;

File created.

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> show parameter spfile;

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

spfile string ?/dbs/spfile@.ora

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

System altered.

提示:Oracle的隐含参数只应该在测试环境或者在Oracle Support的支持下使用。

设置此参数之后,在数据库Open过程中,Oracle会跳过某些一致性检查,从而使数据库可能跳过不一致状态。

SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-03113: end-of-file on communication channel

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-03114: not connected to ORACLE

SQL> conn /as sysdba

Connected to an idle instance.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01034: ORACLE not available

SQL> shutdown immediate

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

SVR4 Error: 2: No such file or directory

SQL> startup

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

ORA-00607: Internal error occurred while making a change to a data block

ORA-00600: internal error code, arguments: [4194], [53], [43], [], [], [], [],[]

以上强制启动后,产生Ora-600错误了,在预料之中。。。。

SQL> startup force;

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

SQL> startup mount

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

SQL> set pages 0 feedback off lines 132

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

SQL>

SQL> !oerr ora 1092

01092, 00000, "ORACLE instance terminated. Disconnection forced"

// *Cause: The instance this process was connected to was terminated

// abnormally, probably via a shutdown abort. This process

// was forced to disconnect from the instance.

// *Action: Examine the alert log for more details. When the instance has been

// restarted, retry action.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-03114: not connected to ORACLE

SQL> startup force;

ORA-24324: service handle not initialized

ORA-01041: internal error. hostdef extension doesn't exist

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup force;

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

由于和undo表空间不同步,那好重建undo tablespace:

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

SQL> show parameter undo

undo_management string AUTO

undo_retention integer 3600

undo_suppress_errors boolean FALSE

undo_tablespace string UNDOTBS1

SQL> alter system set undo_management=manual scope=spfile;

SQL> alter database open;

先改成不使用undo,可以启动DB,但没法新建对象:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

Database opened.

SQL>

SQL> conn wacos/oss

Connected.

SQL> select count(*) from tab;

2034

SQL> create table t_test (c1 date);

create table t_test (c1 date)

*

ERROR at line 1:

ORA-01552: cannot use system rollback segment for non-system tablespace 'WACOS'

SQL> !oerr ora 1552

01552, 00000, "cannot use system rollback segment for non-system tablespace '%s'"

// *Cause: Tried to use the system rollback segment for operations involving

// non-system tablespace. If this is a clone database then this will

// happen when attempting any data modification outside of the system

// tablespace. Only the system rollback segment can be online in a

// clone database.

// *Action: Create one or more private/public segment(s), shutdown and then

// startup again. May need to modify the INIT.ORA parameter

// rollback_segments to acquire private rollback segment. If this is

// a clone database being used for tablspace point in time recovery

// then this operation is not allowed.

那就新建一个undo表空间,并弃用原先的:

SQL> create undo tablespace UNDOTBS1 datafile '/opt/oracle/db02/app/oracle/oradata/ORCL/undotbs01.dbf' size 3000m;

create undo tablespace UNDOTBS1 datafile '/opt/oracle/db02/app/oracle/oradata/ORCL/undotbs01.dbf' size 3000m

*

ERROR at line 1:

ORA-01543: tablespace 'UNDOTBS1' already exists

SQL> create undo tablespace UNDOTBS2 datafile '/opt/oracle/db02/app/oracle/oradata/ORCL/undotbs02.dbf' size 3000m;

SQL> show parameter undo

undo_management string MANUAL

undo_retention integer 3600

undo_suppress_errors boolean FALSE

undo_tablespace string UNDOTBS1

SQL> alter system set undo_management=auto scope=spfile;

SQL> alter system set undo_tablespace=UNDOTBS2 scope=spfile;

SQL> shutdown immediate

ORA-01031: insufficient privileges

SQL> show user

USER is "WACOS"

SQL> conn /as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

Database opened.

SQL> conn wacos/oss

Connected.

SQL> create table t_test (c1 date);

SQL>

SQL> drop tablespace undotbs1;

SQL> create table t_test2 (c1 date);

SQL> select * from t_test;

SQL> insert into t_test values (sysdate);

SQL> commit;

SQL> select * from t_test;

04-MAY-08

现在没问题了,把隐含参数改回默认的:

SQL> alter system set "_allow_resetlogs_corruption"=false scope=spfile;

SQL> shutdown immediate

ORA-01031: insufficient privileges

SQL> conn /as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

ORACLE instance started.

Total System Global Area 826248288 bytes

Fixed Size 732256 bytes

Variable Size 503316480 bytes

Database Buffers 318767104 bytes

Redo Buffers 3432448 bytes

Database mounted.

Database opened.

重启没问题了,问题解决,哈!

SQL> show parameter undo

undo_management string AUTO

undo_retention integer 3600

undo_suppress_errors boolean FALSE

undo_tablespace string UNDOTBS2

SQL> show parameter spfile

spfile string ?/dbs/spfile@.ora

SQL>

通常使用此方法Open数据库之后,应该立即通过导出、导入重建数据库。

重建受损的文件成员

前面提到过复用的联机重做日志中的一个成员丢失或受损的情况下,如何进行恢复。而当当前日志文件组的所有副本都被损坏,那么实例就会立即终止。如果在日志切换时,当前生成的日志文件组的所有副本都被损坏,那么实例也会立即终止。

解决方法:

方法一:

1)删除受损的联机重做日志文件成员并添加一个替换的成员。

命令:

ocp10g> alter database drop logfile member 'C:\ORACLE\ORADATA\REDOA\REDO1A.LOG';

ocp10g> host del C:\ORACLE\ORADATA\REDOA\REDO1A.LOG

ocp10g> alter database add logfile member 'C:\ORACLE\ORADATA\REDOA\REDO1A.LOG' to group 1;

方法二:

1)使用”CLEAR LOGFILE“命令通过替换所有成员与重用旧成员的文件名来创建一个新的联机重做日志文件组。

命令:

ocp10g> alter database clear logfile group 1;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值