我們都知道,Oracle的監(jiān)聽默認(rèn)端口是1521,但是如果系統(tǒng)上1521已經(jīng)被占用或業(yè)務(wù)要求不用默認(rèn)端口,則需要修改監(jiān)聽的默認(rèn)端口。
湯陰網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),湯陰網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為湯陰超過千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的湯陰做網(wǎng)站的公司定做!修改監(jiān)聽端口只需要修改配置文件listiner.ora,然后重啟監(jiān)聽就行了。但是Oracle實例的PMON進程還是會去找監(jiān)聽1521端口的監(jiān)聽進程去注冊,所以同時也需要修改數(shù)據(jù)庫的配置。數(shù)據(jù)庫里只需要在線修改LOCAL_LISTINER即可。
下面以11.2.0.4為例測試修改監(jiān)聽端口:
1、修改監(jiān)聽端口
#查看監(jiān)聽狀態(tài) [oracle@rhel6 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:16:24 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 07-JAN-2017 20:16:16 Uptime 0 days 0 hr. 0 min. 8 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully #停止監(jiān)聽 [oracle@rhel6 ~]$ lsnrctl stop LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:17:39 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) The command completed successfully #修改配置文件listener.ora,改監(jiān)聽端口為2521 LISTENER= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)) (ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))) #啟動監(jiān)聽 [oracle@rhel6 ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:19:11 Copyright (c) 1991, 2013, Oracle. All rights reserved. Starting /u02/app/oracle/product/11.2.4/db1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.4.0 - Production System parameter file is /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Log messages written to /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 07-JAN-2017 20:19:11 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) The listener supports no services The command completed successfully至此,監(jiān)聽端口已經(jīng)修改完畢,這時Oracle實例是無法注冊到此監(jiān)聽上的。
2、修改LOCAL_LISTINER參數(shù)
#修改參數(shù) sys@ORCL>alter system set local_listener="(address = (protocol = tcp)(host = rhel6)(port = 2521))"; System altered. #查看監(jiān)聽狀態(tài) [oracle@rhel6 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:23:10 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 07-JAN-2017 20:19:11 Uptime 0 days 0 hr. 3 min. 59 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully修改完后,可以看到數(shù)據(jù)庫實例立即注冊到監(jiān)聽器上。
3、使用新端口進行測試連接
[c:\~]$ sqlplus zx/zx@192.168.56.2:2521/orcl SQL*Plus: Release 12.1.0.1.0 Production on 星期六 1月 7 20:24:17 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. 連接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>修改監(jiān)聽端口完成。
4、把Oracle實例的注冊端口改回1521
sys@ORCL>alter system set local_listener=''; System altered.官方文檔中還提供了另一種配置LOCAL_LISTINER的方法:
在tnsnames.ora中添加配置,然后配置LOCAL_LISTINER為tnsnames.ora中的名字即可
#配置tnsnames.ora [oracle@rhel6 admin]$ vi tnsnames.ora listener1=(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.2 )(PORT = 2521)) #修改LOCAL_LISTINER參數(shù) sys@ORCL>alter system set local_listener=listener1; System altered. #查看監(jiān)聽狀態(tài) [oracle@rhel6 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:34:01 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 07-JAN-2017 20:31:28 Uptime 0 days 0 hr. 2 min. 33 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully另外還可以使用靜態(tài)監(jiān)聽的方法來修改監(jiān)聽的端口,但是Oracle實例不是“主動”注冊到監(jiān)聽器上的。
sys@ORCL>show parameter local_listener NAME TYPE VALUE ------------------------------------ --------------------------------- ------------------------------ local_listener string #修改監(jiān)聽為靜態(tài)監(jiān)聽 [oracle@rhel6 admin]$ vi listener.ora LISTENER= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)) (ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))) SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=orcl) (ORACLE_HOME=/u02/app/oracle/product/11.2.4/db1) (SID_NAME=orcl)) #重啟監(jiān)聽 [oracle@rhel6 ~]$ lsnrctl stop LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:38:45 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) The command completed successfully [oracle@rhel6 ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-JAN-2017 20:38:51 Copyright (c) 1991, 2013, Oracle. All rights reserved. Starting /u02/app/oracle/product/11.2.4/db1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.4.0 - Production System parameter file is /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Log messages written to /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 07-JAN-2017 20:38:52 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora Listener Log File /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully靜態(tài)監(jiān)聽實例的狀態(tài)為UNKNOWN,測試連接成功
[c:\~]$ sqlplus zx/zx@192.168.56.2:2521/orcl SQL*Plus: Release 12.1.0.1.0 Production on 星期六 1月 7 20:40:03 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. 連接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>官方文檔:
http://docs.oracle.com/cd/E11882_01/network.112/e41945/listenercfg.htm#NETAG1154
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。