文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Oracle一个实例配置多个监听

2024-04-02 19:55

关注

要想给一个Oracle实例配置多个监听,首先要定义多个监听器,因为是多个监听,势必会有一些监听端口不是1521.

现在服务端的listener.ora文件中定义如下监听器:
[oracle@wang admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LI =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = wang)(PORT = 1522))
    )
  )

[oracle@wang admin]$

注意:
Because all of the configuration parameters have default values, it is possible to start and use a listener with no configuration. This default listener has a name of LISTENER, supports no services on startup, and listens on the following TCP/IP protocol address: (ADDRESS=(PROTOCOL=tcp)(HOST=host_name)(PORT=1521))  

这句话就能解释,即使是在没有listener.ora文件的情况下,也会可以启动名为LISTENER的监听来监听1521端口。

一个监听1521端口的默认监听器,一个监听1522端口的监听器LI. 到现在我们还没有给这两个监听器配置相应的Oracle服务.

监听器与Oracle服务关联有两种方式,静态注册和动态注册.

 动态注册只能注册到默认的1521端口,而这里我们需要一次性的动态注册到两个端口,因为需要使用local_listener.

先在服务端的tnsnames.ora文件里加入一个描述对象L,具体叫什么其实都无所谓的.然后会把它赋值给local_listner,这样Pmon才知道往那些指定的IP和端口发送注册请求.

动态注册的时候,PMon会到tnsnames.ora里面查找描述对象的具体信息,

L =
  (
    DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1522))
    )
  )

SQL> alter system set local_listener='l';

System altered.

其实local_listener也接受直接的地址描述或者地址描述列表.
SQL>  alter system set local_listener=' (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1522))';

-更改local_listener后,原来注册的服务会取消,然后PMON每隔一分钟重参试注册到新地址.下面我们手动触发注册.

SQL> alter system register; --注册到新的local_listener

System altered.

SQL>  alter system set local_listener='(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.12)(PORT = 1522))))';--同时注册到1521 和1522 端口.

System altered.

SQL> alter system register;

System altered.

--查看监听状态:
[oracle@wang admin]$ lsnrctl status li

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-FEB-2018 18:47:13

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wang)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     li
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                06-FEB-2018 17:38:09
Uptime                    0 days 1 hr. 9 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/wang/li/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1522)))
Services Summary...
Service "DBdb" has 1 instance(s).
  Instance "DBdb", status READY, has 1 handler(s) for this service...
Service "DBdbXDB" has 1 instance(s).
  Instance "DBdb", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@wang admin]$
[oracle@wang admin]$
[oracle@wang admin]$ lsnrctl status   

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-FEB-2018 18:47:17

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                06-FEB-2018 17:38:04
Uptime                    0 days 1 hr. 9 min. 12 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/wang/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1521)))
Services Summary...
Service "DBdb" has 1 instance(s).
  Instance "DBdb", status READY, has 1 handler(s) for this service...
Service "DBdbXDB" has 1 instance(s).
  Instance "DBdb", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@wang admin]$

动态注册的服务名为service_name.db_domain,

在服务端的listener.ora里对监听器LI配置静态的服务名称和实例名,下面没有列出默认监听器的配置.

此时的默认监听器还是监听在1521端口的,而且没有设置local_listener
(alter system reset local_listener 可以把local_listener还原成默认值).

所以Pmon会默认注册到默认监听器的.

因此我们只需要在给监听在1522端口的LI配置静态服务,这样就有两个监听器为我们的实例服务了.

配置如下:

[oracle@wang admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LI =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = wang)(PORT = 1522))
    )
  )

SID_LIST_LI=
   (SID_LIST=
     (SID_DESC=
       (GLOBAL_DBNAME=DBdb)
       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
       (SID_NAME=DBdb)
     )
    )

[oracle@wang admin]$

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 资料下载
  • 历年真题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