oracle监听配置.md

  • 最近在工作中需要测试oracle监听,通过扒拉资料和请教一些同事,先做一些操作上的总结吧,先看下监听中的很多名词
    • 动态监听:动态注册不需要从listener.ora中读取配置文件,实例在mount时,pmon进程会根据instance_name,service_name参数将实例和服务动态注册到listerer中
    • 静态监听:静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序
      • 如图所示:状态是UNKNOW的是静态监听,状态是READY是动态监听


        image.png
      • 静态监听配置方法
        • RAC: 配置在grid下,配置路径$ORACLE_HOME/network/admin/listener.ora
        • 单实例(无GI):配置在oracle下,配置路径$ORACLE_HOME/network/admin/listener.ora
        • 配置监听的三种情况
          • 一个监听在一个IP一个端口上监听多个实例
          • 一个监听在一个IP一个端口上监听多个实例
# 注意SID_LIST_ORCL和ORCL 的名称需要一致
# 启动监听:lsnrctl start orcl
# 关闭监听:lsnrctl stop orcl
# 监听状态:lsnrctl status orcl
# 一个监听在一个IP一个端口上监听多个实例
SID_LIST_ORCL =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = NHL)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = NHL)
    )
  )
ORCL =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
  )
# 一个监听在一个IP不同端口上监听多个实例
SID_LIST_ORCL =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = NHL)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = NHL)
    )
  )
ORCL =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1522))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    )
  )
# 多个监听监听多个实例
SID_LIST_ORCL =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = ORCL)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = NHL)
      (SID_NAME = NHL)
    )
  )
ORCL =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    )
SID_LIST_TEST =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = TEST)
      (ORACLE_HOME = /opt/oracle/products/12.2.0.2)
      (SID_NAME = TEST)
    )
   )
TEST =
   (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1523))
    )


  • 安装完RAC后默认的监听地址(本地监听和scan 监听)
LISTENER_SCAN1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
    )
  )
  • 配置完成后需要手工注册监听地址
方法一:
alter system register    # 手动给监听注册service
方法二:
- 单实例
alter system set local_listener='(address=(protocol=tcp)(host=0.0.0.0)(port=1522))';
- RAC
alter system set local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1523))' scope=both sid='orcl';

参考链接:
参考1
参考2

你可能感兴趣的:(oracle监听配置.md)