代码编织梦想

项目场景:

oracle 11gR2 数据库,在某次重启后维护人员手动添加了listener.ora文件,在启动监听后,发现没有监听的实例。命令显示如下:

[oracle@233-szsjdatabase-backup admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:29:44

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                08-JUN-2022 14:18:52
Uptime                    0 days 0 hr. 10 min. 51 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
The listener supports no services
The command completed successfully

无论等多久,都是看不到监听的实例的。  但1521端口是打开的,看下这时监听文件的配置:

[oracle@233-szsjdatabase-backup admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/app/oracle

由于localhost对应的是127.0.0.1,所以看到的监听端口如下:

[oracle@233-szsjdatabase-backup admin]$ netstat -an | grep 1521
tcp        0      0 127.0.0.1:1521          0.0.0.0:*               LISTEN

既然只在127.0.0.1 上监听1521,那么外部的客户端和业务系统是无法访问数据库的。



原因分析:

     正常情况下,数据库会采用动态监听,也就是无需手动配置listener.ora这个文件。

      如果是静态监听,才需要对这个文件进行配置,但host不能是localhost。


解决方案:

提示:这里填写该问题的具体解决方案:

(1)采用动态监听。

1. 删除$ORACLE_HOME/network/admin目录下的listener.ora文件,或者改成其它文件名。

2. 重启监听,如果报错,杀掉监听进程,然后重启监听。

[oracle@233-szsjdatabase-backup admin]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:54:53

Copyright (c) 1991, 2013, 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@233-szsjdatabase-backup admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:54:55

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

Starting /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Error listening on: (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12542: TNS:address already in use
 TNS-12560: TNS:protocol adapter error
  TNS-00512: Address already in use
   Linux Error: 98: Address already in use

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

[oracle@233-szsjdatabase-backup admin]$ ps -ef | grep tnsl
oracle   14651     1  0 14:18 ?        00:00:00 /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr LISTENER -inherit
oracle   28028 13418  0 14:55 pts/2    00:00:00 grep --color=auto tnsl
[oracle@233-szsjdatabase-backup admin]$ kill -9 14651
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:55:20

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

Starting /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                08-JUN-2022 14:55:20
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/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@233-szsjdatabase-backup admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:55:24

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                08-JUN-2022 14:55:20
Uptime                    0 days 0 hr. 0 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))
The listener supports no services
The command completed successfully

动态监听启动时稍慢一些,等待60秒左右再查看状态既可看到动态监听实例了。(急性子可以执行下alter system register命令)

[oracle@233-szsjdatabase-backup admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 14:57:58

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                08-JUN-2022 14:57:00
Uptime                    0 days 0 hr. 0 min. 57 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))
Services Summary...
Service "hrmis" has 1 instance(s).
  Instance "hrmis", status READY, has 1 handler(s) for this service...
Service "hrmisXDB" has 1 instance(s).
  Instance "hrmis", status READY, has 1 handler(s) for this service...
The command completed successfully

(2)采用静态监听。

修改listener.ora文件,参考官网的示例。

SID_LIST_listener=
(SID_LIST=
 (SID_DESC=
  (GLOBAL_DBNAME=sales.us.example.com)
  (SID_NAME=sales)
  (ORACLE_HOME=/u01/app/oracle/11g)))
[oracle@233-szsjdatabase-backup admin]$ vi listener.ora
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 15:20:57

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 08-JUN-2022 15:21:03

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

Starting /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                08-JUN-2022 15:21:03
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/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/233-szsjdatabase-backup/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=233-SZSJDatabase-backup.cviclocal)(PORT=1521)))
Services Summary...
Service "hrmis" has 1 instance(s).
  Instance "hrmis", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@233-szsjdatabase-backup admin]$
[oracle@233-szsjdatabase-backup admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

#LISTENER =
#  (DESCRIPTION =
#    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
#  )


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = hrmis)
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/db_1)
      (SID_NAME = hrmis)
    )
  )


ADR_BASE_LISTENER = /u01/app/oracle

注意上面的监听文件中将LISTEN=部分注释掉了,里面监听host地址是localhost,会造成只在127.0.0.1地址监听的问题。注释后静态监听是在0.0.0.0监听。

等待几分钟后可以看到,静态和动态监听是可以共存的。

取消动态监听的办法:在listener.ora文件中加入DYNAMIC_REGISTRATION_LISTENER = off

,然后重启监听。

总结:

1. 动态监听

 (1)network/admin目录中 删除或改名listener.ora文件

 (2)alter system register

 

2. 静态监听

(1)配置network/admin目录中的listener.ora文件,加入下面两句

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = hrmis)
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/db_1)
      (SID_NAME = inst_name)
    )
  )

DYNAMIC_REGISTRATION_LISTENER = off

(2) 重启监听

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/thinklog2018/article/details/125183951

oracle 动态监听和静态监听非1521端口配置_moscot_wu的博客-爱代码爱编程

硬核配置方法, 动态监听配置默认的1521不做演示 动态注册非1521端口,需要配置三个地方listener.ora、tnsname.ora、local_listener. listener.ora配置 LISTENER = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = l

oracle动态注册和静态注册,Oracle监听器的静态注册与动态注册-爱代码爱编程

