重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
要想给一个Oracle实例配置多个监听,首先要定义多个监听器,因为是多个监听,势必会有一些监听端口不是1521.
阳高网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
现在服务端的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.
动态注册的服务名为service_name.db_domain,
在服务端的listener.ora里对监听器LI配置静态的服务名称和实例名,下面没有列出默认监听器的配置.
此时的默认监听器还是监听在1521端口的,而且没有设置local_listener
(alter system reset local_listener 可以把local_listener还原成默认值).
所以Pmon会默认注册到默认监听器的.
因此我们只需要在给监听在1522端口的LI配置静态服务,这样就有两个监听器为我们的实例服务了.
配置如下:
这里的GLOBAL_DBNAME=service_name.db_domain,和自动注册是在lsnrclt里看到的服务是一样的.
--重启监听LI
[oracle@wang admin]$ lsnrctl stop li
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-FEB-2018 18:51:20
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wang)(PORT=1522)))
The command completed successfully
[oracle@wang admin]$
[oracle@wang admin]$ lsnrctl start li
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-FEB-2018 18:51:30
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/wang/li/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wang)(PORT=1522)))
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 18:51:30
Uptime 0 days 0 hr. 0 min. 0 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", statusUNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@wang admin]$