非默認監聽註冊問題

在集羣環境或非集羣環境中,local_listener或remote_listener參數設置錯誤,可能導致數據庫就不能啓動,報ORA-00119和ORA-00132錯誤。


官方文檔Oracle Database Net Services Administrator's Guide (11.2)第9章Configuring and Administering Oracle Net Listener中的相關解釋爲

Configuring a Naming Method

The listener name alias specified for the LOCAL_LISTENER initialization parameter, REMOTE_LISTENER initialization parameter, or LISTENER attribute can be resolved through a tnsnames.ora file. A net service name entry can be created for the protocol address without the CONNECT_DATA section of the connect descriptor. Oracle Enterprise Manager and Oracle Net Manager cannot configure a tnsnames.ora file without the CONNECT_DATA information. To use listener name aliases, Oracle recommends you modify the tnsnames.ora file using a text editor.

For example, if LOCAL_LISTENER is set to listener_sales1 and listener_sales1 uses TCP/IP on port 1421, then the entry in the tnsnames.ora file would be:

listener_sales1=

(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1421))


Notes:

■ Multiple addresses are supported, but connect-time failover and client load balancing features are not supported.

■ If the listener alias specified in the LOCAL_LISTENER parameter is invalid or not resolved, then the PMON process does not allow the database to start. The following


errors occur:

ORA-00119: invalid specification for system parameter LOCAL_LISTENER

ORA-00132: syntax error or unresolved network name ’%s


註冊非默認監聽方法


When configuring the listener to listen on TCP/IP, you should enter the default port of 1521. If you do not, you must configure the LOCAL_LISTENER parameter in the intialization parameter file and resolve the listener name through a naming method.


網上有個實驗文章 http://blog.csdn.net/t0nsha/article/details/6630348

(1)新增兩個測試的監聽,listener.ora的配置內容(可純手動編輯該文件或使用netca)如下:

(LISTENER爲系統原有;L1、L2爲測試用新增的監聽)

  1. # listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  2. # Generated by Oracle configuration tools.  

  3. L2 =  

  4.  (DESCRIPTION_LIST =  

  5.    (DESCRIPTION =  

  6.      (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1523))  

  7.    )  

  8.  )  

  9. L1 =  

  10.  (DESCRIPTION_LIST =  

  11.    (DESCRIPTION =  

  12.      (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1522))  

  13.    )  

  14.  )  

  15. SID_LIST_LISTENER =  

  16.  (SID_LIST =  

  17.    (SID_DESC =  

  18.      (SID_NAME = PLSExtProc)  

  19.      (ORACLE_HOME = D:\oracle\product\10.2.0\db_1)  

  20.      (PROGRAM = extproc)  

  21.    )  

  22.  )  

  23. LISTENER =  

  24.  (DESCRIPTION_LIST =  

  25.    (DESCRIPTION =  

  26.      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))  

  27.      (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))  

  28.    )  

  29.  )  


(2)配置tnsnames.ora,使數據庫(t02)可同時使用以上3個監聽:

  1. # tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora  

  2. # Generated by Oracle configuration tools.  

  3. T01 =  

  4.  (DESCRIPTION =  

  5.    (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))  

  6.    (CONNECT_DATA =  

  7.      (SERVER = DEDICATED)  

  8.      (SERVICE_NAME = t01)  

  9.    )  

  10.  )  

  11. T02 =  

  12.  (DESCRIPTION =  

  13.    (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))  

  14.    (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1522))  

  15.    (ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1523))  

  16.    (CONNECT_DATA =  

  17.      (SERVER = DEDICATED)  

  18.      (SERVICE_NAME = t02)  

  19.    )  

  20.  )  

  21. EXTPROC_CONNECTION_DATA =  

  22.  (DESCRIPTION =  

  23.    (ADDRESS_LIST =  

  24.      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))  

  25.    )  

  26.    (CONNECT_DATA =  

  27.      (SID = PLSExtProc)  

  28.      (PRESENTATION = RO)  

  29.    )  

  30.  )  


