Oracle 建立非1521埠監聽

東北胖子發表於2018-04-04


現有的監聽檔案配置

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ cat listener.ora
  2. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  8.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  9.     )
  10.   )

  11. ADR_BASE_LISTENER = /u01/app/oracle



  12. SID_LIST_LISTENER =
  13.   (SID_LIST =
  14.     (SID_DESC =
  15.       (GLOBAL_DBNAME=orcl)
  16.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  17.      (SID_NAME = orcl)
  18.     )
  19.   )

目前的監聽狀態

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ lsnrctl status

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:09:29

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
  5. STATUS of the LISTENER
  6. ------------------------
  7. Alias LISTENER
  8. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  9. Start Date 03-APR-2018 23:30:31
  10. Uptime 0 days 0 hr. 38 min. 57 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  15. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
  16. Listening Endpoints Summary...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
  18.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  19. Services Summary...
  20. Service "orcl" has 1 instance(s).
  21.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  22. Service "orclXDB" has 1 instance(s).
  23.   Instance "orcl", status READY, has 1 handler(s) for this service...
  24. Service "primary_orcl" has 1 instance(s).
  25.   Instance "orcl", status READY, has 1 handler(s) for this service...
  26. The command completed successfully

----------------------------------分隔線-----------------------------------------

在listener.ora檔案中新增1522埠的監聽,新增後的檔案內容如下

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ cat listener.ora
  2. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  8.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  9.     )
  10.   )

  11. ADR_BASE_LISTENER = /u01/app/oracle



  12. SID_LIST_LISTENER =
  13.   (SID_LIST =
  14.     (SID_DESC =
  15.       (GLOBAL_DBNAME=orcl)
  16.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  17.      (SID_NAME = orcl)
  18.     )
  19.   )


  20. #1522
  21. MY_LISTENER =
  22.   (DESCRIPTION_LIST =
  23.     (DESCRIPTION =
  24.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
  25.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
  26.     )
  27.   )

  28. #用於在1522埠註冊服務
  29. SID_LIST_MY_LISTENER =
  30.   (SID_LIST =
  31.     (SID_DESC =
  32.       (GLOBAL_DBNAME=orcl)
  33.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  34.      (SID_NAME = orcl)
  35.     )
  36.   )

啟動1522埠監聽

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ lsnrctl start my_listener

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:16:18

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

  5. TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  6. System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  7. Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  8. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))

  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  11. STATUS of the LISTENER
  12. ------------------------
  13. Alias my_listener
  14. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  15. Start Date 04-APR-2018 00:16:18
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  21. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  22. Listening Endpoints Summary...
  23.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  24.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  25. Services Summary...
  26. Service "orcl" has 1 instance(s).
  27.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  28. The command completed successfully

使用PLSQL Developer工具測試可以正常連線。

-----------------------分割線----------------------------
在1522埠註冊伺服器還有一種方法,就是使用tnsnames.ora檔案
在去掉了listener.ora中有關 SID_LIST_MY_LISTENER 靜態註冊的程式碼後,重啟my_listener監聽發現沒有任何服務註冊

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ lsnrctl start my_listener

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:18:08

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

  5. TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  6. System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  7. Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  8. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))

  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  11. STATUS of the LISTENER
  12. ------------------------
  13. Alias my_listener
  14. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  15. Start Date 04-APR-2018 00:18:08
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  21. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  22. Listening Endpoints Summary...
  23.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  24.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  25. The listener supports no services
  26. The command completed successfully

在tnsnames.ora檔案中新增如下程式碼

點選(此處)摺疊或開啟

  1. my_orcl =
  2.   (DESCRIPTION =
  3.     (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
  4.     (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  5.     (CONNECT_DATA =
  6.       (SERVER = DEDICATED)
  7.       (SERVICE_NAME = orcl)
  8.     )
  9.   )

注:如果不新增(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))這段的話,那麼在預設1521埠中將不會有服務註冊

登入資料庫設定local_listener引數

點選(此處)摺疊或開啟

  1. alter system set local_listener='my_orcl' scope=both;

使用命令分別檢查監聽狀態

點選(此處)摺疊或開啟

  1. [oracle@test-db admin]$ lsnrctl status

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:38

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
  5. STATUS of the LISTENER
  6. ------------------------
  7. Alias LISTENER
  8. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  9. Start Date 03-APR-2018 23:30:31
  10. Uptime 0 days 1 hr. 2 min. 6 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  15. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
  16. Listening Endpoints Summary...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
  18.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  19. Services Summary...
  20. Service "orcl" has 1 instance(s).
  21.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  22. Service "orclXDB" has 1 instance(s).
  23.   Instance "orcl", status READY, has 1 handler(s) for this service...
  24. Service "primary_orcl" has 1 instance(s).
  25.   Instance "orcl", status READY, has 1 handler(s) for this service...
  26. The command completed successfully
  27. [oracle@test-db admin]$ lsnrctl status my_listener

  28. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:45

  29. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  30. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  31. STATUS of the LISTENER
  32. ------------------------
  33. Alias my_listener
  34. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  35. Start Date 04-APR-2018 00:18:08
  36. Uptime 0 days 0 hr. 14 min. 37 sec
  37. Trace Level off
  38. Security ON: Local OS Authentication
  39. SNMP OFF
  40. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  41. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  42. Listening Endpoints Summary...
  43.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  44.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  45. Services Summary...
  46. Service "orclXDB" has 1 instance(s).
  47.   Instance "orcl", status READY, has 1 handler(s) for this service...
  48. Service "primary_orcl" has 1 instance(s).
  49.   Instance "orcl", status READY, has 1 handler(s) for this service...
  50. The command completed successfully

使用PLSQL Developer工具測試可以正常連線。





來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2317695/viewspace-2152591/,如需轉載,請註明出處,否則將追究法律責任。

相關文章