ORA-12514, TNS:listener does not currently know of service requested in connect descriptor案例2

今天使用SQL Developer鏈接一臺測試服務器數據庫(ORACLE 11g)時,遇到了「ORA-12514, TNS:listener does not currently know of service requested in connect descriptor」錯誤,具體提示以下所示:html

 

執行請求的操做時遇到錯誤:
 
Listener refused the connection with the following error:
 
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
 
供應商代碼 12514

clip_image001

 

幾年前寫過一篇關於」ORA-12514: TNS: 監聽程序當前沒法識別鏈接描述符中請求的服務「的案例文章,如今看來當時寫的比較膚淺和粗糙,固然案例也不同,下面在總結一下如何處理ORA-12514這個錯誤吧。 sql

 

Step 1: 首先檢查客戶端的tnsnames.ora裏面的host、port、service_name等是否正確數據庫

myvm =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.57.15)(PORT = 1521))
    )
    (CONNECT_DATA =
       (SERVER = SHARED)
      (SERVICE_NAME = gsp.localdomain)
      
    )
  )

逐一仔細檢查事後發現這些配置都是正確的。 其實前幾天仍是正常來的。測試服務器和tnsnames.ora都沒有改動過。因此咱們繼續後面排查。 服務器

 

Step 2:檢查確認數據庫實例是否啓動。網絡

SQL> select status from v$instance;
 
STATUS
------------
OPEN
 
SQL> 

 

如上所示,數據庫實例正常,並無關閉。當數據庫實例異常關閉,也會出現ORA-12514錯誤,以下所示(若是我關閉一數據庫實例,而後使用SQL*Plus測試鏈接數據庫就會遇到這個錯誤):oracle

C:\Users>sqlplus system/123456@mydb
 
SQL*Plus: Release 11.2.0.1.0 Production on 星期三 4月 12 11:56
 
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
 
ERROR:
ORA-12514: TNS: 監聽程序當前沒法識別鏈接描述符中請求的服務

 

Step 3:檢查網絡是否正常,tnsping可否ping通 app

 

以下所示,ping 和tnsping 均都正常 dom

clip_image002

 

監聽服務也正常,沒有問題tcp

[oracle@DB-Server admin]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-APR-2017 10:36:40
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                12-APR-2017 10:31:20
Uptime                    0 days 0 hr. 5 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/DB-Server/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB-Server.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully

clip_image003

 

Step 4:檢查$ORACLE_BASE/diag/tnslsnr/DB-Server/listener/alert下的日誌,發現host_addr爲10.20.34.76,實際IP地址不是這個。由於監聽文件裏面我使用的hostname DB-Server.localdomain,因此趕忙檢查/etc/hosts的配置 oop

 

clip_image004

[root@DB-Server ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr B0:83:FE:55:32:E5  
          inet addr:10.20.57.15  Bcast:10.20.57.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2363981 errors:0 dropped:0 overruns:0 frame:0
          TX packets:180048 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:225925147 (215.4 MiB)  TX bytes:14349633 (13.6 MiB)
          Interrupt:233 Base address:0x4000 
 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3692 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3692 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2982961 (2.8 MiB)  TX bytes:2982961 (2.8 MiB)
 
[root@DB-Server ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
10.20.34.76        DB-Server.localdomain DB-Server
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
[root@DB-Server ~]# 

clip_image005

 

果真發現/etc/hosts下配置爲10.20.34.76, 具體緣由是由於IT部門調換辦公室,從三樓撤到二樓,將這臺PC搬下來後,服務器IP地址變化了,修改/etc/hosts,而後重啓監聽服務,問題解決。

相關文章
相關標籤/搜索