网上有很多关于oracle 监听静态注册的文章,但大多都是简单说说,并没有详细的例子,这里,将结合linux as3 下的oracle 10gR2.0.1 举一个具体的例子
1、在 $ORACLE_HOME/network/admin/listener.ora 文件中加入一个静态注册的节点
[oracle@guohui6 oracle]$ cd $ORACLE_HOME/network/admin
[oracle@guohui6 admin]$ vi listener.ora
# listener.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
[oracle@guohui6 admin]$ vi listener.ora
# listener.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /mydatafile2/app/oracle/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
( SID_NAME = ORCL)--此为oracle实例的名称,不能随便更改
(ORACLE_HOME = /mydatafile2/app/oracle/oracle/product/10.2.0/db_1)
( GLOBAL_DBNAME=HJD.COM.CN)--此为别名,可以自定义
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = guohui6)(PORT = 1521))--host既可以为主机名,也可以为IP地址,PORT为端口号
)
)
注意这里的global_dbname=HJD.COM.CN
SID_NAME=ORCL
这个SID_NAME 应与你对外提供服务的 $ORACLE_SID 一致
[oracle@guohui6 admin]$ echo $ORACLE_SID
ORCL
ORCL
2、配置对应的tnsnames.ora 中的节点
[oracle@guohui6 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = guohui6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
GUOHUIORCL=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = guohui6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = HJD.COM.CN)--此为之前定义的别名,通过之前定义的别名,映射到SID_NAME
)
)
# tnsnames.ora Network Configuration File: /mydatafile2/app/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = guohui6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
GUOHUIORCL=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = guohui6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = HJD.COM.CN)--此为之前定义的别名,通过之前定义的别名,映射到SID_NAME
)
)
tnsname GUOHUIORCL 中的 SERVICE_NAME=HJD.COM.CN
这里的服务名为 HJD.COM.CN 而不是通常的 ORCL,因为在 listener.ora 中已经注册了 HJD.COM.CN,lsnrctl 启动时会监听 HJD.COM.CN ,并对应到 SID_NAME=ORCL 上。
3、启动监听和服务
4、验证该服务可以到达
地址:http://www.cnblogs.com/kelantas/archive/2011/02/14/1953992.html