最近一个客户的库在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