ITPub博客

首页 > 数据库 > Oracle > TNS-12541: TNS:no listener错误处理

TNS-12541: TNS:no listener错误处理

原创 Oracle 作者:wailon 时间:2014-05-26 17:39:56 0 删除 编辑

--启动监听报错
[oracle@rhel5 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 05:31:02
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

--检查监听文件,发现没有;其实没有监听文件也可以正常启动才对
[oracle@rhel5 ~]$ cd $ORACLE_HOME/network/admin
[oracle@rhel5 admin]$ ls
samples  shrept.lst  sqlnet.log  tnsnames.ora

--创建监听文件,并配置静态监听
[oracle@rhel5 admin]$ vi listener.ora 
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521))
      ))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=wailon)
      (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME=wailon))
   )


[oracle@rhel5 admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.log  tnsnames.ora

--启动监听仍然报错
[oracle@rhel5 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 05:31:02
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

--根据错误代码,检查对应的文件及内容,都没有发现任何问题
[oracle@rhel5 ~]$ oerr tns 12541
12541, 00000, "TNS:no listener"
// *Cause: The connection request could not be completed because the listener
// is not running.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry with
// the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to
// go by way of an Interchange). Start the listener on the remote machine.

--由此怀疑可能是网卡或网络环境配置的问题引起
[oracle@rhel5 ~]$ oerr tns 12560
12560, 00000, "TNS:protocol adapter error"
// *Cause: A generic protocol adapter error occurred.
// *Action: Check addresses used for proper protocol specification. Before
// reporting this error, look at the error stack and check for lower level
// transport errors. For further details, turn on tracing and reexecute the
// operation. Turn off tracing when the operation is complete.

[oracle@rhel5 ~]$ oerr tns 511
00511, 00000, "No listener"
// *Cause: The connect request could not be completed because no application
// is listening on the address specified, or the application is unable to
// service the connect request in a sufficiently timely manner.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry with
// appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to go
// by way of an Interchange. Start the listener on the remote machine.

[oracle@rhel5 admin]$ exit
logout

--后来在网上搜索,有可能是hosts文件的127.0.0.1未配置
--查看hosts文件配置,发现127.0.0.1被注释掉

[root@rhel5 ~]# 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
192.168.56.102  rhel5

--修改hosts文件如下
[root@rhel5 ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
192.168.56.102  rhel5
~
~
"/etc/hosts" 5L, 208C written

--再次启动监听,发现可以正常启动

[oracle@rhel5 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 05:53:31
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Starting /u01/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 /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                06-SEP-2013 05:53:31
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
Services Summary...
Service "wailon" has 1 instance(s).
  Instance "wailon", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

--过一分钟左右,动态监听也注册成功

[oracle@rhel5 ~]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 06:04:45
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                06-SEP-2013 05:53:31
Uptime                    0 days 0 hr. 11 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
Services Summary...
Service "wailon" has 2 instance(s).
  Instance "wailon", status UNKNOWN, has 1 handler(s) for this service...
  Instance "wailon", status READY, has 1 handler(s) for this service...
Service "wailon_XPT" has 1 instance(s).
  Instance "wailon", status READY, has 1 handler(s) for this service...
The command completed successfully

--删掉监听配置文件,重启监听,监听也正常

[oracle@rhel5 ~]$ cd $ORACLE_HOME/network/admin
[oracle@rhel5 admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.log  tnsnames.ora
[oracle@rhel5 admin]$ rm listener.ora 
[oracle@rhel5 admin]$ ls
samples  shrept.lst  sqlnet.log  tnsnames.ora
[oracle@rhel5 admin]$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 06:06:39
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
[oracle@rhel5 admin]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 06:06:49
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(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                06-SEP-2013 06:06:49
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
The listener supports no services
The command completed successfully

[oracle@rhel5 admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 06-SEP-2013 06:07:55
Copyright (c) 1991, 2010, Oracle.  All rights reserved.

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                06-SEP-2013 06:06:49
Uptime                    0 days 0 hr. 1 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rhel5)(PORT=1521)))
Services Summary...
Service "wailon" has 1 instance(s).
  Instance "wailon", status READY, has 1 handler(s) for this service...
Service "wailon_XPT" has 1 instance(s).
  Instance "wailon", status READY, has 1 handler(s) for this service...
The command completed successfully

所以系统环境及配置真的很重要,每一步都要检查清楚,并且在安装文档说明。

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

请登录后发表评论 登录
全部评论

注册时间:2013-11-08

  • 博文量
    51
  • 访问量
    291503