oracle - ODP.NET 和托管连接失败并出现 ORA-12154
问题描述
我认为通过 Oracle.ManagedDataAccess.Core NuGet 包使用 ODP.Net Managed Connections 的全部意义在于您不需要在运行时环境中安装 Oracle 客户端。我发现很多关于
ORA-12154: TNS: 无法解析指定的连接标识符错误
错误,但所有关于潜在修复的讨论都围绕客户端配置问题展开。
我所做的正是本文中所描述的。当我从 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 字符串,但没有成功:
<user>/<password>@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=<ip address>)(Port=<port>))(CONNECT_DATA=(SID=<mysid>)))
我错过了什么?
更新:该问题似乎是由 Azure 混合连接管理器而不是 Oracle 连接的潜在问题引起的。现在查看 VPN 连接。暂时保留您尝试不同连接字符串格式的建议。
解决方案
我们会看到输出中的内容,但需要查看您在调用应用程序中实际指定连接字符串的方式。ora-12154 是最常见的连接问题之一,在整个 Internet 上都有相关报道。当你用谷歌搜索它时,你发现了什么?
它说您指定了一个无法在客户端的 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.
推荐阅读
- python - 如何删除 xml 或 html 命令行并使用 python 检索实际文本数据?
- c++ - 是否可以在具有基类定义的映射中传递子类对象?
- python - 如何从连续行中查找损益百分比
- django - 如何在 Django Rest Framework 中使用 LimitOffSetPagination 而不是 PageNumberPagination?
- javascript - 为什么我的引导折叠功能在页面刷新后不起作用?
- javascript - 无法在 Polymer 中进行用户定义的函数调用
- powerbi - 如何计算 PowerBI 中每个类别的比率?
- android - 是否可以使用 Model 类在 JSONArray 中序列化 JSONArray?
- javascript - 将输入转换为字符串/变量并在警报中使用
- spring-boot - 如何将日期作为参数从控制器传递到 API?