共計 8164 個字符,預計需要花費 21 分鐘才能閱讀完成。
丸趣 TV 小編給大家分享一下 Oracle 如何創建非 1521 端口監聽,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
現有的監聽文件配置
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
目前的監聽狀態
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-APR-2018 00:09:29
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 03-APR-2018 23:30:31
Uptime 0 days 0 hr. 38 min. 57 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service orcl has 1 instance(s).
Instance orcl , status UNKNOWN, has 1 handler(s) for this service…
Service orclXDB has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
Service primary_orcl has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
The command completed successfully
———————————- 分隔線 —————————————–
在 listener.ora 文件中添加 1522 端口的監聽,添加后的文件內容如下
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
#1522
MY_LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
)
)
#用于在 1522 端口注冊服務
SID_LIST_MY_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
啟動 1522 端口監聽
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ lsnrctl start my_listener
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-APR-2018 00:16:18
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait…
TNSLSNR for Linux: Version 11.2.0.3.0 – Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
STATUS of the LISTENER
————————
Alias my_listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 04-APR-2018 00:16:18
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/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Services Summary…
Service orcl has 1 instance(s).
Instance orcl , status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully
使用 PLSQL Developer 工具測試可以正常連接。
———————– 分割線 —————————-
在 1522 端口注冊服務器還有一種方法,就是使用 tnsnames.ora 文件
在去掉了 listener.ora 中有關 SID_LIST_MY_LISTENER 靜態注冊的代碼后,重啟 my_listener 監聽發現沒有任何服務注冊
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ lsnrctl start my_listener
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-APR-2018 00:18:08
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait…
TNSLSNR for Linux: Version 11.2.0.3.0 – Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
STATUS of the LISTENER
————————
Alias my_listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 04-APR-2018 00:18:08
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/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
The listener supports no services
The command completed successfully
在 tnsnames.ora 文件中添加如下代碼
點擊 (此處) 折疊或打開
my_orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
注:如果不添加 (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521)) 這段的話,那么在默認 1521 端口中將不會有服務注冊
登錄數據庫設置 local_listener 參數
點擊 (此處) 折疊或打開
alter system set local_listener= my_orcl scope=both;
使用命令分別檢查監聽狀態
點擊 (此處) 折疊或打開
[oracle@test-db admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-APR-2018 00:32:38
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 03-APR-2018 23:30:31
Uptime 0 days 1 hr. 2 min. 6 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service orcl has 1 instance(s).
Instance orcl , status UNKNOWN, has 1 handler(s) for this service…
Service orclXDB has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
Service primary_orcl has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
The command completed successfully
[oracle@test-db admin]$ lsnrctl status my_listener
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-APR-2018 00:32:45
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
STATUS of the LISTENER
————————
Alias my_listener
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 04-APR-2018 00:18:08
Uptime 0 days 0 hr. 14 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Services Summary…
Service orclXDB has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
Service primary_orcl has 1 instance(s).
Instance orcl , status READY, has 1 handler(s) for this service…
The command completed successfully
使用 PLSQL Developer 工具測試可以正常連接。
以上是“Oracle 如何創建非 1521 端口監聽”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!