网站建设资讯

NEWS

网站建设资讯

Oracle一个实例配置多个监听-创新互联

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

创新互联专注于企业营销型网站、网站重做改版、八公山网站定制设计、自适应品牌网站建设、H5页面制作商城网站定制开发、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为八公山等各大城市提供网站开发制作服务。

现在服务端的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]$

文章标题:Oracle一个实例配置多个监听-创新互联
标题来源:http://cdweb.net/article/docpsp.html