【问题标题】:ODP.NET and managed connections fail with ORA-12154ODP.NET 和托管连接失败并出现 ORA-12154
【发布时间】:2021-04-16 21:45:27
【问题描述】:

我认为通过 Oracle.ManagedDataAccess.Core NuGet 包使用 ODP.Net 托管连接的全部意义在于您不需要在运行时环境中安装 Oracle 客户端。 我发现很多关于这个的帖子

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

错误,但所有关于潜在修复的讨论都围绕客户端配置问题展开。

我完全按照this article 中的描述进行操作。 当我从 Visual Studio 在本地运行该应用程序时,该应用程序连接良好,但是当它由 Azure 管道构建和部署时,它无法连接。来自服务器的连接不是问题,没有 tnsnames.ora 和 sqlnet.ora 文件,也没有 TNS_ADMIN 和 ORA_HOME 环境变量。

2021-02-15T18:04:40.867284043Z       Oracle connection string: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip address>)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<sid>)));User Id=<User>;Password=<Password>;
2021-02-15T18:04:40.871226968Z [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[13]
2021-02-15T18:04:40.871246768Z       Connection id "0HM6HRG9F3OUG", Request id "0HM6HRG9F3OUG:00000004": An unhandled exception was thrown by the application.
2021-02-15T18:04:40.871252068Z       Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
2021-02-15T18:04:40.871255568Z        ---> OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified

我也试过这个 EZ Connect 字符串,但没有成功:

&lt;user&gt;/&lt;password&gt;@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=&lt;ip address&gt;)(Port=&lt;port&gt;))(CONNECT_DATA=(SID=&lt;mysid&gt;)))

我错过了什么?

更新:该问题似乎是由 Azure 混合连接管理器的潜在问题引起的,而不是由 Oracle 连接引起的。现在查看 VPN 连接。暂时保留您尝试不同连接字符串格式的建议。

【问题讨论】:

  • 在连接字符串中使用Data Source=(DESCRIPTION=(ADDRESS_LIST=...

标签: oracle database-connection odp.net-managed


【解决方案1】:

我们会看到输出中的内容,但需要查看您是如何在调用应用程序中实际指定连接字符串的。 ora-12154 是最常见的连接问题之一,在整个互联网上都有所报道。您在 Google 上搜索时发现了什么?

它说您指定了一个无法在客户端的 tnsnames.ora 文件中找到的 tns 连接字符串。由于我不知道您客户的 tnsnames 的内容,也不知道您实际指定了什么,所以我现在不能多说。

但是,如前所述,几乎每个 Oracle 博客和 Internet 上的在线资源都写过此错误。我最喜欢的是这里:https://edstevensdba.wordpress.com/2018/09/19/troubleshooting-ora-12154/

还有。 . . oracle:cdb$ oerr ora 12154 12154, 00000, "TNS:could not resolve the connect identifier specified" // *Cause: A connection to a database or other service was requested using // a connect identifier, and the connect identifier specified could not // be resolved into a connect descriptor using one of the naming methods // configured. For example, if the type of connect identifier used was a // net service name then the net service name could not be found in a // naming method repository, or the repository could not be // located or reached. // *Action: // - If you are using local naming (TNSNAMES.ORA file): // - Make sure that "TNSNAMES" is listed as one of the values of the // NAMES.DIRECTORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA) // - Verify that a TNSNAMES.ORA file exists and is in the proper // directory and is accessible. // - Check that the net service name used as the connect identifier // exists in the TNSNAMES.ORA file. // - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA // file. Look for unmatched parentheses or stray characters. Errors // in a TNSNAMES.ORA file may make it unusable. // - If you are using directory naming: // - Verify that "LDAP" is listed as one of the values of the // NAMES.DIRETORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA). // - Verify that the LDAP directory server is up and that it is // accessible. // - Verify that the net service name or database name used as the // connect identifier is configured in the directory. // - Verify that the default context being used is correct by // specifying a fully qualified net service name or a full LDAP DN // as the connect identifier // - If you are using easy connect naming: // - Verify that "EZCONNECT" is listed as one of the values of the // NAMES.DIRETORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA). // - Make sure the host, port and service name specified // are correct. // - Try enclosing the connect identifier in quote marks. // // See the Oracle Net Services Administrators Guide or the Oracle // operating system specific guide for more information on naming.

【讨论】:

  • 我的问题是:没有 TNSNAMES.ORA。我使用托管连接进行连接,没有 TNSNAMES.ORA。 (编辑的)连接字符串在日志 sn-p 中,它没有引用 TNS 名称。
  • 另外,我将连接字符串与 Branko 在他对 this question 的回答中建议的连接字符串进行了匹配,但我尝试了许多变体,但都不起作用。
  • 您的 EZ Connect 语法完全错误。见oracle.com/technetwork/database/enterprise-edition/…。如果您的 db 服务器正在运行 *nix,请输入以下命令:'oerr ora 12154'。它将描述更多奇特的问题。我会在我的答案中发布输出,但似乎无法将其格式化以便于阅读。您的 EZConnect 如此错误的事实向我表明,您在应用程序中的规范也是错误的,迫使 oracle 认为它正在寻找一个 tnsnames 条目。
  • 我发现了格式问题,并用更多建议更新了我的答案。
  • 谢谢你,埃德。我们已将此范围缩小到 Azure 混合连接的问题。目前,客户端上的 DNS 未解析 Oracle 主机名。发生这种情况的原因尚不清楚,但似乎不是 Oracle 连接的问题。
【解决方案2】:

此错误是由于应用服务与我们客户的本地旧版 Oracle 数据库之间的 Azure 混合连接配置不正确造成的。错误消息的“无法解析”部分实际上是准确的,表明存在潜在的 DNS 错误。

【讨论】:

    猜你喜欢
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    • 2016-03-16
    • 1970-01-01
    相关资源
    最近更新 更多