ORA-01189的完整解决过程(File is from a different RESETLOGS than previous files)

简介: 昨天用户报告数据库不能启动了,询问用户,用户也不清楚原因。在解决过程中遇到了ORA-01189的问题,查遍了网上,包括metalink,也没有找到合适的解决方案,差点就放弃了......还好,根据ORACLE的错误解释,终于摸索出了下面的解决方法。

昨天用户报告数据库不能启动了,询问用户,用户也不清楚原因。在解决过程中遇到了ORA-01189的问题,查遍了网上,包括metalink,也没有找到合适的解决方案,差点就放弃了......还好,根据ORACLE的错误解释,终于摸索出了下面的解决方法。:)
ORA-01189解释:
Cause: In a CREATE CONTROLFILE command, either this file or all previous files were backups from before the last RESETLOGS. This also may occur if this is a file that is offline and has been offline since before the last RESETLOGS.
Action: If the file was taken offline normally before the last RESETLOGS and is still offline, omit it from the CREATE CONTROLFILE command. Rename and online the file after the database is open. Otherwise, find the version of the mentioned file consistent with the rest of the datafiles and retry the command.


以下是解决过程
试图打开数据库:
SQLPLUS>STARTUP
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
ORA-01190: 控制文件或数据文件1来自于最后一个 RESETLOGS 之前
ORA-01110: 数据文件 1: 'E:ORACLE9IORA9ISYSTEM01.DBF'

SQLPLUS>SELECT TS#,FILE#,CHECKPOINT_CHANGE# FROM V$DATAFILE;
TS# FILE# CHECKPOINT_CHANGE#
---- ----- ------------------
0 1 37667
1 2 37667
3 3 37667
4 4 37667
5 5 37667
6 6 37667
7 7 37667
8 8 37667
13 9 37667
14 10 37667
15 11 37667
TS# FILE# CHECKPOINT_CHANGE#
---- ----- ------------------
16 12 37667
已选择12行。
SQLPLUS>SELECT * FROM V$RECOVER_FILE;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
----- ------- ------- -------------------- --------------- ----------
1 ONLINE ONLINE UNKNOWN ERROR 37650 18-12月-04
从上面中可以看出来,V$RECOVER_FILE中文件1的CHANGE#小于V$DATAFILE的CHECKPOINT_CHANGE#。由于没有备份,决定重新创建控制文件。
SQLPLUS>ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
数据库已更改。
SQLPLUS>SHUTDOWN IMMEDIATE
ORA-01109: 数据库未打开

已经卸载数据库。
ORACLE 例程已经关闭。
SQLPLUS>STARTUP NOMOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

SQLPLUS>CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS NOARCHIVELOG
2 -- SET STANDBY TO MAXIMIZE PERFORMANCE
3 MAXLOGFILES 5
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 1
7 MAXLOGHISTORY 453
8 LOGFILE
9 GROUP 1 'E:ORACLE9IORA9IREDO01.LOG' SIZE 5M,
10 GROUP 2 'E:ORACLE9IORA9IREDO02.LOG' SIZE 5M
11 -- STANDBY LOGFILE
12 DATAFILE
13 'E:ORACLE9IORA9ISYSTEM01.DBF',
14 'E:ORACLE9IORA9IUNDOTBS01.DBF',
15 'E:ORACLE9IORA9IDRSYS01.DBF',
16 'E:ORACLE9IORA9IINDX01.DBF',
17 'E:ORACLE9IORA9ITOOLS01.DBF',
18 'E:ORACLE9IORA9IUSERS01.DBF',
19 'E:ORACLE9IORA9IXDB01.DBF',
20 'E:ORACLE9IORA9IOEM_REPOSITORY.DBF',
21 'E:ORACLE9IORADATAGAXZTEMP.DB',
22 'E:ORACLE9IORADATAGAXZUSR.DB',
23 'E:ORACLE9IORADATAGAXZRBS.DB',
24 'E:ORACLE9IORADATAGAXZWEB.DB'
25 CHARACTER SET ZHS16GBK
26 ;
CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS NOARCHIVELOG
*
ERROR 位于第 1 行:
ORA-01503: CREATE CONTROLFILE ??
ORA-01189: ????????????? RESETLOGS
ORA-01110: ???? 2: 'E:ORACLE9IORA9IUNDOTBS01.DBF'
上面按照生成的控制文件代码重新创建控制文件的时候,出现了讨厌的ORA-01189! 于是将除了SYSTEM表空间对应的文件以外,其它的文件都去掉:
SQLPLUS>CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS NOARCHIVELOG
2 -- SET STANDBY TO MAXIMIZE PERFORMANCE
3 MAXLOGFILES 5
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 1
7 MAXLOGHISTORY 453
8 LOGFILE
9 GROUP 1 'E:ORACLE9IORA9IREDO01.LOG' SIZE 5M,
10 GROUP 2 'E:ORACLE9IORA9IREDO02.LOG' SIZE 5M
11 -- STANDBY LOGFILE
12 DATAFILE
13 'E:ORACLE9IORA9ISYSTEM01.DBF'
14 CHARACTER SET ZHS16GBK
15 ;
控制文件已创建
SQLPLUS>SHUTDOWN IMMEDIATE
ORA-01109: ??????