(3)檢查及測試,發現問題:

檢查的時候發現除了默認的LISTENER監聽外,L1和L2始終不能註冊服務:

  1. C:\>lsnrctl  

  2. LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 24-7月 -2011 22:19:24  

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

  4. 歡迎來到LSNRCTL, 請鍵入"help"以獲得信息。  

  5. LSNRCTL> status  

  6. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))  

  7. LISTENER 的 STATUS  

  8. ------------------------

  9. 別名                      LISTENER  

  10. 版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production  

  11. 啓動日期                  24-7月 -2011 22:14:18  

  12. 正常運行時間              0 天 0 小時 5 分 13 秒  

  13. 跟蹤級別                  off

  14. 安全性                    ON: Local OS Authentication  

  15. SNMP                      OFF

  16. 監聽程序參數文件          D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  17. 監聽程序日誌文件          D:\oracle\product\10.2.0\db_1\network\log\listener.log  

  18. 監聽端點概要...  

  19.  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))  

  20.  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1521)))  

  21. 服務摘要..  

  22. 服務 "+ASM_XPT" 包含 1 個例程。  

  23.  例程 "+asm", 狀態 BLOCKED, 包含此服務的 1 個處理程序...  

  24. 服務 "+asm" 包含 1 個例程。  

  25.  例程 "+asm", 狀態 BLOCKED, 包含此服務的 1 個處理程序...  

  26. 服務 "PLSExtProc" 包含 1 個例程。  

  27.  例程 "PLSExtProc", 狀態 UNKNOWN, 包含此服務的 1 個處理程序...  

  28. 服務 "t01" 包含 1 個例程。  

  29.  例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...  

  30. 服務 "t01XDB" 包含 1 個例程。  

  31.  例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...  

  32. 服務 "t01_XPT" 包含 1 個例程。  

  33.  例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...  

  34. 命令執行成功  

  35. LSNRCTL> stop  

  36. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))  

  37. 命令執行成功  

  38. LSNRCTL> set curr L1  

  39. 目前的監聽程序爲 L1  

  40. LSNRCTL> status  

  41. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1522)))  

  42. LISTENER 的 STATUS  

  43. ------------------------

  44. 別名                      L1  

  45. 版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production  

  46. 啓動日期                  24-7月 -2011 22:14:19  

  47. 正常運行時間              0 天 0 小時 5 分 26 秒  

  48. 跟蹤級別                  off

  49. 安全性                    ON: Local OS Authentication  

  50. SNMP                      OFF

  51. 監聽程序參數文件          D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  52. 監聽程序日誌文件          D:\oracle\product\10.2.0\db_1\network\log\l1.log  

  53. 監聽端點概要...  

  54.  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1522)))  

  55. 監聽程序不支持服務  

  56. 命令執行成功  

  57. LSNRCTL> set curr L2  

  58. 目前的監聽程序爲 L2  

  59. LSNRCTL> status  

  60. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1523)))  

  61. LISTENER 的 STATUS  

  62. ------------------------

  63. 別名                      L2  

  64. 版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production  

  65. 啓動日期                  24-7月 -2011 22:14:19  

  66. 正常運行時間              0 天 0 小時 5 分 38 秒  

  67. 跟蹤級別                  off

  68. 安全性                    ON: Local OS Authentication  

  69. SNMP                      OFF

  70. 監聽程序參數文件          D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  71. 監聽程序日誌文件          D:\oracle\product\10.2.0\db_1\network\log\l2.log  

  72. 監聽端點概要...  

  73.  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1523)))  

  74. 監聽程序不支持服務  

  75. 命令執行成功  


停止了默認的LISTENER監聽後,使用tns進行連接測試的時候報錯(ORA-12514):

  1. C:\Documents and Settings\Administrator>sqlplus scott/tiger@t02  

  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:20:06 2011  

  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  

  4. ERROR:  

  5. ORA-12514: TNS: 監聽程序當前無法識別連接描述符中請求的服務  


(4)分析問題:

