listener log in rac

最近应客户之邀,给简单答疑解惑了一下:listener.log,listener_nodename.log的问题,大致如下:

在rac的环境下最好使用srvctl工具来管理listener,instance的启动、停止,否则可能引起不必要的问题。单实例、多实例的管理方式还是存在差别的。举个例子:

如果在lsnrctl模式下,贸然的start,stop,想停止和启动监听,而这样不加参数的start,stop是在对缺省的listener操作。而在rac环境,最好使用srvctl start listener -n nodename。否则,启动的监听程序很可能是listener,而不是listener_<nodename>,看如下一段日志。

[oracle@rac1 ~]$ lsnrctl status listener_rac1

LSNRCTL for Linux: Version 10.2.0.5.0 – Production on 01-AUG-2012 22:01:41

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.201.149)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
————————
Alias LISTENER_RAC1
Version TNSLSNR for Linux: Version 10.2.0.5.0 – Production
Start Date 01-AUG-2012 14:48:22
Uptime 0 days 7 hr. 13 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/product/10.2.0/db_1/network/log/listener_rac1.log
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.201.149)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.201.128)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Services Summary…
Service “rac.world” has 2 instance(s).
Instance “rac1”, status READY, has 2 handler(s) for this service…
Instance “rac2”, status READY, has 1 handler(s) for this service…
Service “racXDB.world” has 2 instance(s).
Instance “rac1”, status READY, has 1 handler(s) for this service…
Instance “rac2”, status READY, has 1 handler(s) for this service…
Service “rac_XPT.world” has 2 instance(s).
Instance “rac1”, status READY, has 2 handler(s) for this service…
Instance “rac2”, status READY, has 1 handler(s) for this service…
Service “rsdb.world” has 2 instance(s).
Instance “rac1”, status READY, has 2 handler(s) for this service…
Instance “rac2”, status READY, has 1 handler(s) for this service…
The command completed successfully

加粗、标红的部分注意一下,在rac环境中,监听的日志正常应当写入listener_<nodename>.log中,而不是listener.log中,这也是为什么很多dba会在$ORACLE_HOME/network/admin/log下面发现两个与监听相关的日志信息:listener.log,listener_<nodename>.log,而且两个日志的时间标签、内容都会让dba觉得疑惑。(到底tmd用了哪个日志记录东西?)

写入listener.log的原因有可能是:在cmd下面”lsnrctl start”这样启动的监听,后没有加任何的参数,这样启动的监听是default的那个listener。

一个简单的测试案例:

在一个节点,使用”srvctl stop listener”来正常关闭监听,在cmd下面使用”lsnrctl start”不加任何参数来启动”监听”,”crs_stat -t”查询你会发现在crs上面是offline的,crs根本没有理会你这样的”单独”行动。当然,”lsnrctl start listener_<nodename>”,crs会帮你将监听的状态注册到crs中,处于online状态。

[oracle@rac1 ~]$ srvctl stop listener -n rac1

//srvctl来停止监听,然后查看状态
[oracle@rac1 ~]$ crs_stat -t
Name Type Target State Host
————————————————————
ora.rac.db application ONLINE ONLINE rac2
ora….c1.inst application ONLINE ONLINE rac1
ora….c2.inst application ONLINE ONLINE rac2
ora….rsdb.cs application ONLINE ONLINE rac1
ora….ac1.srv application ONLINE ONLINE rac1
ora….ac2.srv application ONLINE ONLINE rac2
ora….C1.lsnr application OFFLINE OFFLINE
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora….C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[oracle@rac1 ~]$ lsnrctl start

//单实例思维管理模式,启动监听。监听日志记录到缺省的listener.log里面了,这说明你起错了。。把缺省的监听给起来了

LSNRCTL for Linux: Version 10.2.0.5.0 – Production on 01-AUG-2012 22:10:22

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Starting /opt/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait…

TNSLSNR for Linux: Version 10.2.0.5.0 – Production
System parameter file is /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /opt/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.localdomain)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.5.0 – Production
Start Date 01-AUG-2012 22:10:22
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully

//再查看crs中监听程序的状态
[oracle@rac1 ~]$ crs_stat -t
Name Type Target State Host
————————————————————
ora.rac.db application ONLINE ONLINE rac2
ora….c1.inst application ONLINE ONLINE rac1
ora….c2.inst application ONLINE ONLINE rac2
ora….rsdb.cs application ONLINE ONLINE rac1
ora….ac1.srv application ONLINE ONLINE rac1
ora….ac2.srv application ONLINE ONLINE rac2
ora….C1.lsnr application OFFLINE OFFLINE
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora….C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
—————————————————————————————————————————

所以:RAC的管理最好使用官方建议的srvctl,而不是单实例下的各种蛮干。

–EOF–