TNS-12541: TNS:no listener錯誤處理

wailon發表於2014-05-26

--啟動監聽報錯
[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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章