配置好rac后,兩個(gè)節(jié)點(diǎn)用tnsping都可以ping通,但用sqlplus連接都出現(xiàn)以下錯(cuò)誤,不知道哪里出了問(wèn)題
[oracle@rac2 admin]$ lsnrctl status
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 04-MAR-2008 08:32:26
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac2)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date 04-MAR-2008 08:29:03
Uptime 0 days 0 hr. 3 min. 22 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /home/oracle/9.2.0.4/network/admin/listener.ora
Listener Log File /home/oracle/9.2.0.4/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac2)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "esal" has 2 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
Instance "rac2", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@rac2 admin]$ lsnrctl service
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 04-MAR-2008 08:32:32
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac2)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "esal" has 2 instance(s).
Instance "rac1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(address=(protocol=tcp)(host=rac1)(port=1521))
Instance "rac2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully
[oracle@rac2 admin]$ sqlplus cy/zh@esal
SQL*Plus: Release 9.2.0.4.0 - Production on Tue Mar 4 08:32:45 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve service name
Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name: cy/zh@rac1
ERROR:
ORA-12154: TNS:could not resolve service name
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@rac2 admin]$ sqlplus cy/zh@rac2
SQL*Plus: Release 9.2.0.4.0 - Production on Tue Mar 4 08:32:59 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve service name
Enter user-name:
按照如下過(guò)程,一般都能解決:
在虛擬機(jī)內(nèi)開(kāi)cmd,用lsnrctl status查看監(jiān)聽(tīng)器監(jiān)聽(tīng)的服務(wù)
如看到監(jiān)聽(tīng)服務(wù)“orcl”,那在本機(jī)的tns配置中(SERVICE_NAME = orcl)必須寫orcl;如果想要自定義,則在虛擬機(jī)內(nèi)的listener配置中就要加入自定義服務(wù)名,記得要重啟監(jiān)聽(tīng)服務(wù):lsnrctl reload
最后形成的配置文件如下
虛擬機(jī)listener:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test) 自定義服務(wù)名
(ORACLE_HOME = E:oracleproduct10.2.0db_1) db_home
(SID_NAME = test)
)
(SID_DESC =
(PROGRAM = extproc)
(SID_NAME = PLSExtProc)
(ORACLE_HOME = E:oracleproduct10.2.0db_1) ##這個(gè)服務(wù)保證你可以使用外部過(guò)程,如C程序
)
)
本機(jī)tns:
ORCL_XNJ =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 182.12.15.232)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test) 與自定義服務(wù)名對(duì)應(yīng)
)
)
再次連接,問(wèn)題解決!
記住,一定從最簡(jiǎn)單的原因找起,不要一上去就看到網(wǎng)上的什么改process數(shù)、注冊(cè)表之類的,要想想本機(jī)能連為什么通過(guò)網(wǎng)絡(luò)就不行,還是定位問(wèn)題。
VS2008連接oracle 出現(xiàn)錯(cuò)誤 ora-12154 tns 無(wú)法解析指定的連接標(biāo)示符
在保證你的代碼沒(méi)有錯(cuò)誤的前提下:
(一)檢查OracleOraDb10g_home1TNSListener 服務(wù)有沒(méi)有啟動(dòng),即監(jiān)聽(tīng)服務(wù)
(二)檢查tnsnames.ora是否添加連接串(建議用SQLPLUS或者pl/sql測(cè)試),其路徑一般是:%Oracle_home%product10.2.0db_1NETWORKADMINtnsnames.ora
其它網(wǎng)友的補(bǔ)充:
今天裝oracle安裝都完成了,但出現(xiàn)了“ORA-12154 TNS”的錯(cuò)誤,最開(kāi)始以為是oracle安裝處了問(wèn)題,但后來(lái)發(fā)現(xiàn)并不是,因?yàn)橛肧QL Plus可以登錄,只是用plsql登錄時(shí)才出現(xiàn)這錯(cuò),用360完全卸載了qlsql后,從新裝了次,還是那錯(cuò),郁悶。。。后來(lái)又把數(shù)據(jù)庫(kù)刪掉重新建立,還是不行,整了半天,最后自己都整暈了,算了,重頭再來(lái)吧。。。
百度下很多安裝圖解,按著來(lái)就成
oracle服務(wù)端安裝圖解
https://www.jb51.net/article/108555.htm
oracle客戶端安裝圖解
https://www.jb51.net/article/108556.htm
oracle完全卸載
https://www.jb51.net/article/96395.htm
或者直接在注冊(cè)表中按F3搜索oracle,刪除注冊(cè)文件,不過(guò)貌似文件有點(diǎn)多,操作有點(diǎn)慢,建議用上邊鏈接的方法
總結(jié)了下要注意的幾點(diǎn)
1.安裝服務(wù)端是一般選“基本安裝”就行
2.使用PLSQL Developer時(shí),“ORA-12154 TNS無(wú)法解析指定的連接標(biāo)識(shí)符”的問(wèn)題
安裝時(shí)報(bào)后邊的錯(cuò)“warning some oracle net versions cannot connect from a path with parentheses”,這錯(cuò)原來(lái)提示了,不能有括號(hào),修改了安裝路徑就沒(méi)有問(wèn)題了
相應(yīng)的上邊的“ORA-12154 TNS無(wú)法解析指定的連接標(biāo)識(shí)符”錯(cuò)也沒(méi)啦,有點(diǎn)暈,沒(méi)整明白,但確實(shí)好啦
3.“ORA-12154 TNS無(wú)法解析指定的連接標(biāo)識(shí)符”按照網(wǎng)上的方法有兩種,但我試了,在我這都不好使,下邊貼出來(lái),沒(méi)準(zhǔn)兒啥時(shí)候可以用
1.解決辦法,修改PLSQL Developer的選項(xiàng)設(shè)置:
客戶端、服務(wù)器端Oracle軟件裝好之后,用PLSQL Devloper登錄時(shí),點(diǎn)擊取消,進(jìn)入PLSQL Developer主界面,菜單Tools-Preferences,在設(shè)置窗口中,選擇Oracle-Connection,對(duì)應(yīng)設(shè)置窗口中,找到Oracle Home,選擇OraDb10g_home1,保存設(shè)置,重新登錄PLSQL Developer即可
2.修改D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN路徑下的tnsnames.ora文件
###### 一般的配置 ##################################
ORALOCAL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oralocal)
)
)
以上答案供參考
您可能感興趣的文章:- 與虛擬機(jī)Oracle連接出現(xiàn)ora-12154問(wèn)題的解決方法
- Oracle導(dǎo)dmp出現(xiàn)文件ORA-12154: TNS: 無(wú)法解析指定的連接標(biāo)識(shí)符問(wèn)題的解決方案
- plsql連接oracle數(shù)據(jù)庫(kù)報(bào)ora 12154錯(cuò)誤解決方法
- Oracle出現(xiàn)ora-12154無(wú)法解析指定連接標(biāo)識(shí)符的解決方法