已经卸载数据库。
ORACLE 例程已经关闭。
SQLPLUS>STARTUP MOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
SQLPLUS>RECOVER USING BACKUP CONTROLFILE UNTIL CANCEL;
ORA-00279: 更改 37650 (在 12/18/2004 15:06:24 生成) 对于线程 1 是必需的
ORA-00289: 建议: E:ORACLE9IORA9IARCHIVEORA9IT001S00001.ARC
ORA-00280: 更改 37650 对于线程 1 是按序列 # 1 进行的

指定日志: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
介质恢复已取消。
SQLPLUS>ALTER DATABASE OPEN RESETLOGS;
ALTER DATABASE OPEN RESETLOGS
*
ERROR 位于第 1 行:
ORA-01092: ORACLE 例程终止。强行断开连接
查看日志,发现了出现上面问题的原因:
ORA-30012: 撤消表空间 'UNDOTBS' 不存在或类型不正确
SQLPLUS>CONNECT
/@ORA9I AS SYSDBA
已连接到空闲例程。
SQLPLUS>STARTUP MOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
SQLPLUS>ALTER SYSTEM SET UNDO_MANAGEMENT=MANUAL SCOPE=SPFILE;
系统已更改。
SQLPLUS>ALTER SYSTEM SET UNDO_TABLESPACE='' SCOPE=SPFILE;
系统已更改。
SQLPLUS>SHUTDOWN IMMEDIATE
ORA-01109: 数据库未打开

已经卸载数据库。
ORACLE 例程已经关闭。
SQLPLUS>STARTUP MOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
SQLPLUS>ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR 位于第 1 行:
ORA-01113: 文件 1 需要介质恢复
ORA-01110: 数据文件 1: 'E:ORACLE9IORA9ISYSTEM01.DBF'

