要想給一個Oracle實例配置多個監(jiān)聽,首先要定義多個監(jiān)聽器,因為是多個監(jiān)聽,勢必會有一些監(jiān)聽端口不是1521.
陽高網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、APP開發(fā)、響應式網(wǎng)站等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)2013年至今到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選創(chuàng)新互聯(lián)。
現(xiàn)在服務端的listener.ora文件中定義如下監(jiān)聽器:
[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))
這句話就能解釋,即使是在沒有l(wèi)istener.ora文件的情況下,也會可以啟動名為LISTENER的監(jiān)聽來監(jiān)聽1521端口。
一個監(jiān)聽1521端口的默認監(jiān)聽器,一個監(jiān)聽1522端口的監(jiān)聽器LI. 到現(xiàn)在我們還沒有給這兩個監(jiān)聽器配置相應的Oracle服務.
監(jiān)聽器與Oracle服務關聯(lián)有兩種方式,靜態(tài)注冊和動態(tài)注冊.
動態(tài)注冊只能注冊到默認的1521端口,而這里我們需要一次性的動態(tài)注冊到兩個端口,因為需要使用local_listener.
先在服務端的tnsnames.ora文件里加入一個描述對象L,具體叫什么其實都無所謂的.然后會把它賦值給local_listner,這樣Pmon才知道往那些指定的IP和端口發(fā)送注冊請求.
動態(tài)注冊的時候,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每隔一分鐘重參試注冊到新地址.下面我們手動觸發(fā)注冊.
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.
動態(tài)注冊的服務名為service_name.db_domain,
在服務端的listener.ora里對監(jiān)聽器LI配置靜態(tài)的服務名稱和實例名,下面沒有列出默認監(jiān)聽器的配置.
此時的默認監(jiān)聽器還是監(jiān)聽在1521端口的,而且沒有設置local_listener
(alter system reset local_listener 可以把local_listener還原成默認值).
所以Pmon會默認注冊到默認監(jiān)聽器的.
因此我們只需要在給監(jiān)聽在1522端口的LI配置靜態(tài)服務,這樣就有兩個監(jiān)聽器為我們的實例服務了.
配置如下:
這里的GLOBAL_DBNAME=service_name.db_domain,和自動注冊是在lsnrclt里看到的服務是一樣的.
--重啟監(jiān)聽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]$