当前位置:   article > 正文

oracle 19c CDB容器数据库监听和tns文件配置_oracle 19c listener.ora

oracle 19c listener.ora

sqlnet.ora(客户端和服务端):决定连接顺序

listener.ora(服务端)和tnsnames.ora(客户端)文件配置:

首先说明一下监听分为以下两类

默认监听:端口号是1521,监听的名字为LISTENER
非默认监听:端口号自定义,监听名字也可以自定义

注册:将实例和服务名注册到监听

服务器注册也分为以下两类:

动态注册:先启动监听,如果实例启动,就自动注册到监听,监听每隔1分钟会去扫描是否有新启动的实例

如下:如果将实例关闭,监听就监听不到服务。


alter system register;---注册监听,这个操作是手动的去注册服务,这样就不需要区等待1分钟了
静态注册:启动监听的同时就把实例注册到监听,不管实例是否启动都注册

监听的过程:

1.有一个外部程序每隔1分钟就会去扫描是否有新启动的实例,有的话就把实例和服务名注册上去,注册过后就代表告诉外界的客户端,你们都可以来连接我了。

2.客户端只要提供正确的端口号,ip,服务名就可以连接到服务器了


想要默认监听和非默认监听都能静态注册和动态注册
1.要在listener.ora配置默认和非默认监听名字
2.设置参数为新增的别名,这个别名要有默认监听和非默认监听两个端口
alter system set local_listener='LISR2';

listener.ora:
#默认监听

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )


SID_LIST_LISTENER =
  (SID_LIST =#动态注册,这一段其实可以不写,为了体现完整性还是加上
    (SID_DESC =
      (SID_NAME = plsextproc)
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (PROGRAM = extproc)
    )
    (SID_DESC =#静态注册
      (GLOBAL_DBNAME = CDB)#对外提供服务的名字是什么,这个可以自定义
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (SID_NAME = CDB)
    )
  )


tnsnames.ora:

LISTENER_CDB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))


CDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CDB)
    )
  )
pdb1=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )
 

配置默认监听和非默认监听都同时支持动态注册和静态注册
1.如果要默认监听和非默认监听都能使用,需要去掉 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

LISTENER =#默认监听
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    )
  )


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = plsextproc)
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = CDB)
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (SID_NAME = CDB)
    )
  )
LSNR2 =#非默认监听
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1526))
    )     
  )      
        

SID_LIST_LSNR2 = 
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = plsextproc)
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = CDB)
      (ORACLE_HOME = /u01/app/oracle/product/19.2.0/db_home1)
      (SID_NAME = CDB)
    )
  )

2.需要修改tnsnames.ora配置,以下红色部分为新增的

LISTENER_CDB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))

lsnr2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1526))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CDB)
    )
  )

 

CDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CDB)
    )
  )
pdb1=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )
 

3.修改参数local_listener

测试结果:默认监听和非默认监听都满足要求

实践:以下为11g监听配置,一个实例配置多个服务名,这个GLOBAL_NAME 可以自己任意取名字,和tnsnames.ora的SERVICE_NAME对应。修改监听文件后应该要重启监听。

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = zhuke)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
     (GLOBAL_DBNAME = zhuke.net)
        (ORACLE_HOME = /u01/app/oracle/11.2.0/db_1)
        (SID_NAME = zhuke))
    (SID_DESC =
     (GLOBAL_DBNAME = test)
        (ORACLE_HOME = /u01/app/oracle/11.2.0/db_1)
        (SID_NAME = zhuke))
  )
sqlplus system/oracle@//192.168.244.100:1521/zhuke.net

sqlplus system/oracle@ZHUKE_PD

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/545526
推荐阅读
相关标签
  

闽ICP备14008679号