最近一个客户的库在OPEN时报错需要恢复,发现原因为当时一个表空间正在热备份-->ALTER TABLESPACE TEST1 BEGIN BACKUP; 然后实例异常关闭(可能为ABORT或KILL SMON等进程,这里据说为存储直接关闭导致),然后重启时遇到此错误。
在ORACLE 10.2.0.1及11.2.0.4版本中重现了此错误,在
这两个版本中同样的情况但是报错信息不太一样,具体情况如下:
10.2.0.1.0 版本表空间正在热备份时关闭实例重启报错的重现和解决:
SQL> select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
查看此时数据文件的状态:
SQL> select tablespace_name,STATUS from dba_tablespaces;
set linesize 200
set pagesize 200
col file_name for a50
select file_name,tablespace_name,status from dba_data_files;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS ONLINE
SYSAUX ONLINE
TEMPTS1 ONLINE
TEMP1 ONLINE
TEMP2 ONLINE
EXAMPLE ONLINE
INDX ONLINE
TOOLS ONLINE
USERS ONLINE
OLTP ONLINE
REGISTRATION ONLINE
TEST1 ONLINE
TEST2 ONLINE
TEST3 ONLINE
15 rows selected.
SQL> SQL> SQL> SQL>
FILE_NAME TABLESPACE_NAME STATUS
-------------------------------------------------- ------------------------------ ---------
/u01/app/PROD/disk1/system01.dbf SYSTEM AVAILABLE
/u01/app/PROD/disk1/undotbs01.dbf UNDOTBS AVAILABLE
/u01/app/PROD/disk1/sysaux01.dbf SYSAUX AVAILABLE
/u01/app/PROD/disk1/example.dbf EXAMPLE AVAILABLE
/u01/app/PROD/disk1/indx.dbf INDX AVAILABLE
/u01/app/PROD/disk1/tools.dbf TOOLS AVAILABLE
/u01/app/PROD/disk1/users.dbf USERS AVAILABLE
/u01/app/PROD/disk1/oltp.dbf OLTP AVAILABLE
/u01/app/PROD/disk1/REGISTRATION.dbf REGISTRATION AVAILABLE
/u01/app/PROD/disk1/test1.dbf TEST1 AVAILABLE
/u01/app/PROD/disk1/test2.dbf TEST2 AVAILABLE
/u01/app/PROD/disk1/test3.dbf TEST3 AVAILABLE
12 rows selected.
########################################################3
-->发出热备份表空间的命令:
SQL> ALTER TABLESPACE TEST1 BEGIN BACKUP;
Tablespace altered.
-->查询此时数据文件状态:
SQL> select tablespace_name,STATUS from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS ONLINE
SYSAUX ONLINE
TEMPTS1 ONLINE
TEMP1 ONLINE
TEMP2 ONLINE
EXAMPLE ONLINE
INDX ONLINE
TOOLS ONLINE
USERS ONLINE
OLTP ONLINE
REGISTRATION ONLINE
TEST1 ONLINE
TEST2 ONLINE
TEST3 ONLINE
15 rows selected.
SQL> set linesize 200
SQL> set pagesize 200
SQL> col file_name for a50
SQL> select file_name,file_id,tablespace_name,status from dba_data_files;
FILE_NAME FILE_ID TABLESPACE_NAME STATUS
-------------------------------------------------- ---------- ------------------------------ ---------
/u01/app/PROD/disk1/system01.dbf 1 SYSTEM AVAILABLE
/u01/app/PROD/disk1/undotbs01.dbf 2 UNDOTBS AVAILABLE
/u01/app/PROD/disk1/sysaux01.dbf 3 SYSAUX AVAILABLE
/u01/app/PROD/disk1/example.dbf 4 EXAMPLE AVAILABLE
/u01/app/PROD/disk1/indx.dbf 5 INDX AVAILABLE
/u01/app/PROD/disk1/tools.dbf 6 TOOLS AVAILABLE
/u01/app/PROD/disk1/users.dbf 7 USERS AVAILABLE
/u01/app/PROD/disk1/oltp.dbf 8 OLTP AVAILABLE
/u01/app/PROD/disk1/REGISTRATION.dbf 9 REGISTRATION AVAILABLE
/u01/app/PROD/disk1/test1.dbf 10 TEST1 AVAILABLE
/u01/app/PROD/disk1/test2.dbf 11 TEST2 AVAILABLE
/u01/app/PROD/disk1/test3.dbf 12 TEST3 AVAILABLE
12 rows selected.
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 0
6 NOT ACTIVE 0
7 NOT ACTIVE 0
8 NOT ACTIVE 0
9 NOT ACTIVE 0
10 ACTIVE 195848 2014/11/11 22:12:07
11 NOT ACTIVE 0
12 NOT ACTIVE 0
12 rows selected.
-->可以看到此时有一个数据文件处于ACTIVE状态,结合dba_data_files中信息,此文件属于下在热备份的TEST1表空间。
此时,新开一个会话,KILL掉SMON进程,或者使用SHUTDOWN ABORT命令关闭数据库。shutdown immediate关闭会提示如下:
SQL> shutdown immediate;
ORA-01149: cannot shutdown - file 10 has online backup set
ORA-01110: data file 10: '/u01/app/PROD/disk1/test1.dbf'
--此时ALERT日志提示
Tue Nov 11 22:50:55 2014
Shutting down instance: further logons disabled
###################################################
KILL实例进程,重新启动报错如下:
SQL> startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220360 bytes
Variable Size 159383800 bytes
Database Buffers 360710144 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01113: file 10 needs media recovery
ORA-01110: data file 10: '/u01/app/PROD/disk1/test1.dbf'
ALERT日志中的相关信息:
Tue Nov 11 22:15:44 2014
ALTER DATABASE OPEN
ORA-1113 signalled during: ALTER DATABASE OPEN...
此时查看相关视图,10号数据文件--TEST1表空间的仍处于活动状态--:
SQL> select * from v$backup where STATUS='ACTIVE';
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
10 ACTIVE 195848 2014/11/11 22:12:07 -->这里的时间是开始发出热备份命令BEGIN BACKUP的时间及当时SCN。
此时,可以使用两种命令来解决:
1.ALTER DATABASE RECOVER datafile 10;
2.ALTER TABLESPACE TEST1 END BACKUP;
#####################################################
-->如下是解决及OPEN数据库及验证数据文件状态;
SQL> ALTER DATABASE RECOVER datafile 10;
Database altered.
SQL> select * from v$backup where STATUS='ACTIVE';
no rows selected
SQL> alter database open;
Database altered.
ALERT日志信息:
Tue Nov 11 22:15:44 2014
ALTER DATABASE OPEN
ORA-1113 signalled during: ALTER DATABASE OPEN...
Tue Nov 11 22:17:35 2014
ALTER DATABASE RECOVER datafile 10
Tue Nov 11 22:17:35 2014
Media Recovery Start
Tue Nov 11 22:17:35 2014
Recovery of Online Redo Log: Thread 1 Group 5 Seq 6 Reading mem 0
Mem# 0 errs 0: /u01/app/PROD/disk1/redo05.log
Mem# 1 errs 0: /u01/app/PROD/disk2/redo05b.log
Tue Nov 11 22:17:36 2014
Media Recovery Complete (PROD)
Completed: ALTER DATABASE RECOVER datafile 10
检查数据库相关状态:
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 0
6 NOT ACTIVE 0
7 NOT ACTIVE 0
8 NOT ACTIVE 0
9 NOT ACTIVE 0
10 NOT ACTIVE 195848 2014/11/11 22:12:07
11 NOT ACTIVE 0
12 NOT ACTIVE 0
12 rows selected.
SQL> select tablespace_name,STATUS from dba_tablespaces;
set linesize 200
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS ONLINE
SYSAUX ONLINE
TEMPTS1 ONLINE
TEMP1 ONLINE
TEMP2 ONLINE
EXAMPLE ONLINE
INDX ONLINE
TOOLS ONLINE
USERS ONLINE
OLTP ONLINE
REGISTRATION ONLINE
TEST1 ONLINE
TEST2 ONLINE
TEST3 ONLINE
15 rows selected.
SQL> SQL> set pagesize 200
SQL> col file_name for a50
SQL> select file_name,file_id,tablespace_name,status from dba_data_files;
FILE_NAME FILE_ID TABLESPACE_NAME STATUS
-------------------------------------------------- ---------- ------------------------------ ---------
/u01/app/PROD/disk1/system01.dbf 1 SYSTEM AVAILABLE
/u01/app/PROD/disk1/undotbs01.dbf 2 UNDOTBS AVAILABLE
/u01/app/PROD/disk1/sysaux01.dbf 3 SYSAUX AVAILABLE
/u01/app/PROD/disk1/example.dbf 4 EXAMPLE AVAILABLE
/u01/app/PROD/disk1/indx.dbf 5 INDX AVAILABLE
/u01/app/PROD/disk1/tools.dbf 6 TOOLS AVAILABLE
/u01/app/PROD/disk1/users.dbf 7 USERS AVAILABLE
/u01/app/PROD/disk1/oltp.dbf 8 OLTP AVAILABLE
/u01/app/PROD/disk1/REGISTRATION.dbf 9 REGISTRATION AVAILABLE
/u01/app/PROD/disk1/test1.dbf 10 TEST1 AVAILABLE
/u01/app/PROD/disk1/test2.dbf 11 TEST2 AVAILABLE
/u01/app/PROD/disk1/test3.dbf 12 TEST3 AVAILABLE
#############################################################################################
11.2.0.4.0 版本表空间正在热备份时关闭实例重启报错的重现和解决:
--
>11G此问题的报错信息比10G更清楚,根据报错信息就有了基本的判断方向。
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 0
6 NOT ACTIVE 1149659 2014/11/11 21:49:55
7 NOT ACTIVE 0
7 rows selected.
SQL> select sysdate from dual;
SYSDATE
-------------------
2014/11/11 22:05:26
SQL> ALTER TABLESPACE TEST1 BEGIN BACKUP;
Tablespace altered.
SHUTDOWN ABORT实例并重启:
SQL> startup
ORACLE instance started.
Total System Global Area 418484224 bytes
Fixed Size 1365040 bytes
Variable Size 322964432 bytes
Database Buffers 88080384 bytes
Redo Buffers 6074368 bytes
Database mounted.
ORA-10873: file 6 needs to be either taken out of backup mode or media
recovered
ORA-01110: data file 6: '/u01/app/oracle/oradata/bys1/test01.dbf'
此时ALERT日志的报错信息:
Completed: ALTER DATABASE MOUNT
Tue Nov 11 22:06:36 2014
ALTER DATABASE OPEN
Errors in file /u01/app/oracle/diag/rdbms/bys1/bys1/trace/bys1_ora_3910.trc:
ORA-10873: file 6 needs to be either taken out of backup mode or media recovered
ORA-01110: data file 6: '/u01/app/oracle/oradata/bys1/test01.dbf'
ORA-10873 signalled during: ALTER DATABASE OPEN...
Tue Nov 11 22:06:36 2014
Checker run found 1 new persistent data failures
Tue Nov 11 22:21:36 2014
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 0
6 ACTIVE 1171509 2014/11/11 22:05:40
7 NOT ACTIVE 0
7 rows selected.
END BACKUP或RECOVER DATAFILE即可
SQL> ALTER TABLESPACE TEST1 end BACKUP;
Tablespace altered.
ALERT日志:
Tue Nov 11 23:00:56 2014
ALTER TABLESPACE TEST1 end BACKUP
Completed: ALTER TABLESPACE TEST1 end BACKUP
Tue Nov 11 23:01:23 2014
RECOVER DATAFILE时的相关日志:
Tue Nov 11 21:51:02 2014
Checker run found 1 new persistent data failures
Tue Nov 11 22:00:46 2014
ALTER DATABASE RECOVER datafile 6
Media Recovery Start
Serial Media Recovery started
Recovery of Online Redo Log: Thread 1 Group 3 Seq 48 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/bys1/redo03.log
Recovery of Online Redo Log: Thread 1 Group 1 Seq 49 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/bys1/redo01.log
Media Recovery Complete (bys1)
Completed: ALTER DATABASE RECOVER datafile 6
Tue Nov 11 22:01:01 2014
alter database open
SQL> select * from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- -------------------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 NOT ACTIVE 0
6 NOT ACTIVE 1171509 2014/11/11 22:05:40
7 NOT ACTIVE 0
7 rows selected.