在集羣環境或非集羣環境中,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爲測試用新增的監聽)
# listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
L2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1523))
)
)
L1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1522))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))
)
)
(2)配置tnsnames.ora,使數據庫(t02)可同時使用以上3個監聽:
# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
T01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = t01)
)
)
T02 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = PC1255-20110528)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = t02)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
(3)檢查及測試,發現問題:
檢查的時候發現除了默認的LISTENER監聽外,L1和L2始終不能註冊服務:
C:\>lsnrctl
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 24-7月 -2011 22:19:24
Copyright (c) 1991, 2005, Oracle. All rights reserved.
歡迎來到LSNRCTL, 請鍵入"help"以獲得信息。
LSNRCTL> status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
LISTENER 的 STATUS
------------------------
別名 LISTENER
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
啓動日期 24-7月 -2011 22:14:18
正常運行時間 0 天 0 小時 5 分 13 秒
跟蹤級別 off
安全性 ON: Local OS Authentication
SNMP OFF
監聽程序參數文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
監聽程序日誌文件 D:\oracle\product\10.2.0\db_1\network\log\listener.log
監聽端點概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1521)))
服務摘要..
服務 "+ASM_XPT" 包含 1 個例程。
例程 "+asm", 狀態 BLOCKED, 包含此服務的 1 個處理程序...
服務 "+asm" 包含 1 個例程。
例程 "+asm", 狀態 BLOCKED, 包含此服務的 1 個處理程序...
服務 "PLSExtProc" 包含 1 個例程。
例程 "PLSExtProc", 狀態 UNKNOWN, 包含此服務的 1 個處理程序...
服務 "t01" 包含 1 個例程。
例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t01XDB" 包含 1 個例程。
例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t01_XPT" 包含 1 個例程。
例程 "t01", 狀態 READY, 包含此服務的 1 個處理程序...
命令執行成功
LSNRCTL> stop
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
命令執行成功
LSNRCTL> set curr L1
目前的監聽程序爲 L1
LSNRCTL> status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1522)))
LISTENER 的 STATUS
------------------------
別名 L1
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
啓動日期 24-7月 -2011 22:14:19
正常運行時間 0 天 0 小時 5 分 26 秒
跟蹤級別 off
安全性 ON: Local OS Authentication
SNMP OFF
監聽程序參數文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
監聽程序日誌文件 D:\oracle\product\10.2.0\db_1\network\log\l1.log
監聽端點概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1522)))
監聽程序不支持服務
命令執行成功
LSNRCTL> set curr L2
目前的監聽程序爲 L2
LSNRCTL> status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1523)))
LISTENER 的 STATUS
------------------------
別名 L2
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
啓動日期 24-7月 -2011 22:14:19
正常運行時間 0 天 0 小時 5 分 38 秒
跟蹤級別 off
安全性 ON: Local OS Authentication
SNMP OFF
監聽程序參數文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
監聽程序日誌文件 D:\oracle\product\10.2.0\db_1\network\log\l2.log
監聽端點概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1523)))
監聽程序不支持服務
命令執行成功
停止了默認的LISTENER監聽後,使用tns進行連接測試的時候報錯(ORA-12514):
C:\Documents and Settings\Administrator>sqlplus scott/tiger@t02
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:20:06 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
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):
C:\Documents and Settings\Administrator>set oracle_sid=t02
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:21:55 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已連接到空閒例程。
SQL> select status,instance_name from v$instance;
STATUS INSTANCE_NAME
------------------------ --------------------------------
OPEN t02
SQL> alter system set local_listener="T02";
系統已更改。
SQL>
(6)驗證,再測試:
驗證,發現L1、L2已能正常註冊服務:
LSNRCTL> set curr L1
目前的監聽程序爲 L1
LSNRCTL> status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1522)))
LISTENER 的 STATUS
------------------------
別名 L1
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
啓動日期 24-7月 -2011 22:14:19
正常運行時間 0 天 0 小時 32 分 54 秒
跟蹤級別 off
安全性 ON: Local OS Authentication
SNMP OFF
監聽程序參數文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
監聽程序日誌文件 D:\oracle\product\10.2.0\db_1\network\log\l1.log
監聽端點概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1522)))
服務摘要..
服務 "t02" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t02XDB" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t02_XPT" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
命令執行成功
LSNRCTL> set curr L2
目前的監聽程序爲 L2
LSNRCTL> status
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=PC1255-20110528)(PORT=1523)))
LISTENER 的 STATUS
------------------------
別名 L2
版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
啓動日期 24-7月 -2011 22:14:19
正常運行時間 0 天 0 小時 33 分 6 秒
跟蹤級別 off
安全性 ON: Local OS Authentication
SNMP OFF
監聽程序參數文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
監聽程序日誌文件 D:\oracle\product\10.2.0\db_1\network\log\l2.log
監聽端點概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=PC1255-20110528)(PORT=1523)))
服務摘要..
服務 "t02" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t02XDB" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
服務 "t02_XPT" 包含 1 個例程。
例程 "t02", 狀態 READY, 包含此服務的 1 個處理程序...
命令執行成功
LSNRCTL>
再測試,發現scott用戶能夠正常登錄:
C:\Documents and Settings\Administrator>sqlplus scott/tiger@t02
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 7月 24 22:24:43 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
(7)總結
當監聽的端口是默認的1521時,PMON會動態註冊該監聽(listener);
當監聽的端口不是默認的1521時,需要使用alter system set local_listener="T02";來手動註冊監聽。
配置的監聽在lisnrctl.ora文檔和tnsname.ora文檔中都要寫上
本文出自 “無雙城” 博客,請務必保留此出處http://929044991.blog.51cto.com/1758347/1281015