在 Oracle 的世界里,一个实例只能打开一个数据库,如果我想在本机中同时运行两个数据库,那就要开启两个实例了,而不同的实例的标识就是SID。
关闭现有数据库,设定好一个新的 SID 后,通过复制参数文件为 spfile
整个过程都很顺利,但是此时再试图打开原来的数据库就会报错了:
ORA-01102: cannot mount database in EXCLUSIVE mode |
而 alert 文件中出现如下信息:
Sat Oct 9 11:14:18 2010 ALTER DATABASE MOUNT Sat Oct 9 11:14:18 2010 sculkget: failed to lock /u01/app/oracle/dbs/lkORA8I exclusive sculkget: lock held by PID: 11621 Sat Oct 9 11:14:18 2010 ORA-09968: Message 9968 not found; No message file for product=RDBMS, facility=ORA Linux-x86_64 Error: 11: Resource temporarily unavailable Additional information: 11621 Sat Oct 9 11:14:18 2010 ORA-1102 signalled during: ALTER DATABASE MOUNT… |
旧的数据库的 SID 和 DB_NAME 均是 ORA8I,failed to lock /u01/app/oracle/dbs/lkORA8I exclusive 应该就是问题所在了,在参数文件中的db_name好改,但是db_name还存在于控制文件和数据文件中,这些文件怎么改呢? 这个就要借助nid程序了。
首先将新数据库启动到 mount 阶段,假设新的数据库的实例是oratmp,数据库名也是oratmp。
[oracle@l004020 ~]$ export $ORACLE_SID=oratmp [oracle@l004020 ~]$ nid target=sys/sys_password dbname=oratmp DBNEWID: Release 10.2.0.2.0 – Production on Sat Oct 9 11:37:47 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to database ORA8I (DBID=152116074) Connected to server version 10.2.0 Control Files in database: /u02/oradata/oratmp/control01.ctl /u02/oradata/oratmp/control02.ctl /u02/oradata/oratmp/control03.ctl Change database ID and database name ORA8I to ORATMP? (Y/[N]) => y Proceeding with operation Changing database ID from 152116074 to 3320092043 Changing database name from ORA8I to ORATMP Control File /u02/oradata/oratmp/control01.ctl – modified Control File /u02/oradata/oratmp/control02.ctl – modified Control File /u02/oradata/oratmp/control03.ctl – modified Datafile /u02/oradata/oratmp/system01.dbf – dbid changed, wrote new name Datafile /u02/oradata/oratmp/undotbs01.dbf – dbid changed, wrote new name Datafile /u02/oradata/oratmp/sysaux01.dbf – dbid changed, wrote new name Datafile /u02/oradata/oratmp/users01.dbf – dbid changed, wrote new name Datafile /u02/oradata/ora8i/temp01.dbf – dbid changed, wrote new name Control File /u02/oradata/oratmp/control01.ctl – dbid changed, wrote new name Control File /u02/oradata/oratmp/control02.ctl – dbid changed, wrote new name Control File /u02/oradata/oratmp/control03.ctl – dbid changed, wrote new name Instance shut down Database name changed to ORATMP. Modify parameter file and generate a new password file before restarting. Database ID for database ORATMP changed to 3320092043. All previous backups and archived redo logs for this database are unusable. Database has been shutdown, open database with RESETLOGS option. Succesfully changed database name and ID. DBNEWID – Completed succesfully. [oracle@l004020 ~]$ sqlplus / as sysdba SQL> shutdown immediate; ORA-01507: database not mounted ORACLE instance shut down. SQL> startup mount ; ORACLE instance started. Total System Global Area 167772160 bytes Fixed Size 2069648 bytes Variable Size 104860528 bytes Database Buffers 50331648 bytes Redo Buffers 10510336 bytes ORA-01103: database name ‘ORATMP’ in control file is not ‘ORA8I’ SQL> alter system set db_name=’oratmp’ scope=spfile; System altered. SQL> shutdown immediate; ORA-01507: database not mounted ORACLE instance shut down. SQL> startup mount ; ORACLE instance started. Total System Global Area 167772160 bytes Fixed Size 2069648 bytes Variable Size 104860528 bytes Database Buffers 50331648 bytes Redo Buffers 10510336 bytes Database mounted. SQL> alter database open ; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open SQL> alter database open resetlogs ; Database altered. #再看看hc文件。 [oracle@l004020 dbs]$ ls -lth hc* -rw-rw—- 1 oracle dba 1.6K 10-09 11:49 hc_oratmp.dat -rw-rw—- 1 oracle dba 1.6K 10-09 11:34 hc_ora8i.dat |
简单来说就是如下几步:
1。startup mount ;
2。nid target=sys/sys_password dbname=oratmp
3。alter system set db_name=
4。shutdown
5。startup mount ;
6。alter database open resetlogs。
我们一直都在努力坚持原创.......请不要一声不吭,就悄悄拿走。
我原创,你原创,我们的内容世界才会更加精彩!
【所有原创内容版权均属TechTarget,欢迎大家转发分享。但未经授权,严禁任何媒体(平面媒体、网络媒体、自媒体等)以及微信公众号复制、转载、摘编或以其他方式进行使用。】
微信公众号
TechTarget
官方微博
TechTarget中国
作者
相关推荐
-
Collaborate 18大会:了解甲骨文云数据库和应用的进展
在Collaborate 18大会即将举行时,我们会发现,甲骨文用户社区的技术变化会略高于平常水平。 由独立甲 […]
-
甲骨文自治数据库亮相 带来云计算新希望
早前甲骨文还不在云计算公司之列,而现在该公司正在迅速弥补其失去的时间。甲骨文的云计算核心是甲骨文自治数据库(O […]
-
Oracle TNS 错误:管理员旷日持久的战斗
TNS经常给IT管理员带来麻烦,而且很难定位。尤其是在Oracle数据库中。本文将介绍如何避免这些常见错误。
-
Linux支持的引入 推动了SQL Server 2016集成服务的发展
随着SQL Server的不断发展,集成服务也在发生相应的变化。在最新的SSIS更新中,增加Linux支持和SQL Server 2016升级向导。