在运行lsnrctl命令的status时,常会看到如下返回值: 服务“test”包含1个例程。 例程"mydata",状态 UNKOWN,包含此服务的一个处理程序。。。 服务"a"包含1个例程。 例程"mydata",状态 READY,包含此服务的一个处理程序。。。这里的,状态UNKOWN即表明为静态注册(手动填写参数); 状态为READY的

oracle动态监听如何配置,同时配置动态监听与静态监听-爱代码爱编程

再次同时配置动态监听与静态监听: oracle机ORA11GR2库:192.168.2.4 enmo机PROD库:192.168.2.6 ----oracle机ORA11GR2库:192.168.2.4 --数据库的service name: SQL> show parameter service NAME              

oracle 动态监听例子,oracle动态监听和静态监听的区别-爱代码爱编程

一、什么是注册 注册就是将数据库作为一个服务注册到监听程序。 客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名就可以申请连接到数据库。 这个服务名可能与实例名一样,也有可能不一样。 在数据库服务器启动过程中,数据库服务器会向监听程序注册相应的服务(无论何时启动一个数据库,默认地都有两条信息注册到监听器中:数据库服务器对应的实

oracle静态监听block,动态监听和静态监听-爱代码爱编程

[oracle@node1 admin]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-APR-2014 12:33:04 Copyright (c) 1991, 2009, Oracle.  All rights reserved. Connec

oracle注册静态监听,Oracle监听的静态注册和动态注册-爱代码爱编程

Oracle监听的静态注册和动态注册 发布时间:2020-08-11 09:53:49 来源:ITPUB博客 阅读:99 作者:张冲andy 静态注册:通过解析listene.ora文件 动态注册:由PMON进程动态注册至监听中 在没有listener.ora配置文件的情况下,如果启动监听,则监听为动态注册。用图形化netca创建的监听,

oracle监听 注册,oracle监听的动态注册和静态注册-爱代码爱编程

参考资料: 现象1: 1、动态注册 参数文件中指定service_names(多个服务名vmdb,sn01,sn02),8i以后数据库实例启动后,会根据参数文件的service_names以及instance_name动态注册到监听器: 1 SQL>show parameter service_names;2 3 NAME TYPE V

oracle为什么使用静态监听,Oracle静态监听与动态监听-爱代码爱编程

原文在此:http://blog.chinaunix.net/uid-11570547-id-58976.html oracle静态监听和动态监听 一、什么是注册? 注册就是将数据库作为一个服务注册到监听程序。客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名 就可以申请连接到数据库。这个服务名可能与实例名一样,也有可能不一样

oracle什么是动态监听,静态监听与动态监听区别-爱代码爱编程

oracle静态监听和动态监听 一、什么是注册? 注册就是将数据库作为一个服务注册到监听程序。客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名 就可以申请连接到数据库。这个服务名可能与实例名一样,也有可能不一样。 在数据库服务器启动过程中,数据库服务器会向监听程序注册相应的服务(无论何时启动一个数据库,默认地都有两条信息注册

oracle什么时候使用静态监听,Oracle监听之动态监听与静态监听特点-爱代码爱编程

动态注册不需要显示的配置listener.ora文件,实例启动的时候,PMON进程根据instance_name,service_name参数将实例和服务动态注册 1、如何查询某服务是静态监听注册还是动态监听注册 可以使用命令lsnrctl status来查看某服务是静态注册还是动态注册。 实例状态为UNKNOWN值时表明此服务是静态注册的设

ORACLE学习笔记-ORACLE动态监听和静态监听-爱代码爱编程

ORACLE静态监听: listener静态注册,参数是手动静态添加,与数据库无关。数据库监听启动无法确是否正确配置(配置错误SID监听也可以正常启动)。因此,lsnrctl中的status显示状态为“UNKNOWN”。即不保证能连通数据库。listener启动时,根据配置listener.ora文件中配置信息进行实例注册。 静态监听配置如下: SID_

oracle ebs 值层次结构查询sql-爱代码爱编程

Oracle EBS 值层次结构查询SQL  -- 查看层次结构 -- 值层次结构 SELECT ffvcv.flex_value -- 子值 ,ffvcv.description -- 说明 ,ffvcv.summary_flag --是否为父级 ,ffvcv.parent_flex_value --父值 FROM fnd_flex_v

oracle ebs app-爱代码爱编程

Oracle EBS APP-FND-02901: you don't have privilege to any operating unit APP-FND-02901: 您没有访问任何业务实体的权限。请检查您的配置文件选项“MO:安全性配置文件”是否包括任何业务实体,或是否设置了配置文件选项“MO:业务实体”。 A

oracle ebs 发送邮件示例-爱代码爱编程

Oracle EBS 发送邮件示例 DECLAREcrlf varchar2(2) := UTL_TCP.crlf;connection UTL_SMTP.connection;smtpServer varchar2(100) := 'smtp.office365.com';emailSubject varchar2(100) := 'Test Gene

oracle ebs 值集获取段限定词sql_fnd_flex_values-爱代码爱编程

Oracle EBS 值集获取段限定词SQL    SELECT b.flex_value      ,b.enabled_flag      ,b.summary_flag      ,substr(replace(b.compiled_value_attributes, chr(10), ''), 1, 1)  "限定词部分1"