SQLPLUS>RECOVER DATAFILE 1;
完成介质恢复。
SQLPLUS>ALTER DATABASE OPEN;
数据库已更改。
至此,数据库已经打开。查看V$DATAFILE和V$RECOVER_FILE,如下所示:
SQLPLUS>SELECT TS#,FILE#,NAME,STATUS,CHECKPOINT_CHANGE# FROM V$DATAFILE;
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
0 1 E:ORACLE9IORA9ISYSTEM01.DBF SYSTEM 37658
1 2 E:ORACLE9IDATABASEMISSING00002 RECOVER 0
3 3 E:ORACLE9IDATABASEMISSING00003 RECOVER 0
4 4 E:ORACLE9IDATABASEMISSING00004 RECOVER 0
5 5 E:ORACLE9IDATABASEMISSING00005 RECOVER 0
6 6 E:ORACLE9IDATABASEMISSING00006 RECOVER 0
7 7 E:ORACLE9IDATABASEMISSING00007 RECOVER 0
8 8 E:ORACLE9IDATABASEMISSING00008 RECOVER 0
13 9 E:ORACLE9IDATABASEMISSING00009 RECOVER 0
14 10 E:ORACLE9IDATABASEMISSING00010 RECOVER 0
15 11 E:ORACLE9IDATABASEMISSING00011 RECOVER 0
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
16 12 E:ORACLE9IDATABASEMISSING00012 RECOVER 0
已选择12行。
SQLPLUS>SELECT * FROM V$RECOVER_FILE;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
----- ------- ------- -------------------- --------------- ----------
2 OFFLINE OFFLINE FILE MISSING 0
3 OFFLINE OFFLINE FILE MISSING 0
4 OFFLINE OFFLINE FILE MISSING 0
5 OFFLINE OFFLINE FILE MISSING 0
6 OFFLINE OFFLINE FILE MISSING 0
7 OFFLINE OFFLINE FILE MISSING 0
8 OFFLINE OFFLINE FILE MISSING 0
9 OFFLINE OFFLINE FILE MISSING 0
10 OFFLINE OFFLINE FILE MISSING 0
11 OFFLINE OFFLINE FILE MISSING 0
12 OFFLINE OFFLINE FILE MISSING 0
已选择11行。
将丢失的数据文件指定到正确的文件上去。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00002' TO 'E:ORACLE9IORA9IUNDOTBS01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00003' TO 'E:ORACLE9IORA9IDRSYS01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00004' TO 'E:ORACLE9IORA9IINDX01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00005' TO 'E:ORACLE9IORA9ITOOLS01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00006' TO 'E:ORACLE9IORA9IUSERS01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00007' TO 'E:ORACLE9IORA9IXDB01.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00008' TO 'E:ORACLE9IORA9IOEM_REPOSITORY.DBF';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00009' TO 'E:ORACLE9IORADATAGAXZTEMP.DB';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00010' TO 'E:ORACLE9IORADATAGAXZUSR.DB';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00011' TO 'E:ORACLE9IORADATAGAXZRBS.DB';
数据库已更改。
SQLPLUS>ALTER DATABASE RENAME FILE 'E:ORACLE9IDATABASEMISSING00012' TO 'E:ORACLE9IORADATAGAXZWEB.DB';
数据库已更改。
再次查看V$DATAFILE和V$RECOVER_FILE:
SQLPLUS>SELECT TS#,FILE#,NAME,STATUS,CHECKPOINT_CHANGE# FROM V$DATAFILE;
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
0 1 E:ORACLE9IORA9ISYSTEM01.DBF SYSTEM 37660
1 2 E:ORACLE9IORA9IUNDOTBS01.DBF RECOVER 0
3 3 E:ORACLE9IORA9IDRSYS01.DBF RECOVER 0
4 4 E:ORACLE9IORA9IINDX01.DBF RECOVER 0
5 5 E:ORACLE9IORA9ITOOLS01.DBF RECOVER 0
6 6 E:ORACLE9IORA9IUSERS01.DBF RECOVER 0
7 7 E:ORACLE9IORA9IXDB01.DBF RECOVER 0
8 8 E:ORACLE9IORA9IOEM_REPOSITORY.DBF RECOVER 0
13 9 E:ORACLE9IORADATAGAXZTEMP.DB RECOVER 0
14 10 E:ORACLE9IORADATAGAXZUSR.DB RECOVER 0
15 11 E:ORACLE9IORADATAGAXZRBS.DB RECOVER 0
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
16 12 E:ORACLE9IORADATAGAXZWEB.DB RECOVER 0
已选择12行。
SQLPLUS>SELECT * FROM V$RECOVER_FILE;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
----- ------- ------- -------------------- --------------- ----------
2 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
3 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
4 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
5 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
6 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
7 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
8 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
9 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
10 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
11 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
12 OFFLINE OFFLINE UNKNOWN ERROR 37667 18-12月-04
已选择11行。
SQLPLUS>ALTER DATABASE DATAFILE 2 ONLINE;
ALTER DATABASE DATAFILE 2 ONLINE
*
ERROR 位于第 1 行:
ORA-01190: 控制文件或数据文件2来自于最后一个 RESETLOGS 之前
ORA-01110: 数据文件 2: 'E:ORACLE9IORA9IUNDOTBS01.DBF'
接下来由于V$DATAFILE中的CHECKPOINT_CHANGE#仍然大于V$RECOVER_FILE中的CHANGE#,决定用ADJUST_SCN来调整SCN.
首先需要设置_allow_resetlogs_corruption参数,否则不能成功(实验了)
SQLPLUS>SHUTDOWN IMMEDIATE
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQLPLUS>STARTUP MOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
SQLPLUS>ALTER DATABASE OPEN;
数据库已更改。
SQLPLUS>ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME ADJUST_SCN LEVEL 1';
会话已更改。
SQLPLUS>SHUTDOWN IMMEDIATE
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQLPLUS>STARTUP MOUNT;
ORACLE 例程已经启动。
Total System Global Area 135339940
bytes

Fixed Size 454564
bytes

Variable Size 109051904
bytes

Database Buffers 25165824
bytes

Redo Buffers 667648
bytes

数据库装载完毕。
SQLPLUS>SELECT TS#,FILE#,NAME,STATUS,CHECKPOINT_CHANGE# FROM V$DATAFILE;
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
0 1 E:ORACLE9IORA9ISYSTEM01.DBF SYSTEM 1041478416
1 2 E:ORACLE9IORA9IUNDOTBS01.DBF OFFLINE 0
3 3 E:ORACLE9IORA9IDRSYS01.DBF OFFLINE 0
4 4 E:ORACLE9IORA9IINDX01.DBF OFFLINE 0
5 5 E:ORACLE9IORA9ITOOLS01.DBF OFFLINE 0
6 6 E:ORACLE9IORA9IUSERS01.DBF OFFLINE 0
7 7 E:ORACLE9IORA9IXDB01.DBF OFFLINE 0
8 8 E:ORACLE9IORA9IOEM_REPOSITORY.DBF OFFLINE 0
13 9 E:ORACLE9IORADATAGAXZTEMP.DB OFFLINE 0
14 10 E:ORACLE9IORADATAGAXZUSR.DB OFFLINE 0
15 11 E:ORACLE9IORADATAGAXZRBS.DB OFFLINE 0
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
---- ----- ---------------------------------------- ------- ------------------
16 12 E:ORACLE9IORADATAGAXZWEB.DB OFFLINE 0
已选择12行。
SQLPLUS>SELECT * FROM V$RECOVER_FILE;
FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
----- ------- ------- -------------------- --------------- ----------
2 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
3 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
4 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
5 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
6 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
7 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
8 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
9 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
10 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
11 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
12 OFFLINE OFFLINE WRONG FILE CREATE 37667 18-12月-04
已选择11行。

