不同应用通不过不同的端口访问数据库,多网卡的情况下可以让不同应用通过不同的网卡访问数据库。
下面给出的示例是一个地址,不同端口:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = e:\oracle\product\10.2.0)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = yafeishi)
(ORACLE_HOME = e:\oracle\product\10.2.0)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
SID_LIST_LISTENER2 =
(SID_LIST =
(SID_DESC =
(SID_NAME = yafeishi)
(ORACLE_HOME = e:\oracle\product\10.2.0)
)
)
LISTENER2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1522))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
)
SID_LIST_LISTENER3 =
(SID_LIST =
(SID_DESC =
(SID_NAME = yafeishi)
(ORACLE_HOME = e:\oracle\product\10.2.0)
)
)
LISTENER3 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1523))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))
)
)
上面黑体中的 EXTPROC 是可选的。
tns配置如下:
yafeishi =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = yafeishi)
)
)
yafeishi22 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = yafeishi)
)
)
yafeishi23 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi-PC)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = yafeishi)
)
)
测试效果如下:
先启动监听:
C:\Users\yafeishi>lsnrctl start listener
LSNRCTL for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -2012 10:3
1:26
Copyright (c) 1991, 2006, Oracle. All rights reserved.
启动tnslsnr: 请稍候...
TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Production
系统参数文件为e:\oracle\product\10.2.0\network\admin\listener.ora
写入e:\oracle\product\10.2.0\network\log\listener.log的日志信息
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1521)))
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yafeishi-PC)(PORT=1521)))
LISTENER 的 STATUS
------------------------
别名 listener
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Produ
ction
启动日期 18-9月 -2012 10:31:30
正常运行时间 0 天 0 小时 0 分 4 秒
跟踪级别 off
安全性 ON: Local OS Authentication
SNMP OFF
监听程序参数文件 e:\oracle\product\10.2.0\network\admin\listener.ora
监听程序日志文件 e:\oracle\product\10.2.0\network\log\listener.log
监听端点概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
服务摘要..
服务 "PLSExtProc" 包含 1 个例程。
例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
服务 "yafeishi" 包含 1 个例程。
例程 "yafeishi", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
命令执行成功
C:\Users\yafeishi>lsnrctl start listener2
LSNRCTL for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -2012 10:3
1:36
Copyright (c) 1991, 2006, Oracle. All rights reserved.
启动tnslsnr: 请稍候...
TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Production
系统参数文件为e:\oracle\product\10.2.0\network\admin\listener.ora
写入e:\oracle\product\10.2.0\network\log\listener2.log的日志信息
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1522)))
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yafeishi-PC)(PORT=1522)))
LISTENER 的 STATUS
------------------------
别名 listener2
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Produ
ction
启动日期 18-9月 -2012 10:31:42
正常运行时间 0 天 0 小时 0 分 6 秒
跟踪级别 off
安全性 ON: Local OS Authentication
SNMP OFF
监听程序参数文件 e:\oracle\product\10.2.0\network\admin\listener.ora
监听程序日志文件 e:\oracle\product\10.2.0\network\log\listener2.log
监听端点概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
服务摘要..
服务 "yafeishi" 包含 1 个例程。
例程 "yafeishi", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
命令执行成功
C:\Users\yafeishi>lsnrctl start listener3
LSNRCTL for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -2012 10:3
1:45
Copyright (c) 1991, 2006, Oracle. All rights reserved.
启动tnslsnr: 请稍候...
TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Production
系统参数文件为e:\oracle\product\10.2.0\network\admin\listener.ora
写入e:\oracle\product\10.2.0\network\log\listener3.log的日志信息
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1523)))
监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC2ipc)))
正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yafeishi-PC)(PORT=1523)))
LISTENER 的 STATUS
------------------------
别名 listener3
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.3.0 - Produ
ction
启动日期 18-9月 -2012 10:31:49
正常运行时间 0 天 0 小时 0 分 4 秒
跟踪级别 off
安全性 ON: Local OS Authentication
SNMP OFF
监听程序参数文件 e:\oracle\product\10.2.0\network\admin\listener.ora
监听程序日志文件 e:\oracle\product\10.2.0\network\log\listener3.log
监听端点概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yafeishi-PC)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC2ipc)))
服务摘要..
服务 "yafeishi" 包含 1 个例程。
例程 "yafeishi", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
命令执行成功
C:\Users\yafeishi>
测试监听:
C:\Users\yafeishi>tnsping yafeishi
TNS Ping Utility for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -
2012 10:33:06
Copyright (c) 1997, 2006, Oracle. All rights reserved.
已使用的参数文件:
e:\oracle\product\10.2.0\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi
-PC)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = yafeishi
)))
OK (10 毫秒)
C:\Users\yafeishi>tnsping yafeishi22
TNS Ping Utility for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -
2012 10:33:10
Copyright (c) 1997, 2006, Oracle. All rights reserved.
已使用的参数文件:
e:\oracle\product\10.2.0\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi
-PC)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = yafeishi
)))
OK (10 毫秒)
C:\Users\yafeishi>tnsping yafeishi23
TNS Ping Utility for 32-bit Windows: Version 10.2.0.3.0 - Production on 18-9月 -
2012 10:33:15
Copyright (c) 1997, 2006, Oracle. All rights reserved.
已使用的参数文件:
e:\oracle\product\10.2.0\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yafeishi
-PC)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = yafeishi
)))
OK (20 毫秒)
三个都OK!
如果要体现在不同网卡上,修改listener中 host 即可。
--EOF
原文链接:http://blog.yafeishi.net/2012/09/one-instance-more-listeners.html