在Windows平台上启动多个Instance比在UNIX环境下要繁琐一点,需要用到ORADIM来创建新的ORACLE_SID.
现在假设在一台Windows PC上装了一个名字为ORCL的Oracle数据库,默认情况下启动的都是这个对应于这个ORACLE_SID的instance, 现在如果我需要在这台机器上启动另外一个instance (假设名字叫ORCL2),该怎么办呢?
首先先创建另外一个参数文件initorcl2.ora用来启动orcl2这个instance, 内容如下,
db_name=orcl2
先看看如果不用ORADIM会怎么样,
C:\Documents and Settings\szuser>set ORACLE_SID=orcl
C:\Documents and Settings\szuser>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 18 11:33:52 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1298208 bytes
Variable Size 230686944 bytes
Database Buffers 373293056 bytes
Redo Buffers 7090176 bytes
Database mounted.
Database opened.
SQL>
现在启动了默认的instance, 现在如果我再启动名字为orcl2的instance,
C:\Documents and Settings\szuser>SET ORACLE_SID=orcl2
C:\Documents and Settings\szuser>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 18 11:47:24 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn / as sysdba
ERROR:
ORA-12560: TNS:protocol adapter error
SQL>
可以看出在尝试startup 之前就出现了错误ORA-12560. 原因是因为在Windows平台下,需要对每个instance先启动一个服务来初始化环境,因为没有对应于orcl2的service,因此会出现问题。
现在用ORADIM来为orcl2创建服务,
C:\Documents and Settings\szuser>oradim -new -sid orcl2
Instance created.
这时候会在Windows的Services控制面板中看到一个新的服务项,
然后就可以启动这个orcl2 instance了,不过注意的是只能startup到nomount状态,因为数据库orcl2还不存在呢。
这样就可以在同一台机器上启动多个oracle instance了!
C:\Documents and Settings\szuser>set ORACLE_SID=orcl2
C:\Documents and Settings\szuser>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 18 11:34:45 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=E:\oracle\product\10.2.0\db_1\database\initorcl2.ora
ORACLE instance started.
Total System Global Area 117440512 bytes
Fixed Size 1295320 bytes
Variable Size 58723368 bytes
Database Buffers 50331648 bytes
Redo Buffers 7090176 bytes
从Oracle的文档里面也可以看到如何实现在同一台机器上run多个instance,
Running Multiple Instances
To run multiple instances:
- 1. Start the service for each instance using ORADIM utility or the Services dialog box of the Control Panel.
- 2. At the command prompt set the
ORACLE_SID
configuration parameter to theSID
for the first instance to run:C:\> SET ORACLE_SID=SID
where
SID
is the name of the Oracle9i database instance. - 3. Start SQL*Plus:
C:\> sqlplus / NOLOG
- 4. Connect AS SYSDBA:
SQL> CONNECT / AS SYSDBA
- 5. Start up the first instance:
SQL> STARTUP PFILE=ORACLE_BASE\admin\db_name\pfile\init.ora
where
ORACLE_BASE
isc:\oracle
(unless you changed it during installation) anddb_name
is the name of the instance. - Repeat Steps 2-5 for the other instances to run.