首页 > 其他分享 >动态监听和静态监听的区别

动态监听和静态监听的区别

时间:2023-02-09 15:25:47浏览次数:57  
标签:DESCRIPTION 静态 SID LIST ADDRESS 动态 监听 name

动态监听和静态监听主要区别是实例向监听注册的方式。注册,就是让监听能够找到数据库实例。

一、动态监听
1.动态注册不需要显示的配置listener.ora文件,实例启动的时候,
PMON进程根据instance_name,service_name参数将实例和服务动态注册到listerer中。
如果没有设定instance_name,将使用db_name初始化参数值。
如果没有设定service_names,将拼接db_name和db_domain参数值来注册监听。
注意:Oracle_SID从ORACLE 10G开始,参数文件不再记录INSTANCE_NAME,此时INSTANCE_NAME动态从系统ORACLE_SID获得来保持一致。

优点:
1)lsnrctl start后不需要人工干预,会自动注册数据库的instance_name,service_name,然后tns不论使用SID和SERVICE_NAME均可以连接上来
2)修改了SERVICE_NAME或者SID不用修改listener.ora文件
3)动态注册的数据库通过状态信息中的状态READY或状态BLOCKED(对于一个备用数据库)来指明。
缺点:
1)动态监听是数据库启动时注册到监听的,一旦数据库关闭,用户无法连接

二、静态监听

1.静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序。
静态监是一种硬编码,静态监听硬编码的部份是ORACLE_HOME以及ORACLE_SID

lsnrctl status 中显示如下: 服务摘要... 服务“docarejt”包含1个实例    实例“docare”,状态UNKOWN,包含此服务的一个处理程序 注释:test即从监听配置文件中GLOBAL_DBNAME读到的值,docare则从SID_NAME读到的值

三、两种监听的对比

 

 

 

 四、示例

说明:1521、1524端口静态监听,1522、1523端口动态监听

listener.ora配置

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test01)
      (ORACLE_HOME = D:\Oracle\product\11.2.0\dbhome_1)
      (SID_NAME = DOCARE)
    )
  )

SID_LIST_LISTENER1524 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test04)
      (ORACLE_HOME = D:\Oracle\product\11.2.0\dbhome_1)
      (SID_NAME = DOCARE)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1521))
      )
    )
  )

LISTENER1522 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1522))
      )
    )
  )

LISTENER1523 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1523))
      )
    )
  )

LISTENER1524 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1524))
      )
    )
  )

tnsnames.ora 配置

test01 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1521))
      )
    )
  )

test02 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1522))
      )
    )
  )

test03 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1523))
      )
    )
  )

test04 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = 
        (ADDRESS = (PROTOCOL = TCP)(HOST = HISDB)(PORT = 1524))
      )
    )
  )

注释:tnsname.ora的名称需要跟listener.ora的global_name要相对应,tnsname.ora文件中test01 、test04在listener.ora中的静态监听已经声明了(GLOBAL_DBNAME的值),

          而test02、test03则在动态监听service_name参数(或local_listener参数)定义了,所以tnsname.ora声明的连接符都可以使用(如在service_name没有声明,有可能用不了)。

 

标签:DESCRIPTION,静态,SID,LIST,ADDRESS,动态,监听,name
From: https://www.cnblogs.com/jiangxm157/p/17105411.html

相关文章