配置tnsnames.ora遇到的幾個問題總結

pingley發表於2012-02-25
配置tnsnames.ora遇到的幾個問題總結
今天打算在本地配置下tnsnames.ora,以便方便的訪問虛擬機器中的資料庫,這樣就可以不需要用secure crt進入到linux主機再進入資料庫了。其中遇到了幾個問題,總結如下:
在windows cmd中連線目標資料庫的時候遇到
ORA-12541: TNS: 無監聽程式
ERROR:
[oracle@zeng ~]$ oerr ora 12541
12541, 00000, "TNS:no listener"
// *Cause: The connection request could not be completed because the listener
// is not running.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry with
// the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to
// go by way of an Interchange). Start the listener on the remote machine.
檢視監聽程式的狀態
[oracle@zeng ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-FEB-2012 12:16:09
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
啟動監聽程式
[oracle@zeng ~]$ lsnrctl start 
總結:原因是目標主機中資料庫的監聽程式沒有啟動。
ORA-12545: 因目標主機或物件不存在, 連線失敗
[oracle@zeng ~]$ oerr ora 12545
12545, 00000, "Connect failed because target host or object does not exist"
// *Cause: The address specified is not valid, or the program being 
// connected to does not exist.
// *Action: Ensure the ADDRESS parameters have been entered correctly; the
// most likely incorrect parameter is the node name.  Ensure that the 
// executable for the server exists (perhaps "oracle" is missing.)
// If the protocol is TCP/IP, edit the TNSNAMES.ORA file to change the
// host name to a numeric IP address and try again.
原tnsnames,ora中的內容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =zeng)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl.zeng.com)
    )
  )
修改以後的tnsnames.ora中的內容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.101)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl.zeng.com)
    )
  )
總結:原因是目標主機不存在,或者DNS無法解析主機名,嘗試換成主機的IP地址。
ORA-12514: TNS: 監聽程式當前無法識別連線描述符中請求的服務
可以使用下面的命令具體的檢視錯誤資訊,不過上面的提示已經很清楚了。
[oracle@zeng ~]$ oerr ora 12514
修改tnsmame.ora中的內容
oracl= (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.101)(PORT =1521))
    (CONNECT_DATA =
      (SERVICE_NAME = oracl)
    )
  )
即SERVICE_NAME = oracl.zeng.com修改成SERVICE_NAME = oracl
總結:因為資料庫服務名預設是和全域性資料庫服務名一致的,我把資料庫全域性名當資料庫服務名用了。我要連線的資料庫中的資料庫服務名與全域性資料庫名沒有配置成一致。

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

相關文章