在使用11g的DBNEWID工具时,碰到了数据库无法正常关闭的问题。
11g中成功使用DBNEWID的案例:http://yangtingkun.itpub.net/post/468/481871
操作步骤如下。将数据库正常关闭,且置于MOUNT状态:
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期六 4月 4 01:38:33 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select dbid, name from v$database;
DBID NAME
---------- ------------------
790993044 TEST11G
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 5279498240 bytes
Fixed Size 2094528 bytes
Variable Size 3192597056 bytes
Database Buffers 2080374784 bytes
Redo Buffers 4431872 bytes
数据库装载完毕。
下面利用DBNEWID修改数据库的ID和DBNAME:
SQL> host
$ nid target=/ dbname=new11g
DBNEWID: Release 11.1.0.6.0 - Production on 星期六 4月 4 01:42:36 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
已连接数据库 TEST11G (DBID=790993044)
已连接服务器版本 11.1.0
数据库中的控制文件数:
/data/oracle/oradata/test11g/control01.ctl
/data/oracle/oradata/test11g/control02.ctl
/data/oracle/oradata/test11g/control03.ctl
以下数据文件是只读的:
/data/oracle/oradata/test11g/test01.dbf (6)
此实用程序必须能够写入这些文件。
是否将数据库 ID 和数据库名 TEST11G 更改为 NEW11G? (Y/[N]) => y
操作继续进行
将数据库 ID 从 790993044 更改为 2654798284
将数据库名从 TEST11G 更改为 NEW11G
控制文件 /data/oracle/oradata/test11g/control01.ctl - 已修改
控制文件 /data/oracle/oradata/test11g/control02.ctl - 已修改
控制文件 /data/oracle/oradata/test11g/control03.ctl - 已修改
数据文件 /data/oracle/oradata/test11g/system01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/sysaux01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/undotbs01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/users01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/yangtk01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/test01.dbf - dbid 已更改, 已写入新名称
数据文件 /data/oracle/oradata/test11g/temp01.dbf - dbid 已更改, 已写入新名称
控制文件 /data/oracle/oradata/test11g/control01.ctl - dbid 已更改, 已写入新名称
控制文件 /data/oracle/oradata/test11g/control02.ctl - dbid 已更改, 已写入新名称
控制文件 /data/oracle/oradata/test11g/control03.ctl - dbid 已更改, 已写入新名称
NID-00600: 内部错误 - [28] [3113] [0] [0]
在验证时更改数据库名和 ID 失败 - 数据库保持原样。
DBNEWID - 已完成, 但出现验证错误。
$
在上面那个NID-600错误发生之前,nid一直没有响应,在alert文件中可以看到DBNEWID工具所写信息:
*** DBNEWID utility started ***
DBID will be changed from 790993044 to new DBID of 2654798284 for database TEST11G
DBNAME will be changed from TEST11G to new DBNAME of NEW11G
Starting datafile conversion
Setting recovery target incarnation to 1
Datafile conversion complete
Database name changed to NEW11G.
Modify parameter file and generate a new password file before restarting.
Database ID for database NEW11G changed to 2654798284.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open with RESETLOGS option.
Succesfully changed database name and ID.
*** DBNEWID utility finished succesfully ***
除此以外,还可以看到,Oracle在关闭数据库,但是出现了异常,导致数据库没有正常的关闭:
All dispatchers and shared servers shutdown
Sat Apr 04 01:47:56 2009
SHUTDOWN: Active processes prevent shutdown operation
Sat Apr 04 01:53:00 2009
SHUTDOWN: Active processes prevent shutdown operation
Sat Apr 04 01:58:04 2009
SHUTDOWN: Active processes prevent shutdown operation
Sat Apr 04 02:03:08 2009
SHUTDOWN: Active processes prevent shutdown operation
Sat Apr 04 02:08:12 2009
SHUTDOWN: Active processes prevent shutdown operation
长时间等待没有响应后,手工杀掉了一个后台进程,导致了上面nid出现了NID-600错误:
bash-3.00$ ps -ef|grep test11g
oracle 5351 1 0 01:40:38 ? 0:00 ora_smon_test11g
oracle 5347 1 0 01:40:38 ? 0:00 ora_lgwr_test11g
oracle 5327 1 0 01:40:37 ? 0:02 ora_vktm_test11g
oracle 5349 1 0 01:40:38 ? 0:01 ora_ckpt_test11g
oracle 5331 1 0 01:40:38 ? 0:00 ora_diag_test11g
oracle 5345 1 0 01:40:38 ? 0:00 ora_dbw1_test11g
oracle 5339 1 0 01:40:38 ? 0:02 ora_dia0_test11g
oracle 5353 1 0 01:40:38 ? 0:00 ora_reco_test11g
oracle 5335 1 0 01:40:38 ? 0:00 ora_psp0_test11g
oracle 5343 1 0 01:40:38 ? 0:00 ora_dbw0_test11g
oracle 6338 5472 0 02:11:01 pts/2 0:00 grep test11g
oracle 5333 1 0 01:40:38 ? 0:00 ora_dbrm_test11g
oracle 5325 1 0 01:40:37 ? 0:03 ora_pmon_test11g
oracle 5341 1 0 01:40:38 ? 0:00 ora_mman_test11g
oracle 5414 5413 0 01:42:37 ? 0:01 oracletest11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
bash-3.00$ kill -9 5341
虽然DBNEWID报错,但是修改工作已经完成,修改初始化参数后,通过OPEN RESETLOGS可以顺利打开数据库:
SQL> shutdown immediate
ORA-03135: 连接失去联系
SQL> conn / as sysdba
已连接到空闲例程。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 5279498240 bytes
Fixed Size 2094528 bytes
Variable Size 3192597056 bytes
Database Buffers 2080374784 bytes
Redo Buffers 4431872 bytes
ORA-01103: ?????????? ''NEW11G'' ?? ''TEST11G''
SQL> alter system set db_name = new11g scope = spfile;
系统已更改。
SQL> shutdown immediate
ORA-01507: ??????
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 5279498240 bytes
Fixed Size 2094528 bytes
Variable Size 3192597056 bytes
Database Buffers 2080374784 bytes
Redo Buffers 4431872 bytes
数据库装载完毕。
SQL> alter database open resetlogs;
数据库已更改。
SQL> select dbid, name from v$database;
DBID NAME
---------- ------------------
2654798284 NEW11G
SQL> select * from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
NEW11G.NETDB
可以看到DBID和DB_NAME都已经修改成功了。
经过多次的测试,对比文章开头给出的成功的案例,发现导致问题的原因很简单,由于在执行NID命令的时候,没有退出SQLPLUS,也就是说SYS用户的连接还存在,导致NID在关闭数据库的时候出现了等待,而类似的bug描述在以前也碰到过:http://yangtingkun.itpub.net/post/468/469358
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-586803/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/4227/viewspace-586803/