zoukankan      html  css  js  c++  java
  • ORA12154: TNS:could not resolve the connect identifier specified

    Hit a error while trying to connect one oracle database. Normally this should because the tnsname.ora not configured right. Firstly I can sure that the database and listener is working fine. Because there is client connecting to database. So it definitely the local tnsname configuration. So I check the tns config and didn`t find any wrong. The config is like

    DBORA816.BHR.COM.CN =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = pndb)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = dbora816)
        )
      )
    

    I didnt see anything wrong with this config. So i did a tnsping like below  

    bash-2.05$ tnsping DBORA816
    
    TNS Ping Utility for Solaris: Version 10.2.0.5.0 - Production on 29-MAY-2013 11:21:35
    
    Copyright (c) 1997,  2010, Oracle.  All rights reserved.
    
    Used parameter files:
    /opt/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
    
    TNS-03505: Failed to resolve name
    

    Seems another parameter file is involved. sqlnet.ora. Check the file content

    bash-2.05$ cat sqlnet.ora
    # sqlnet.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
    # Generated by Oracle configuration tools.
    
    NAMES.DIRECTORY_PATH= (HOSTNAME, TNSNAMES, EZCONNECT)
    
    #NAMES.DEFAULT_DOMAIN = bhr.com.cn
    

    Ok. Now we found the problem. The NAMES.DEFAULT_DOMAIN is commented. The meaning for this line is to attache the domain infor bechind our command. For example, if we do not comment the line. Then the command tnsping DBORA186 will actually be transformed to tnsping DBORA186.bhr.com.cn.  If DBORA186.bhr.com.cn is configured in the tnsname.ora, then we will be able to resolve the tnsname. But here we commented it, so we hit the infor. 

    If you run below command instead, you will also be able to jump over the error.

    tnsping dbora186.bhr.com.cn

    sqlplus user/password@dbora186.bhr.com.cn

    Or you can check below content 

     

    TNS:could not resolve service name

    This error, seen as ORA-12154, means SQL*Net could not find the database alias specified for a database connection in the TNSNAMES.ORA file or other naming adapter. The database alias is specified after the "@" character in a database connection string. For example, if the connect string "SYSTEM/MANAGER@PROD" is used, "PROD" is the database alias.

    How to troubleshoot ORA-12154

    The following is a list of steps to follow when troubleshooting an ORA-12154 error.

    1. Find the Oracle SQL*Net configuration files- there are two main files Oracle uses on the client when connecting to a database, TNSNAMES.ORA and SQLNET.ORA. Oracle will typically scan for these files using the following sequence:
      1. Current Directory - the directory the application was started from. SQL*Plus typically resides in ORACLE_HOME\bin, but if the current directory was C:\TEMP when it started, Oracle will look here first.
      2. TNS_ADMIN - the directory specified by the TNS_ADMIN environment variable or registry entry
      3. /var/opt/oracle (UNIX only)
      4. ORACLE_HOME\network\admin

      Sometimes you can also use the TNSPING utility to determine where the files are located. As part of the output, this utility typically displays the parameters files used.

    2. Determine the converted database alias name that Oracle will use- inside the SQLNET.ORA file determine if a parameter NAMES.DEFAULT_DOMAIN is specified. For example, you may see a line that reads:
      NAMES.DEFAULT_DOMAIN = mycompany.com
      

      In that case, Oracle will append this name to the database alias name to connect to the database. For example, if you use a database alias of PROD, the converted name Oracle will use is "PROD.MYCOMPANY.COM" (case insensitive). If this parameter is not found the converted alias would be "PROD"

    3. Find the converted alias name in the TNSNAMES.ORA file- inside the TNSNAMES.ORA file, search for the converted alias name to find an exact match. A typical entry would look similar to the following (ignoring white spaces):
      PROD.MYCOMPANY.COM = 
      (DESCRIPTION =
      (ADDRESS_LIST =
      (ADDRESS =
      (PROTOCOL = TCP)
      (Host = PRODMACHINE.MYCOMPANY.COM)
      (Port = 1521)))
      (CONNECT_DATA = (SERVICE_NAME = ORCL)))

      If an exact match is not found, you will receive a TNS-12154 error. If you find an entry that looks similar, i.e. the alias in the TNSNAMES.ORA read "PROD" without the domain name appended to it, then either; 1) add the domain to the end of TNSNAMES.ORA alias name; or 2) remove the NAMES.DEFAULT_DOMAIN parameter from the SQLNET.ORA file.

      If no similar matches are found, an entry similar to the one shown above will need to be added to the TNSNAMES.ORA file.

    1. Modify the AUTOMATIC_IPC parameter in SQLNET.ORA - if this parameter is currently set to ON, change it to OFF. If it is currently OFF, change it to ON. Try the connection again.
    2. Verify the TNSNAMES.ORA and SQLNET.ORA files are accessible - If the files exist and appear to be configured properly, verify the permissions are set properly. Try changing the permissions to full open, e.g. if this is UNIX then change the permissions to "rwxrwxrwx" (chmod 777 tnsnames.ora).
    3. Manually configure the environment - if all else fails, set the TNS_ADMIN environment variable to "C:\TEMP" and create a new TNSNAMES.ORA file in that directory. Add the proper entry to the TNSNAMES.ORA file and the connection should work.
  • 相关阅读:
    Cocos Creator 图集 (TexturePacker、自动图集功能 、压缩纹理)
    Cocos Creator 下载不同版本引擎
    Cocos Creator 源码 (位置,阅读、修改)
    Laya3D Unity商店免费下载3D资源使用(Unity插件支持哪些导出)
    三 Laya3D 加载资源 (场景/预设/模型网格/材质/动画文件/贴图/粒子)
    二 Laya3D github demo下载并使用
    一 Laya3D Unity下载和插件安装
    AndroidUI设计之布局-详细解析布局实现
    Android 监听ScrollView的滑动
    【Android进阶】Android程序与JavaScript之间的简单调用
  • 原文地址:https://www.cnblogs.com/kramer/p/3105554.html
Copyright © 2011-2022 走看看