温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle监听的静态注册和动态注册

发布时间:2020-08-11 09:53:49 来源:ITPUB博客 阅读:232 作者:张冲andy 栏目:关系型数据库

静态注册:通过解析listene.ora文件

动态注册:由PMON进程动态注册至监听中

在没有listener.ora配置文件的情况下,如果启动监听,则监听为动态注册。用图形化netca创建的监听,默认也为动态注册

1.静态注册

listener.ora文件,监听的配置文件,静态注册读取该文件,动态注册,不必要

可以通过netca工具创建,也可以手动编辑。典型的listener.ora文件内容:

LISTENER_PHAMR = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = phamrdb1-vip)(PORT = 1521)) 
  )

 

SID_LIST_LISTENER_PHALR = 
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_DBNAME = phalr) 
      (ORACLE_HOME = /oracle/product/11.2.0) 
      (SID_NAME = phalr) 
    ) 
  )

listener.ora文件两大模块:

LISTENER模块:监听名字、连接协议、监听主机、监听端口等基本配置信息

SID_LIST_LISTENER模块:配置监听的静态注册特性,包含数据库服务名、ORACLE_HOME、实例名等信息。

注意:SID_NAME,就是数据库实例名,在Linux环境大小写敏感

GLOBAL_DBNAME就是数据库服务名,可以省略,默认和SID_NAME保持一致,也可以不一致。

ORACLE_HOME,默认和$ORACLE_HOME环境变量保持一致。Windows,该参数无效,取自注册表。

静态注册,监听不知道实例的具体状态,所以监听启动之初查看实例信息,其状态信息显示为UNKNOWN.例如:

oracle@phamrdb1: /home/oracle> lsnrctl status LISTENER_PHAMR

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 17:17:37

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=phamrdb1-vip)(PORT=1521))) 
STATUS of the LISTENER 
------------------------ 
Alias                     LISTENER_PHAMR 
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production 
Start Date                01-OCT-2016 14:12:51 
Uptime                    47 days 3 hr. 4 min. 45 sec 
Trace Level               off 
Security                  ON: Local OS Authentication 
SNMP                      OFF 
Listener Parameter File   /oracle/product/11.2.0/network/admin/listener.ora 
Listener Log File         /oracle/diag/tnslsnr/phamrdb1/listener_phamr/alert/log.xml 
Listening Endpoints Summary... 
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.178.1.64)(PORT=1521))) 
Services Summary... 
Service "phamr" has 1 instance(s).     监听状态中的服务名 
  Instance "phamr", status UNKNOWN, has 1 handler(s) for this service...  监听状态中的实例名 
The command completed successfully

2,动态注册 
在动态注册监听的环境中,listener.ora文件可以不包括当前数据库的实例信息,所以这个文件不必要。

实例启动时,会由Oracle PMON进程将数据库实例信息动态注册至监听上。

当Oracle实例关闭时,会再次由PMON进程自动从监听里面撤销当前实例信息。

所以,要实现动态注册,数据库的实例至少要处于nomount状态

监听动态注册时的实例状态:来自PMON进程动态注册时的实例状态,一般有3种状态:READY、BLOCKED和RESTRICED

READY:表示数据库实例已经处于mount或者open状态,可以接受客户端连接

BLOCKED:表示数据库实例还处于nomount状态或者该实例类型为ASM实例,不接受客户端连接,如果这时候客户端去连

               接数据库会报ora-12528错误

RESTRICED:表示数据库处于RESTRICED模式,不接受普通权限的远程客户端连接,如果这时候客户端去连接数据库会报

                  ora-12526错误

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 16:01:43

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                17-NOV-2016 15:57:23 
Uptime                    0 days 0 hr. 4 min. 19 sec 
Trace Level               off 
Security                  ON: Local OS Authentication 
SNMP                      OFF 
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml 
Listening Endpoints Summary... 
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521))) 
Services Summary... 
Service "FSDATA" has 1 instance(s). 
  Instance "FSDATA", status READY, has 1 handler(s) for this service... 
Service "FSDATAXDB" has 1 instance(s). 
  Instance "FSDATA", status READY, has 1 handler(s) for this service... 
The command completed successfully 

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 15:58:47

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                17-NOV-2016 15:57:23 
Uptime                    0 days 0 hr. 1 min. 23 sec 
Trace Level               off 
Security                  ON: Local OS Authentication 
SNMP                      OFF 
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml 
Listening Endpoints Summary... 
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521))) 
Services Summary... 
Service "FSDATA" has 1 instance(s). 
  Instance "FSDATA", status BLOCKED, has 1 handler(s) for this service... 
The command completed successfully 

实例既可以动态注册,同时静态注册,状态分别显示为READYUNKNOWN

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 17:50:14

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=fsdata)(PORT=1521))) 
STATUS of the LISTENER 
------------------------ 
Alias                     LISTENER 
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production 
Start Date                17-NOV-2016 15:57:23 
Uptime                    0 days 1 hr. 52 min. 50 sec 
Trace Level               off 
Security                  ON: Local OS Authentication 
SNMP                      OFF 
Listener Parameter File   /oracle/product/11.2.0/network/admin/listener.ora 
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml 
Listening Endpoints Summary... 
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521))) 
Services Summary... 
Service "FSDATA" has 2 instance(s). 
  Instance "FSDATA", status UNKNOWN, has 1 handler(s) for this service... 
  Instance "FSDATA", status READY, has 1 handler(s) for this service... 
Service "FSDATAXDB" has 1 instance(s). 
  Instance "FSDATA", status READY, has 1 handler(s) for this service... 
The command completed successfully 

3.监听的常用命令

lsnrctl start [listener_name]

lsnrctl stop [listener_name]

lsnrctl status [listener_name]

lsnrctl service [listener_name]

lsnrctl reload [listener_name]

4.监听的别名

监听默认名字是LISTENER,可以配置别名

oracle@fsdata: /dump> ps -ef | grep tnslsnr | grep  -v grep 
oracle   29598     1  0 15:57 ?        00:00:00 /oracle/product/11.2.0/bin/tnslsnr LISTENER -inherit 

oracle@phamrdb1: /home/oracle> ps -ef | grep tnslsnr| grep -v grep 
oracle   38300     1  0 Oct01 ?        06:21:54 /oracle/product/11.2.0/bin/tnslsnr LISTENER_PHAMR –inherit

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI