[Oracle工程师手记]解决listener 的 TNS-12545 错误


现象: 执行 lsnrctl start 来启动 listener,却失败了。

$ lsnrctl stat

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 09-APR-2021 23:45:02

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hst15574.mytst.com)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory
$

 

$ lsnrctl start

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 09-APR-2021 23:45:08

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

Starting /refresh/home/app/oracle/product/19.3.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
Log messages written to /refresh/home/app/oracle/diag/tnslsnr/hst06027/listener/alert/log.xml
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hst15574.mytst.com)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
 TNS-12560: TNS:protocol adapter error
  TNS-00515: Connect failed because target host or object does not exist
   Linux Error: 99: Cannot assign requested address

Listener failed to start. See the error message(s) above...

 检查 host 文件,没有发现有什么问题。

$
$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
$

 
再看 listener.ora 文件:

[oracle@hst06027 admin]$ cat /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
# listener.ora Network Configuration File: /refresh/home/app/oracle/product/19.9.0/network/admin
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hst15574.mytst.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

 

再看hostname 的结果:

[oracle@hst06027 admin]$ cat /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
# listener.ora Network Configuration File: /refresh/home/app/oracle/product/19.9.0/network/admin
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hst15574.mytst.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )


由于曾经改变了主机名,所以,listener.ora 中的主机名和 hostname 中的名字不同,导致无法运行listener。需要编辑修改 listener.ora :

$ vi /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora

 
确认:

$ cat /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
# listener.ora Network Configuration File: /refresh/home/app/oracle/product/19.9.0/network/admin
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hst06027.mytst.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

 

再次启动,发现可以成功了。

[oracle@hst06027 admin]$ lsnrctl start

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 09-APR-2021 23:49:25

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

Starting /refresh/home/app/oracle/product/19.3.0/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
Log messages written to /refresh/home/app/oracle/diag/tnslsnr/hst06027/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hst06027.mytst.com)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hst06027.mytst.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                09-APR-2021 23:49:26
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
Listener Log File         /refresh/home/app/oracle/diag/tnslsnr/hst06027/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hst06027.mytst.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

 
等待两三分钟,确认 listener 的状态:

[oracle@hst06027 admin]$ lsnrctl stat

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 09-APR-2021 23:51:26

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hst06027.mytst.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                09-APR-2021 23:49:26
Uptime                    0 days 0 hr. 2 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /refresh/home/app/oracle/product/19.9.0/network/admin/listener.ora
Listener Log File         /refresh/home/app/oracle/diag/tnslsnr/hst06027/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hst06027.mytst.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
  Instance "db193cdb", status READY, has 1 handler(s) for this service...
Service "appcon1" has 1 instance(s).
  Instance "db193cdb", status READY, has 1 handler(s) for this service...
Service "apppdb1" has 1 instance(s).
  Instance "db193cdb", status READY, has 1 handler(s) for this service...
Service "apppdb2" has 1 instance(s).
  Instance "db193cdb", status READY, has 1 handler(s) for this service...

 

posted @ 2021-04-10 07:53  健哥的数据花园  阅读(378)  评论(0编辑  收藏  举报