一陣google之後發現,如果默認端口不是1521,則需要設置LOCAL_LISTENER來手動指定監聽別名:

When configuring the listener to listen on TCP/IP, you should enter the default port of 1521. If you do not, you must configure the LOCAL_LISTENER parameter in the intialization parameter file and resolve the listener name through a naming method.

http://download.oracle.com/docs/cd/B13789_01/network.101/b10775/listenercfg.htm

(5)解決問題(此處的T02爲step 2的tnsnames.ora裏面的T02):

  1. C:\Documents and Settings\Administrator>set oracle_sid=t02  

  2. C:\Documents and Settings\Administrator>sqlplus / as sysdba  

  3. SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:21:55 2011  

  4. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  

  5. 已連接到空閒例程。  

  6. SQL> select status,instance_name from v$instance;  

  7. STATUS                   INSTANCE_NAME  

  8. ------------------------ --------------------------------

  9. OPEN                     t02  

  10. SQL> alter system set local_listener="T02";  

  11. 系統已更改。  

  12. SQL>  


(6)驗證,再測試:

驗證,發現L1、L2已能正常註冊服務:

  1. LSNRCTL> set curr L1  

  2. 目前的監聽程序爲 L1  

  3. LSNRCTL> status  

  4. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1522)))  

  5. LISTENER 的 STATUS  

  6. ------------------------

  7. 別名                      L1  

  8. 版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production  

  9. 啓動日期                  24-7月 -2011 22:14:19  

  10. 正常運行時間              0 天 0 小時 32 分 54 秒  

  11. 跟蹤級別                  off

  12. 安全性                    ON: Local OS Authentication  

  13. SNMP                      OFF

  14. 監聽程序參數文件          D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  15. 監聽程序日誌文件          D:\oracle\product\10.2.0\db_1\network\log\l1.log  

  16. 監聽端點概要...  

  17.  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1522)))  

  18. 服務摘要..  

  19. 服務 "t02" 包含 1 個例程。  

  20.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  21. 服務 "t02XDB" 包含 1 個例程。  

  22.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  23. 服務 "t02_XPT" 包含 1 個例程。  

  24.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  25. 命令執行成功  

  26. LSNRCTL> set curr L2  

  27. 目前的監聽程序爲 L2  

  28. LSNRCTL> status  

  29. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1523)))  

  30. LISTENER 的 STATUS  

  31. ------------------------

  32. 別名                      L2  

  33. 版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production  

  34. 啓動日期                  24-7月 -2011 22:14:19  

  35. 正常運行時間              0 天 0 小時 33 分 6 秒  

  36. 跟蹤級別                  off

  37. 安全性                    ON: Local OS Authentication  

  38. SNMP                      OFF

  39. 監聽程序參數文件          D:\oracle\product\10.2.0\db_1\network\admin\listener.ora  

  40. 監聽程序日誌文件          D:\oracle\product\10.2.0\db_1\network\log\l2.log  

  41. 監聽端點概要...  

  42.  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1523)))  

  43. 服務摘要..  

  44. 服務 "t02" 包含 1 個例程。  

  45.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  46. 服務 "t02XDB" 包含 1 個例程。  

  47.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  48. 服務 "t02_XPT" 包含 1 個例程。  

  49.  例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...  

  50. 命令執行成功  

  51. LSNRCTL>  


再測試,發現scott用戶能夠正常登錄:

  1. C:\Documents and Settings\Administrator>sqlplus scott/tiger@t02  

  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:24:43 2011  

  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  

  4. 連接到:  

  5. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production  

  6. With the Partitioning, OLAP and Data Mining options  

  7. SQL>  

(7)總結

當監聽的端口是默認的1521時,PMON會動態註冊該監聽(listener);

當監聽的端口不是默認的1521時,需要使用alter system set local_listener="T02";來手動註冊監聽。

配置的監聽在lisnrctl.ora文檔和tnsname.ora文檔中都要寫上


本文出自 “無雙城” 博客,請務必保留此出處http://929044991.blog.51cto.com/1758347/1281015

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章