Oracle RAC 监听配置 (listener.ora tnsnames.ora)
Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的。在Oracle中 tns进程用于为指定网络地址上的一个或多
Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的。在Oracle中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务提出的连接请求。一旦连接请求到达,并派生出一个服务器进程建立服务器与用户端之间的连接(专有服务器dedicated server)或转发服务请求(共享服务器模式shared server)。如果监听器知道多于一个实例提供所请求的服务,则可能会根据客户端与服务器端相关配置将请求定位到较低负载的实例为其提供服务。因此合理正确配置监听器以及tnsnames是Oracle RAC实现负载均衡以及failover的前提,本文将描述基于 SUSE linux 10 + Oracle 10g RAC 下监听器的配置。
一、节点上监听信息
1、两个节点及主机配置信息(bo2dbp,,bo2dbs)
oracle@bo2dbp:/u01/oracle/db/network/admin> cat /etc/hosts
127.0.0.1 localhost.2gotrade.com localhost
# Public
192.168.7.51 bo2dbp.2gotrade.com bo2dbp
192.168.7.52 bo2dbs.2gotrade.com bo2dbs
#Private
10.10.7.51 bo2dbp-priv.2gotrade.com bo2dbp-priv
10.10.7.52 bo2dbs-priv.2gotrade.com bo2dbs-priv
#Virtual
192.168.7.61 bo2dbp-vip.2gotrade.com bo2dbp-vip
192.168.7.62 bo2dbs-vip.2gotrade.com bo2dbs-vip
2、节点bo2dbp上的listener.ora
oracle@bo2dbp:/u01/oracle/db/network/admin> more listener.ora
# listener.ora.bo2dbp Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbp
# Generated by Oracle configuration tools.
LISTENER_BO2DBP =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbp-vip.2gotrade.com)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.51)(PORT = 1521)(IP = FIRST))
)
)
SID_LIST_LISTENER_BO2DBP =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/db)
(PROGRAM = extproc)
)
)
3、节点bo2dbp上的tnsnames.ora
oracle@bo2dbp:/u01/oracle/db/network/admin> more tnsnames.ora
#对于连接字符串GOBO1A,GOBO1B,GOBO1在此处可以省略
#这些字符串通常用于客户端连接到数据库
GOBO1B =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GOBO1)
(INSTANCE_NAME = GOBO1B)
)
)
GOBO1A =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GOBO1)
(INSTANCE_NAME = GOBO1A)
)
)
GOBO1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GOBO1)
)
)
#下面是几个重要的用于设置local_listener 以及remote_listener参数的定义信息
LISTENER_BO2DB =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
)
LISTENER_BO2DBP =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
)
LISTENER_BO2DBS =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
)
#Author: Robinson cheng
#Blog :
4、节点bo2dbp上监听器的信息
#可以看出只有实例 GOBO1A 注册到监听器 LISTENER_BO2DBP
oracle@bo2dbp:/u01/oracle/db/network/admin> lsnrctl status LISTENER_BO2DBP
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 25-SEP-2012 17:12:04
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bo2dbp-vip.2gotrade.com)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
..............
Listener Parameter File /u01/oracle/db/network/admin/listener.ora
Listener Log File /u01/oracle/db/network/log/listener_bo2dbp.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.61)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.51)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "GOBO1" has 1 instance(s).
Instance "GOBO1A", status READY, has 1 handler(s) for this service...
Service "GOBO1XDB" has 1 instance(s).
Instance "GOBO1A", status READY, has 1 handler(s) for this service...
Service "GOBO1_XPT" has 1 instance(s).
Instance "GOBO1A", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
5、节点bo2dbs上的listener.ora
oracle@bo2dbs:/u01/oracle/db/network/admin> more listener.ora
# listener.ora.bo2dbs Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbs
# Generated by Oracle configuration tools.
LISTENER_BO2DBS =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbs-vip.2gotrade.com)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.52)(PORT = 1521)(IP = FIRST))
)
)
SID_LIST_LISTENER_BO2DBS =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/db)
(PROGRAM = extproc)
)
)
#由于节点bo2dbs上的tnsnames.ora与节点bo2dbp内容相同,不再列出
6、节点bo2dbs上的监听器状态
#同样可以看到只有一个 instance,即GOBO1B注册到了监听器 LISTENER_BO2DBS
oracle@bo2dbs:/u01/oracle/db/network/admin> lsnrctl status LISTENER_BO2DBS
LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 25-SEP-2012 17:12:31
Copyright (c) 1991, 2006, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bo2dbs-vip.2gotrade.com)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
.......................
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.62)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.52)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service...
Service "GOBO1" has 1 instance(s).
Instance "GOBO1B", status READY, has 1 handler(s) for this service...
Service "GOBO1XDB" has 1 instance(s).
Instance "GOBO1B", status READY, has 1 handler(s) for this service...
Service "GOBO1_XPT" has 1 instance(s).
Instance "GOBO1B", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
#通过上面的观察可知,当前的两个实例都是在各自所在主机上的监听器进行了注册。