TNS-03505 名稱無法解析

來源:互聯網
上載者:User

TNS-03505 名稱無法解析

TNS-03505 名稱無法解析

問題現象:

[Oracle@db01 admin]$ tnsping pri
 


TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 15-JUN-2015 21:57:52
Copyright (c) 1997, 2013, Oracle. All rights reserved.

Used parameter files:

TNS-03505: Failed to resolve name

 
[oracle@db01 admin]$ sqlplus system/oracle@pri

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 15 21:58:48 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.

ERROR:

ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: ^C

問題分析:
    出現該問題的原因通常有兩個:1、名稱不存在  2、tns設定檔不存在。

問題處理:

1、首先檢查tnsnames.ora的所有配置資訊,一切正常沒有任何問題。

[oracle@db01 admin]$ cat tnsname.ora
 
pri =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.50)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = woo)

    )

  )

2、檢查tnsnames.ora的檔案及檔案所屬使用者及使用者組 

[oracle@db01 admin]$ ll tnsnames.ora
 
-rwxr--r-- 1 oracle oinstall 350 Jun 16 22:04 tnsname.ora

#從這裡來看也是沒有問題,檔案是屬於oinstall使用者組,及其所有許可權也是Oracle

3、那麼這個時候我們選擇跳過tnsnames.ora通過手工登陸進行驗證資料庫是否正常

[oracle@db01 admin]$ sqlplus system/oracle@192.168.1.50/woo
 


SQL*Plus: Release 11.2.0.4.0 Production on Tue Jun 16 22:34:40 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining,

Oracle Database Vault and Real Application Testing options


 
             
SQL> select name from v$database;

NAME

---------

WOO

SQL> select instance_name,status from v$instance;

INSTANCE_NAME STATUS

---------------- ------------

woo OPEN

SQL>

#從這裡我們可以看到,資料庫肯定是沒有問題的,那麼下一步我們通過拿一個好的監聽檔案替換這個監聽檔案來處理該問題。

4、通過上傳一個之前可用的監聽設定檔進行對比

[oracle@db01 admin]$ ls
 
listener.ora samples shrept.lst sqlnet.ora tnsname.ora tnsnames.ora

[oracle@db01 admin]$ chmod u+x tnsnames.ora

[oracle@db01 admin]$ ll

total 24

-rwxr-xr-x 1 oracle oinstall 711 Jun 16 22:08 listener.ora

drwxr-xr-x 2 oracle oinstall 4096 Jun 11 21:56 samples

-rw-r--r-- 1 oracle oinstall 381 Dec 17 2012 shrept.lst

-rw-r--r-- 1 oracle oinstall 221 Jun 16 21:59 sqlnet.ora

-rwxr--r-- 1 oracle oinstall 350 Jun 16 22:31 tnsname.ora

-rwxr--r-- 1 oracle oinstall 350 Jun 16 22:04 tnsnames.ora ----這個是後面上傳的


#通過對比,我發現之前手工些的那個檔案名稱不對,即使裡面內容正確也無濟於事。

5、通過修改替換監聽檔案,該問題得到解決:

[oracle@db01 admin]$ cat tnsname.ora > tnsnames.ora
 


[oracle@db01 admin]$ rm -rf tnsname.ora

[oracle@db01 admin]$ sqlplus system/oracle@pri

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jun 16 23:02:15 2015

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining,

Oracle Database Vault and Real Application Testing options

SQL> select name from v$database;

NAME

---------

WOO

SQL> select instance_name,status from v$instance;

INSTANCE_NAME STATUS

---------------- ------------

woo OPEN

SQL>

SQL> host ls -rtl

total 20

-rw-r--r-- 1 oracle oinstall 381 Dec 17 2012 shrept.lst

drwxr-xr-x 2 oracle oinstall 4096 Jun 11 21:56 samples

-rw-r--r-- 1 oracle oinstall 221 Jun 16 21:59 sqlnet.ora

-rwxr-xr-x 1 oracle oinstall 711 Jun 16 22:08 listener.ora

-rwxr--r-- 1 oracle oinstall 350 Jun 16 23:02 tnsnames.ora

SQL>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.