ora-01190: 控制文件或数据文件2来自于最后一个 resetlogs 之前ora-01110: 数据文件 2: lsquo;e:\oracle9i\ora9i\undotbs01.dbf
sqlplus>alter database datafile 2 online;
alter database datafile 2 online
*
error 位于第 1 行:
ora-01190: 控制文件或数据文件2来自于最后一个 resetlogs 之前
ora-01110: 数据文件 2: ‘e:\oracle9i\ora9i\undotbs01.dbf’
接下来由于v$datafile中的checkpoint_change#仍然大于v$recover_file中的change#,决定用adjust_scn来调整scn.
首先需要设置_allow_resetlogs_corruption参数,否则不能成功(实验了)
sqlplus>alter system set “_allow_resetlogs_corruption”=true scope=spfile;
系统已更改。
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:\oracle9i\ora9i\system01.dbf system 1041478416
1 2 e:\oracle9i\ora9i\undotbs01.dbf offline 0
3 3 e:\oracle9i\ora9i\drsys01.dbf offline 0
4 4 e:\oracle9i\ora9i\indx01.dbf offline 0
5 5 e:\oracle9i\ora9i\tools01.dbf offline 0
6 6 e:\oracle9i\ora9i\users01.dbf offline 0
7 7 e:\oracle9i\ora9i\xdb01.dbf offline 0
8 8 e:\oracle9i\ora9i\oem_repository.dbf offline 0
13 9 e:\oracle9i\oradata\gaxztemp.db offline 0
14 10 e:\oracle9i\oradata\gaxzusr.db offline 0
15 11 e:\oracle9i\oradata\gaxzrbs.db offline 0
ts# file# name status checkpoint_change#
—- —– —————————————- ——- ——————
16 12 e:\oracle9i\oradata\gaxzweb.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:\oracle9i\ora9i\system01.dbf system 1041478418
1 2 e:\oracle9i\ora9i\undotbs01.dbf online 1041478418
3 3 e:\oracle9i\ora9i\drsys01.dbf online 1041478418
4 4 e:\oracle9i\ora9i\indx01.dbf online 1041478418
5 5 e:\oracle9i\ora9i\tools01.dbf online 1041478418
6 6 e:\oracle9i\ora9i\users01.dbf online 1041478418
7 7 e:\oracle9i\ora9i\xdb01.dbf online 1041478418
8 8 e:\oracle9i\ora9i\oem_repository.dbf online 1041478418
13 9 e:\oracle9i\oradata\gaxztemp.db online 1041478418
14 10 e:\oracle9i\oradata\gaxzusr.db online 1041478418
15 11 e:\oracle9i\oradata\gaxzrbs.db online 1041478418
ts# file# name status checkpoint_change#
— —– —————————————- ——- ——————
16 12 e:\oracle9i\oradata\gaxzweb.db online 1041478418
至此,,数据库已经恢复了,接下来的工作就简单了:
将临时表空间文件找回:
sqlplus>alter tablespace temp add tempfile ‘e:\oracle9i\ora9i\temp01.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表空间。
模拟出了同样的问题。然后用同样的方法解决了。