1、解決方法 在oracle設(shè)置ODBC及出現(xiàn)oracle提示TNS:無監(jiān)聽程序的解決辦法 2009年10月16日 星期五 11:42 設(shè)置ODBC
ODBC的全名是Open Database Connectivity(開放式數(shù)據(jù)庫連接),,是應(yīng)用程序連接數(shù)據(jù)庫的接口,。由于計算機(jī)的類型不同,從個人計算機(jī)到大型主機(jī),,都有自己處理數(shù)據(jù)的方式,,ODBC則可以連接到相同或不相同的數(shù)據(jù)庫管理系統(tǒng),因此,,ODBC可以給應(yīng)用程序提供相同的存取數(shù)據(jù)庫的接口,,程序設(shè)計員在設(shè)計連接不同數(shù)據(jù)庫時,只要處理與ODBC的連接就可以了,,而不必針對不同的數(shù)據(jù)庫設(shè)計完全不同的程序,。特別需要提醒的是,,不同的數(shù)據(jù)庫都有自己對應(yīng)的ODBC驅(qū)動程序,在使用不同數(shù)據(jù)庫的同時,,務(wù)必設(shè)置正確的ODBC驅(qū)動程序,。就像在本節(jié)中,,想要連接Oracle 10g數(shù)據(jù)庫,,就必須設(shè)置Oracle ODBC驅(qū)動程序,,操作步驟如下: (1)選擇Start→Programs→Oracle-OraDb10g_home1→Configuration and Migration Tools→Microsoft ODBC Administrator (2)打開ODBC Data Source Administrator,, (3)單擊System DSN標(biāo)簽 (4)單擊Add按鈕 (5)向下拖動滾動條,,找到Oracle in OraDb10g_home1選項,選擇該選項 (6)單擊Finish按鈕,,進(jìn)入Oracle ODBC Driver Configuration對話框 Data Source Name:自定義,,程序調(diào)用時將使用這個名稱,請輸入misdbdsn,。 TNS Service Name:Oracle TNS服務(wù)名稱,,在創(chuàng)建數(shù)據(jù)庫時,一般默認(rèn)TNS服務(wù)名稱與數(shù)據(jù)庫名稱相同,,請輸入MISDB,,讀者也可以自定義。 User ID:用戶的賬戶名稱,,這里使用System賬戶來測試,。 (7)單擊Test Connection按鈕,出現(xiàn)Oracle ODBC Driver Connect對話框,,如圖13-10所示,。 Password:請輸入安裝時給System設(shè)置的密碼,或自行修改后的密碼,。 如果出現(xiàn)oracle提示ERROR - ORA-12541: TNS:無監(jiān)聽程序,,那么就依照下列步驟做,這是因?yàn)槟愕姆峙涞牡刂凡粚Α?br>查看\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora文件,,用記事本打開,,顯示oracle值: ORACLE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =自動分配的IP地址)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oracle) ) ) 主機(jī)名輸入localhost或127.0.0.1都會提示無監(jiān)聽程序。由于自動分配的IP地址會有變動,,所以將oralce值中的host改成本機(jī)的計算機(jī)名,,保存修改后的tnsnames.ora。再次新建數(shù)據(jù)庫,,出錯問題解決,。 # tnsnames.ora Network Configuration File: G:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. ORACLE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =計算機(jī)名稱)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oracle) ) ) 計算機(jī)名稱可以右擊‘我的電腦’找到 (8)單擊OK按鈕 (9)單擊OK按鈕,回到Oracle ODBC Driver Configuration對話框 (10)單擊OK按鈕,,回到ODBC Data Source Administrator的System DNS選項卡 (11)單擊OK按鈕,,完成ODBC的設(shè)置,。 2、解決方式: <轉(zhuǎn)>改變oracle數(shù)據(jù)庫的ip地址引起的“ORA-12541:TNS:無監(jiān)聽程序”錯誤解決方法,! 2009-10-11 05:25 P.M.
在用PL/SQL Developer連接數(shù)據(jù)庫時出現(xiàn) “ORA-12541:TNS:無監(jiān)聽程序”錯誤,。
1、檢查listener.log日志 發(fā)現(xiàn)下面錯誤: TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 10:25:26 Copyright (c) 1991, 2005, Oracle. All rights reserved. 系統(tǒng)參數(shù)文件為D:\oracle\product\10.2.0\db_1\network\admin\listener.ora 寫入D:\oracle\product\10.2.0\db_1\network\log\listener.log的日志信息 寫入D:\oracle\product\10.2.0\db_1\network\trace\listener.trc的跟蹤信息 跟蹤級別當(dāng)前為0 以 pid=1704 開始 監(jiān)聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc))) 監(jiān)聽該對象時出錯: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.5.0.5)(PORT=1521))) TNS-12545: 因目標(biāo)主機(jī)或?qū)ο蟛淮嬖? 連接失敗 TNS-12560: TNS: 協(xié)議適配器錯誤 TNS-00515: 因目標(biāo)主機(jī)或?qū)ο蟛淮嬖? 連接失敗 32-bit Windows Error: 49: Unknown error 不再監(jiān)聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
2,、查看Oracle的listener是否啟動 C:\Documents and Settings\mengzhaoliang>lsnrctl status LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 10:5 0:44 Copyright (c) 1991, 2005, Oracle. All rights reserved. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) TNS-12541: TNS: 無監(jiān)聽程序 TNS-12560: TNS: 協(xié)議適配器錯誤 TNS-00511: 無監(jiān)聽程序 32-bit Windows Error: 2: No such file or directory 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.5.0.5)(PORT=1521))) TNS-12535: TNS: 操作超時 TNS-12560: TNS: 協(xié)議適配器錯誤 TNS-00505: 操作超時 32-bit Windows Error: 60: Unknown error 原來沒有啟動listener,,用“lsnrctl start”命令也不能啟動。 C:\Documents and Settings\mengzhaoliang>lsnrctl start LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 10:5 2:16 Copyright (c) 1991, 2005, Oracle. All rights reserved. 啟動tnslsnr: 請稍候... TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production 系統(tǒng)參數(shù)文件為D:\oracle\product\10.2.0\db_1\network\admin\listener.ora 寫入D:\oracle\product\10.2.0\db_1\network\log\listener.log的日志信息 監(jiān)聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc))) 監(jiān)聽該對象時出錯: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.5.0.5)(PORT=1521)) ) TNS-12545: 因目標(biāo)主機(jī)或?qū)ο蟛淮嬖? 連接失敗 TNS-12560: TNS: 協(xié)議適配器錯誤 TNS-00515: 因目標(biāo)主機(jī)或?qū)ο蟛淮嬖? 連接失敗 32-bit Windows Error: 49: Unknown error 監(jiān)聽程序未能啟動,。請參閱上面的錯誤消息... 3,、查看listener.ora的內(nèi)容: # listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora # Generated by Oracle configuration tools. 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 = 0.5.0.5)(PORT = 1521)) ) ) 原來本機(jī)的ip發(fā)生改變后,就出現(xiàn)了上述問題,,改變數(shù)據(jù)庫的監(jiān)聽ip地址: 把(ADDRESS = (PROTOCOL = TCP)(HOST = 0.5.0.5)(PORT = 1521)) 改成 (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) 127.0.0.1:也就是目前數(shù)據(jù)庫正在用的ip地址,。
4、再次啟動oracle的listener C:\Documents and Settings\mengzhaoliang>lsnrctl start LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 10:5 4:40 Copyright (c) 1991, 2005, Oracle. All rights reserved. 啟動tnslsnr: 請稍候... TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production 系統(tǒng)參數(shù)文件為D:\oracle\product\10.2.0\db_1\network\admin\listener.ora 寫入D:\oracle\product\10.2.0\db_1\network\log\listener.log的日志信息 監(jiān)聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc))) 監(jiān)聽: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) LISTENER 的 STATUS ------------------------ 別名 LISTENER 版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ ction 啟動日期 20-9月 -2008 10:54:41 正常運(yùn)行時間 0 天 0 小時 0 分 1 秒 跟蹤級別 off 安全性 ON: Local OS Authentication SNMP OFF 監(jiān)聽程序參數(shù)文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.o ra 監(jiān)聽程序日志文件 D:\oracle\product\10.2.0\db_1\network\log\listener.log 監(jiān)聽端點(diǎn)概要... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) 服務(wù)摘要.. 服務(wù) "PLSExtProc" 包含 1 個例程,。 例程 "PLSExtProc", 狀態(tài) UNKNOWN, 包含此服務(wù)的 1 個處理程序... 命令執(zhí)行成功 啟動已經(jīng)成功,,
5.再tnsnames.ora上添加上 ORCL_127.0.0.1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) 6、再次用PL/SQL Developer再次連接數(shù)據(jù)庫 出現(xiàn)下面錯誤: TNS-12514: TNS: 監(jiān)聽程序當(dāng)前無法識別連接描述符中請求的服務(wù) 再次檢查listener.log日志 20-9月 -2008 11:01:54 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)(CID= (PROGRAM=D:\plsql\plsqldev.exe)(HOST=RUIFEI-EF0ADC98)(USER=mengzhaoliang))) * (ADDRESS= (PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1267)) * establish * orcl * 12514 TNS-12514: TNS: 監(jiān)聽程序當(dāng)前無法識別連接描述符中請求的服務(wù) 查看listener: C:\Documents and Settings\mengzhaoliang>lsnrctl services LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 11:1 1:09 Copyright (c) 1991, 2005, Oracle. All rights reserved. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) 服務(wù)摘要.. 服務(wù) "PLSExtProc" 包含 1 個例程,。 例程 "PLSExtProc", 狀態(tài) UNKNOWN, 包含此服務(wù)的 1 個處理程序... 處理程序: "DEDICATED" 已建立:0 已被拒絕:0 LOCAL SERVER 命令執(zhí)行成功
7,、用sqlplus也出現(xiàn)同樣錯誤: C:\Documents and Settings\mengzhaoliang>sqlplusscott/mzl@ORCL_127.0.0.1 SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 9月 20 11:15:09 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. ERROR: ORA-12514: TNS: 監(jiān)聽程序當(dāng)前無法識別連接描述符中請求的服務(wù) 8、查看listenser狀態(tài): C:\Documents and Settings\mengzhaoliang>lsnrctl status LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 -2008 11:2 6:42 Copyright (c) 1991, 2005, Oracle. All rights reserved. 正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) LISTENER 的 STATUS ------------------------ 別名 LISTENER 版本 TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ ction 啟動日期 20-9月 -2008 11:24:33 正常運(yùn)行時間 0 天 0 小時 2 分 8 秒 跟蹤級別 off 安全性 ON: Local OS Authentication SNMP OFF 監(jiān)聽程序參數(shù)文件 D:\oracle\product\10.2.0\db_1\network\admin\listener.o ra 監(jiān)聽程序日志文件 D:\oracle\product\10.2.0\db_1\network\log\listener.log 監(jiān)聽端點(diǎn)概要... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) 服務(wù)摘要.. 服務(wù) "PLSExtProc" 包含 1 個例程,。 例程 "PLSExtProc", 狀態(tài) UNKNOWN, 包含此服務(wù)的 1 個處理程序... 命令執(zhí)行成功 C:\Documents and Settings\mengzhaoliang>tnsping orcl TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 20-9月 - 2008 11:27:43 Copyright (c) 1997, 2005, Oracle. All rights reserved. 已使用的參數(shù)文件: D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora TNS-03505: 無法解析名稱 9,、查看sqlnet.ora內(nèi)容: # sqlnet.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora # Generated by Oracle configuration tools. # This file is actually generated by netca. But if customers choose to # install "Software Only", this file wont exist and without the native # authentication, they will not be able to connect to the database on NT. SQLNET.AUTHENTICATION_SERVICES= (NTS) NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) 10.把listener.ora的內(nèi)容: # listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora # Generated by Oracle configuration tools. 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 = 127.0.0.1)(PORT = 1521)) ) )
改成下面的內(nèi)容: # listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = orcl) (ORACLE_HOME = D:\oracle\product\10.2.0\db_1) # (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = orcl)) (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) ) 11、然后關(guān)閉,、再啟動listener 在cmd中執(zhí)行“lsnrctl stop” 和“lsnrctl stop”命令,,再次登陸正常! C:\Documents and Settings\mengzhaoliang>sqlplus scott/mzl@orcl SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 9月 20 11:55:47 2008 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>
再次用PL/SQL Peveloper登陸就沒有問題了,。 完畢! 我通過以上步驟我的問題還沒解決,,然后重啟了一下OracleOraDb10g_home1TNSListener服務(wù)就行了
|