以上listener.ora配置文件中的信息是Grid Infrastructure安装过程中Agent自行添加的(Duringthe Grid Infrastructure installation, the (default) node VIP listener is always created referencing the
public network),比较难以理解的可能是LISTENER仅指定了PROTOCOL=IPC的信息, 而
没有指定监听的地址、端口等信息。
2. About Me
l Email & Gtalk:liu.maclean@gmail.com
l Blog:www.oracledatabase12g.com
l QQ:47079569 QQ Group:23549328
l Oracle Certified Database Administrator Master 10g
and 11g
l Over 6 years experience with Oracle DBA technology
l Over 7 years experience with Linux technology
l Member Independent Oracle Users Group
l Member All China Oracle Users Group
l Presents for advanced Oracle topics: RAC,
DataGuard, Performance Tuning and Oracle Internal.
4. 之前有同学想要给 11gR2 的 RAC 添加 LISTENER 监听器,查看了 listener.ora 并发现问题:
[oracle@vrh2 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-DEC-2011 02:51:40
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 02-DEC-2011 05:40:09
Uptime 1 days 21 hr. 11 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File /g01/orabase/diag/tnslsnr/vrh2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.163)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.164)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "VPROD" has 1 instance(s).
Instance "VPROD2", status READY, has 1 handler(s) for this service...
Service "VPRODXDB" has 1 instance(s).
Instance "VPROD2", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@vrh2 ~]$ cat /g01/11.2.0/grid/network/admin/listener.ora
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)
(KEY=LISTENER_SCAN1)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) #
line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LSN_MACLEAN=ON # line added by Agent
以上 listener.ora 配置文件中的信息是 Grid Infrastructure 安装过程中 Agent 自行添加的(During
the Grid Infrastructure installation, the (default) node VIP listener is always created referencing the
public network),比较难以理解的可能是 LISTENER 仅指定了 PROTOCOL=IPC 的信息, 而
没有指定监听的地址、端口等信息。
5. 实际上 11.2 GI 的 LISTENER 监听器配置默认受到 11.2 新引入的 endpoints_listener.ora 配置文
件的管理:
Listener.ora
[grid@netrac1 admin]$ more listener.ora
LISTENER_SCAN2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)
(KEY=LISTENER_SCAN2)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))#
line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)
(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2=ON # line added by Agent
The ENABLE_GLOBAL_DYNAMIC_ENDPOINT_ parameter is set to allow the listener to
accept connections
for pre-11.2 databases which did not register the dynamic endpoint.
Listener status "listener" showing 1 instance registered, ie instance running on
the node
[grid@netrac1 admin]$ lsnrctl status listener
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 15-FEB-2011 10:57:09
Uptime 0 days 0 hr. 0 min. 46 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/netrac1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12.345.678.111)(PORT=1521))) ** Node
IP Address **
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12.345.678.888)(PORT=1521))) ** Node
VIP Address **
Services Summary...
Service "v11gr2" has 1 instance(s).
Instance "v11gr21", status READY, has 2 handler(s) for this service...
The command completed successfully
New file for 11.2 called endpoints_listener.ora, showing the Node IP address and
Node VIP address.
[grid@netrac1 admin]$ more endpoints_listener.ora
LISTENER_NETRAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=netrac1-vip)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=12.345.678.888)(PORT=1521)(IP=FIRST)))) # line
added by Agent
Endpoints_listener.ora file is there for backward compatibility with pre-11.2
6. databases.
DBCA needs to know the endpoints location to configure database parameters and
tnsnames.ora file.
It used to use the listener.ora file, 11.2 RAC listener.ora by default only has
IPC entries.
"Line added by Agent" is the Oraagent is the process updating the listener.ora
and endpoints_listener.ora files.
Endpoints_listener.ora showing the Node IP address and Node VIP address
[grid@netrac2 admin]$ more endpoints_listener.ora
LISTENER_NETRAC2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=netrac2-vip)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=12.345.678.999) (PORT=1521)(IP=FIRST)))) # line
added by Agent
我一开始以为 LISTENER 默认监听的地址和端口被写到了 OCR 中,后来用 ocrdump 转储注
册信息发现没有相关记录。 后来才发现原来 11.2 GI 中监听器的地址和端口信息被移到了
endpoints_listener.ora 中, “Line added by Agent”说明是由 Oraagent 进程更新的记录。
注意:使用 endpoints_listener.ora 的情况 下不应使用 lsnrctl 管理 LISTENER,而需使用 srvctl
或 crsctl 工具管理,否则 lsnrctl 将不会识别 endpoints_listener.ora 中的信息,造成监听没有在
必要地址、端口上工作。如:
[grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:26
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN)))
STATUS of the LISTENER
------------------------
Alias LSN_MACLEAN
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 26-NOV-2011 08:33:14
Uptime 1 days 2 hr. 12 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File
/g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LSN_MACLEAN)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1588)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1588)))
Services Summary...
Service "VPROD" has 1 instance(s).
Instance "VPROD1", status READY, has 1 handler(s) for this service...
Service "VPRODXDB" has 1 instance(s).
7. Instance "VPROD1", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@vrh1 admin]$ lsnrctl reload LSN_MACLEAN
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:39
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN)))
The command completed successfully
[grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:45:44
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN)))
STATUS of the LISTENER
------------------------
Alias LSN_MACLEAN
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 26-NOV-2011 08:33:14
Uptime 1 days 2 hr. 12 min. 30 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File
/g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LSN_MACLEAN)))
The listener supports no services
The command completed successfully
[grid@vrh1 admin]$ srvctl stop listener -l LSN_MACLEAN
[grid@vrh1 admin]$ srvctl start listener -l LSN_MACLEAN
[grid@vrh1 admin]$ lsnrctl status LSN_MACLEAN
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 10:46:26
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LSN_MACLEAN)))
STATUS of the LISTENER
------------------------
Alias LSN_MACLEAN
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 27-NOV-2011 10:46:22
Uptime 0 days 0 hr. 0 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File
/g01/orabase/diag/tnslsnr/vrh1/lsn_maclean/alert/log.xml
Listening Endpoints Summary...
14. 填入 Global Database Name 和本地实例的 SID 信息,并确认 ORACLE HOME Directory(应是
Grid Infrastructure 的 Home 目录)正确后点选 Save Network Configuration。
之后使用 srvctl 或 crsctl 重启该监听即可生效:
[grid@vrh1 admin]$ crsctl status res ora.MACLEAN_LISTENER.lsnr
NAME=ora.MACLEAN_LISTENER.lsnr
TYPE=ora.listener.type
TARGET=ONLINE , ONLINE
STATE=ONLINE on vrh1, ONLINE on vrh2
15. [grid@vrh1 admin]$ crsctl stop res ora.MACLEAN_LISTENER.lsnr
CRS-2673: Attempting to stop 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1'
CRS-2673: Attempting to stop 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2'
CRS-2677: Stop of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' succeeded
CRS-2677: Stop of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' succeeded
[grid@vrh1 admin]$ crsctl start res ora.MACLEAN_LISTENER.lsnr
CRS-2672: Attempting to start 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2'
CRS-2672: Attempting to start 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1'
CRS-2676: Start of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh1' succeeded
CRS-2676: Start of 'ora.MACLEAN_LISTENER.lsnr' on 'vrh2' succeeded
[grid@vrh1 admin]$ lsnrctl status MACLEAN_LISTENER
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:00:42
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MACLEAN_LISTENER)))
STATUS of the LISTENER
------------------------
Alias MACLEAN_LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 27-NOV-2011 11:00:11
Uptime 0 days 0 hr. 0 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File
/g01/orabase/diag/tnslsnr/vrh1/maclean_listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MACLEAN_LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1598)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1598)))
Services Summary...
Service "VPROD" has 1 instance(s).
Instance "VPROD1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[grid@vrh1 admin]$ srvctl stop listener -l MACLEAN_LISTENER
[grid@vrh1 admin]$ srvctl start listener -l MACLEAN_LISTENER
[grid@vrh1 admin]$ srvctl config listener -l MACLEAN_LISTENER
Name: MACLEAN_LISTENER
Network: 1, Owner: grid
Home:
End points: TCP:1598
[grid@vrh1 admin]$ lsnrctl status MACLEAN_LISTENER
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:01:42
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=MACLEAN_LISTENER)))
STATUS of the LISTENER
------------------------
Alias MACLEAN_LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 27-NOV-2011 11:01:10
16. Uptime 0 days 0 hr. 0 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/11.2.0/grid/network/admin/listener.ora
Listener Log File
/g01/orabase/diag/tnslsnr/vrh1/maclean_listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=MACLEAN_LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.161)(PORT=1598)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.162)(PORT=1598)))
Services Summary...
Service "VPROD" has 1 instance(s).
Instance "VPROD1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
以上使用 netca 和 netmgr 图形界面工具完成了新监听的添加和静态注册工作。
2. 使用 srvctl 工具添加监听并手动加入静态注册信息
检查默认 network 的 network number,红色的数字
[grid@vrh1 admin]$ srvctl config network
Network exists: 1/192.168.1.0/255.255.255.0/eth0, type static
srvctl 添加监听的语法如下
[grid@vrh1 admin]$ srvctl add listener -h
Adds a listener configuration to the Oracle Clusterware.
Usage: srvctl add listener [-l <lsnr_name>] [-s] [-p "[TCP:]<port>[, ...]
[/IPC:<key>]
[/NMP:<pipe_name>][/TCPS:<s_port>] [/SDP:<port>]"] [-o <oracle_home>] [-k
<net_num>]
-l <lsnr_name> Listener name (default name is LISTENER)
-o <oracle_home> ORACLE_HOME path (default value is CRS_HOME)
-k <net_num> network number (default number is 1)
-s Skip the checking of ports
-p "[TCP:]<port>[, ...][/IPC:<key>][/NMP:<pipe_name>][/TCPS:<s_port>]
[/SDP:<port>]"
Comma separated tcp ports or listener endpoints
-h Print usage
[grid@vrh1 admin]$ srvctl add listener -l NEW_MACLEAN_LISTENER -o $CRS_HOME -p
1601 -k 1
-k 填入方才获得的 network number,-p 填入端口号,-l 填入监听名,-o 填入 GI HOME 路径
[grid@vrh1 admin]$ srvctl start listener -l NEW_MACLEAN_LISTENER
17. srvctl start listener 启动新添加的监听后 listener.ora 和 endpoints_listener.ora 会出现新的记录:
[grid@vrh1 admin]$ head -1 listener.ora
NEW_MACLEAN_LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)
(KEY=NEW_MACLEAN_LISTENER))))
# line added by Agent
[grid@vrh1 admin]$ head -1 endpoints_listener.ora
NEW_MACLEAN_LISTENER_VRH1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=vrh1-vip)(PORT=1601))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.161)(PORT=1601)(IP=FIRST))))
# line added by Agent
以上已经完成了监听的添加,足见使用 srvctl 管理更为简便。
之后仅需要加入静态注册信息即可,如:
SID_LIST_NEW_MACLEAN_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = VPROD)
(ORACLE_HOME = /g01/11.2.0/grid)
(SID_NAME = VPROD1)
)
)
加入如上信息到 listener.ora 配置文件中(SID_LIST_($LISTENER_NAME),并重启监听即完
成静态注册:
[grid@vrh1 admin]$ srvctl stop listener -l NEW_MACLEAN_LISTENER
[grid@vrh1 admin]$ srvctl start listener -l NEW_MACLEAN_LISTENER
[grid@vrh1 admin]$ lsnrctl status NEW_MACLEAN_LISTENER
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 27-NOV-2011 11:21:37
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=NEW_MACLEAN_LISTENER)))
STATUS of the LISTENER
------------------------