概述
oracle nid工具可用于修改数据库名,在修改过程中失败,将导致部分文件修改成功,部分文件修改失败,数据库无法启动,这里记录对该问题的修复。
nid
DBNEWID: Release 11.2.0.4.0 - Production on Mon Nov 9 11:00:23 2020
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Keyword Description (Default)
----------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
现象
失败后可以看到,v$datafile_header,出现不同的RESETLOGS_CHANGE#,ERROR为WRONG RESETLOGS
bbed可以看到文件头上出现不同的dbid,resetlogs scn
select file#,status,error,checkpoint_change#,resetlogs_change#,RESETLOGS_TIME from v$datafile_header;
FILE# STATUS ERROR CHECKPOINT_CHANGE# RESETLOGS_CHANGE# RESETLOGS_TIME
-------------------- ------- ---------------------- -------------------- -------------------- ---------------
1 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
2 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
3 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
4 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
5 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
.......
176 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
177 ONLINE WRONG RESETLOGS 644282942109 644282942106 04-NOV-20
178 ONLINE 644282942105 579039040549 11-JUN-20
179 ONLINE 644282942105 579039040549 11-JUN-20
180 ONLINE 644282942105 579039040549 11-JUN-20
.......
487 ONLINE 644282942105 579039040549 11-JUN-20
488 ONLINE 644282942105 579039040549 11-JUN-20
489 ONLINE 644282942105 579039040549 11-JUN-20
489 rows selected.
处理
bbed 修改resetlog scn,dbid
修改resetlog scn
assign dba 178,1 kcvfh.kcvfhrlc=dba 1,1 kcvfh.kcvfhrlc
assign dba 178,1 kcvfh.kcvfhrls=dba 1,1 kcvfh.kcvfhrls
sum dba 178,1 apply
assign dba 179,1 kcvfh.kcvfhrlc=dba 1,1 kcvfh.kcvfhrlc
assign dba 179,1 kcvfh.kcvfhrls=dba 1,1 kcvfh.kcvfhrls
sum dba 179,1 apply
assign dba 180,1 kcvfh.kcvfhrlc=dba 1,1 kcvfh.kcvfhrlc
assign dba 180,1 kcvfh.kcvfhrls=dba 1,1 kcvfh.kcvfhrls
sum dba 180,1 apply
......
assign dba 488,1 kcvfh.kcvfhrlc=dba 1,1 kcvfh.kcvfhrlc
assign dba 488,1 kcvfh.kcvfhrls=dba 1,1 kcvfh.kcvfhrls
sum dba 488,1 apply
assign dba 489,1 kcvfh.kcvfhrlc=dba 1,1 kcvfh.kcvfhrlc
assign dba 489,1 kcvfh.kcvfhrls=dba 1,1 kcvfh.kcvfhrls
sum dba 489,1 apply
修改dbid
assign dba 1,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 1,1 apply
assign dba 2,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 2,1 apply
assign dba 3,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 3,1 apply
assign dba 4,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 4,1 apply
assign dba 5,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 5,1 apply
......
assign dba 176,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 176,1 apply
assign dba 177,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 177,1 apply
assign dba 178,1 kcvfhhdr.kccfhdbi=dba 180,1 kcvfhhdr.kccfhdbi
sum dba 178,1 apply
重建控制文件
alter database backup controlfile to trace as ‘/home/oracle/ctl.trc’;
通过/home/oracle/ctl.trc中的信息,重建控制文件。
open resetlogs
创建临时pfile,增加参数*._allow_resetlogs_corruption=true
重建控制文件后需要为temp表空间增加临时文件.