要想给一个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配置静态服务,这样就有两个监听器为我们的实例服务了.
配置如下:
# 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
软考中级精品资料免费领
- 历年真题答案解析
- 备考技巧名师总结
- 高频考点精准押题
- 资料下载
- 历年真题
193.9 KB下载数265
191.63 KB下载数245
143.91 KB下载数1142
183.71 KB下载数642
644.84 KB下载数2755