ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【故障处理】【LISTENER】主机名修改为IP地址后LISTENER无法监听到实例

【故障处理】【LISTENER】主机名修改为IP地址后LISTENER无法监听到实例

原创 Linux操作系统 作者:secooler 时间:2009-07-21 15:22:41 0 删除 编辑
1.【环境信息】
操作系统
ora10g@testdb /home/oracle$ uname -a
Linux testdb 2.6.18-53.el5xen #1 SMP Wed Oct 10 16:48:44 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
数据库
sys@ora10g> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

2.【问题现象】
一句话描述:将listener.ora和tnsnames.ora文件中的HOST信息从原来的主机名字修改为IP地址后,监听可以启动,但是无论如何也监听不到数据库实例的信息(即使反复重启数据库)。

问题展开描述:
修改前的listener.ora内容如下:
ora10g@testdb /oracle/app/oracle/product/10.2.0/db_1/network/admin$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/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 = /oracle/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

修改后的listener.ora内容如下:
ora10g@testdb /oracle/app/oracle/product/10.2.0/db_1/network/admin$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/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 = /oracle/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 144.194.192.183)(PORT = 1521)(IP = FIRST))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

对应的tnsnames.ora文件中也同样的将主机名testdb修改为IP地址144.194.192.183。

修改后重新启动监听,但是监听一直保持在如下的状态
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 14:34:20
Uptime                    0 days 0 hr. 0 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

就是监听不到对应的数据库实例信息!!!!!

3.【问题原因】
罪魁祸首在/etc/hosts文件!!
先看一下在我处理之前该文件的内容:
[root@testdb ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1   testdb  localhost.localdomain   localhost
::1     localhost6.localdomain6 localhost6

先提示到这里,停一停,想一想,这到底是为什么呢?如果您也遇到了这个问题,处理思路是什么呢?

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

思考ing ……

好了,不卖关子了,问题出在,在这种默认配置下(操作系统安装后的状态),主机名字和本机的IP地址没有对应起来.
换一种好理解的方式讲,在这种情况下如果您ping主机名testdb的话:
ora10g@testdb /home/oracle$ ping testdb
PING testdb (127.0.0.1) 56(84) bytes of data.
64 bytes from testdb (127.0.0.1): icmp_seq=1 ttl=64 time=0.076 ms
64 bytes from testdb (127.0.0.1): icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from testdb (127.0.0.1): icmp_seq=3 ttl=64 time=0.053 ms

结果是主机名testdb直接对应到了127.0.0.1地址,没有对应到正确的144.194.192.183地址!!

4.【问题解决】
(1)将/etc/hosts内容修改为:
[root@testdb ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
::1     localhost6.localdomain6 localhost6
144.194.192.183   testdb

比较一下与之前文件的不同,这里修改的内容如下:
1)将127.0.0.1后面的testdb主机名删除
2)添加IP地址和主机名对应关系144.194.192.183   testdb

通过ping主机名testdb的方式验证一下修改后的效果:
ora10g@testdb /home/oracle$ ping testdb
PING testdb (144.194.192.183) 56(84) bytes of data.
64 bytes from testdb (144.194.192.183): icmp_seq=1 ttl=64 time=0.082 ms
64 bytes from testdb (144.194.192.183): icmp_seq=2 ttl=64 time=0.047 ms
64 bytes from testdb (144.194.192.183): icmp_seq=3 ttl=64 time=0.050 ms
到此,主机名testdb与IP地址
144.194.192.183建立起了对应关系。

(2)重新启动监听
LSNRCTL> stop
LSNRCTL> start
Starting /oracle/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 15:05:08
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>

过大概半分钟的样子,LISTENER即可监听到数据库的实例ora10g:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=144.194.192.183)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                21-JUL-2009 15:05:08
Uptime                    0 days 0 hr. 0 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=144.194.192.183)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
Service "ora10g_XPT" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
The command completed successfully

5.总结
数据库的任何修改都是存在风险的,即使您“觉得”没有问题,永远记得“墨菲定律”--Anything that can go wrong will go wrong!
(1)任何事都没有表面看起来那么简单;
(2)所有的事都会比你预计的时间长;
(3)会出错的事总会出错;
(4)如果你担心某种情况发生,那么它就更有可能发生。
所以,在做任何事情之前都要充分的测试,否则就有可能被“墨菲”到!

-- The End --

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-609799/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE 总监,阿里云MVP,北京大学理学硕士,恩墨学院创始人,教育专家,中国区 Cloudera 首位官方授权大数据讲师,金牌培训专家,BDA大数据联盟创始人,OCM联盟创始人,ACCUG创始人、ACOUG核心专家,Blogger。

注册时间:2008-03-16

  • 博文量
    797
  • 访问量
    7977524