SQLPLUS>RECOVER UNTIL CANCEL;
完成介质恢复。
上面这一步很重要,虽然不做这个操作也能打开数据库,但是我们是要用RESETLOGS来打开数据库,否则仍然将其它数据文件联机的时候
仍然会报ORA-01189.
然后将数据文件状态联机。
SQLPLUS>ALTER DATABASE DATAFILE 2,3,4,5,6,7,8,9,10,11,12 ONLINE;
数据库已更改。
打开数据库。
SQLPLUS>ALTER DATABASE OPEN RESETLOGS;
数据库已更改。
查看V$DATAFILE,文件状态已经是ONLINE了。
TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
--- ----- ---------------------------------------- ------- ------------------
0 1 E:ORACLE9IORA9ISYSTEM01.DBF SYSTEM 1041478418
1 2 E:ORACLE9IORA9IUNDOTBS01.DBF ONLINE 1041478418
3 3 E:ORACLE9IORA9IDRSYS01.DBF ONLINE 1041478418
4 4 E:ORACLE9IORA9IINDX01.DBF ONLINE 1041478418
5 5 E:ORACLE9IORA9ITOOLS01.DBF ONLINE 1041478418
6 6 E:ORACLE9IORA9IUSERS01.DBF ONLINE 1041478418
7 7 E:ORACLE9IORA9IXDB01.DBF ONLINE 1041478418
8 8 E:ORACLE9IORA9IOEM_REPOSITORY.DBF ONLINE 1041478418
13 9 E:ORACLE9IORADATAGAXZTEMP.DB ONLINE 1041478418
14 10 E:ORACLE9IORADATAGAXZUSR.DB ONLINE 1041478418
15 11 E:ORACLE9IORADATAGAXZRBS.DB ONLINE 1041478418

TS# FILE# NAME STATUS CHECKPOINT_CHANGE#
--- ----- ---------------------------------------- ------- ------------------
16 12 E:ORACLE9IORADATAGAXZWEB.DB ONLINE 1041478418
至此,数据库已经恢复了,接下来的工作就简单了:
将临时表空间文件找回:
SQLPLUS>ALTER TABLESPACE TEMP ADD TEMPFILE 'E:ORACLE9iORA9ITEMP01.DBF' REUSE;
表空间已更改。
将UNDO管理方式改成自动
SQLPLUS>ALTER SYSTEM SET UNDO_MANAGEMENT=AUTO SCOPE=SPFILE;
系统已更改。
SQLPLUS>ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS SCOPE=SPFILE;
系统已更改。
用EXP导出数据,重建数据库。

总结:刚解决完的时候,有点不敢相信竟然解决了。因为这种由SYSTEM表空间造成的ORA-01189这个错误,我一直以为只能通过DUL来解决了。
在网上也同样找不到真正解决的资料,一般都是解决ORA-01190的。这两个问题的区别在于,创建控制文件的时候如果不产生01189(用resetlogs选项)那么创建时不用将其它的数据文件去掉,而且打开数据库的时候只要设置_allow_resetlogs_corruption就可以了,另外也不用adjust_scn来修改change#。于是在自己的机器上又做了几次实验:
1关掉数据库;
2备份SYSTEM表空间;
3打开数据库;
4切换日志;
5关数据库;
6替换旧的SYSTEM表空间。
模拟出了同样的问题。然后用同样的方法解决了。

目录
相关文章
|
5月前
|
TensorFlow 算法框架/工具
【ERROR】FailedPreconditionError: checkpoint is not a directory
【ERROR】FailedPreconditionError: checkpoint is not a directory
83 1
|
数据库
ORA-01113: file 1 needs media recovery ORA-01110: data file 1:
把下面两个隐含参数加入到pfile中
243 0
ORA-09925: Unable to create audit trail file
ORA-09925: Unable to create audit trail file
151 0
|
SQL 关系型数据库
ORA-01336: specified dictionary file cannot be opened
这篇介绍使用Logminer时遇到ORA-01336: specified dictionary file cannot be opened错误的各种场景   1:dictionary_location参数的路径最后多了一个/符号。
1323 0
|
关系型数据库 数据库管理 Oracle