奥拉12154错误

发布于 2024-07-06 09:29:19 字数 498 浏览 6 评论 0原文

我最近在我的一台开发服务器中部署了一个 Web 应用程序。 我正在使用 oracle、asp.net 和 c#。 当我在服务器中运行应用程序时,一切正常,但是当我尝试在服务器外部运行应用程序(例如,使用我的电脑)时,我收到此错误:

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

如果我使用 Visual Studio 在我的电脑中运行应用程序,它可以工作美好的。

Oracle 安装在服务器“A”中,应用程序安装在服务器“B”中。 服务器“A”位于一个域中,服务器“B”位于另一个域中。我的电脑与服务器“A”位于同一域中。

在我的电脑中,我可以在 C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN 中找到文件 tnsname.ora,但在服务器“B”中我无法在任何地方找到它,

有什么想法吗? 谢谢您的帮助。

I recently deploy one web application in one of my development servers. I'm using oracle, asp.net and c#. When I run the application in the server everything works fine, but when I try to run the application outside of the server (using my pc, for example) i get this error:

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

If i run the application in my pc with visual studio it works fine.

Oracle is installed in Server "A" and the application is in server "B". Server "A" is in one domain and server "B" is in other domain.My pc is in the same domain has Server "A".

In my pc I can find the file tnsname.ora in C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN, but in Server "B" i can´t find it anywhere

any idea?
Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

猫瑾少女 2024-07-13 09:29:19

你试过这个了吗? (来自http://ora-12154.ora-code.com/

ORA- 12154:TNS:无法解析指定的连接标识符
原因:使用连接标识符请求与数据库或其他服务的连接,并且无法使用配置的命名方法之一将指定的连接标识符解析为连接描述符。 例如,如果使用的连接标识符类型是网络服务名称,则无法在命名方法存储库中找到该网络服务名称,或者无法定位或访问该存储库。
行动:
- 如果您使用本地命名(TNSNAMES.ORA 文件):

  • 确保“TNSNAMES”被列为 Oracle Net 配置文件 (SQLNET.ORA) 中 NAMES.DIRECTORY_PATH 参数的值之一

  • 验证 TNSNAMES.ORA 文件是否存在、位于正确的目录中并且可以访问。

  • 检查用作连接标识符的网络服务名称是否存在于 TNSNAMES.ORA 文件中。

  • 确保 TNSNAMES.ORA 文件中的任何位置都没有语法错误。 查找不匹配的括号或杂散字符。 TNSNAMES.ORA 文件中的错误可能会导致其无法使用。

  • 如果您使用目录命名:

  • 验证“LDAP”是否被列为 Oracle Net 配置文件 (SQLNET.NET) 中 NAMES.DIRETORY_PATH 参数的值之一。验证

  • 验证 LDAP 目录服务器是否已启动并且可以访问。

  • 验证目录中是否配置了用作连接标识符的网络服务名称或数据库名称。

    验证目录

  • 通过指定完全限定的网络服务名称或完整的 LDAP DN 作为连接标识符来验证所使用的默认上下文是否正确

  • 如果您使用简单连接命名:

  • 验证“EZCONNECT”是否被列为 NAMES 的值之一.Oracle Net 配置文件 (SQLNET.ORA) 中的 DIRETORY_PATH 参数。

  • 确保指定的主机、端口和服务名称正确。

  • 尝试将连接标识符括在引号中。 有关命名的详细信息,请参阅《Oracle 网络服务管理员指南》或特定于 Oracle 操作系统的指南。

Have you tried this yet? (from http://ora-12154.ora-code.com/)

ORA-12154: 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.

灯下孤影 2024-07-13 09:29:19

解决 TNS 错误可能会非常痛苦。 有几点需要记住。

大多数开发环境(如 Visual Studio)都会保留自己的 TNS 连接信息副本,并且不使用 TNSNAMES.ora 文件。 保存此信息的文件不必名为 TNSNAMES.ora,这只是默认名称。 这可能是您在服务器B上找不到它的原因。

如果您有oracle客户端软件(或oracle数据库),您可以使用tnsping检查您的TNSNAMES.ora文件是否配置正确。

TNSNAMES.ora 文件配置最常见的问题是使用错误的服务名称和/或使用错误的主机名。 您可能需要将“ODB_A”更改为“ODB_A.WORLD”,反之亦然,具体取决于 SQLNET 设置。 对于 Oracle 10,后者是默认的 SQL NET 设置。 对于后者,您需要使用 ping 查看服务器“A”,并了解是否需要使用“SERVERA”或“SERVERA.DOMIN.COM”或 IP 地址。

Resolving TNS errors can be a real pain. A few things to keep in mind.

Most development environments (like visual studio) keep their own copy of the TNS connection information, and do not use the TNSNAMES.ora file. The file where this information is kept does not have to be called TNSNAMES.ora, that's just the default name. Which may be the reason you can't find it on Server B.

If you have the oracle client software (or an oracle database) you can use tnsping to check if your TNSNAMES.ora file is configured correctly.

The most frequent problems with a TNSNAMES.ora file configuration are using the wrong service name and/or using the wrong host name. You may need to change the "ODB_A" to "ODB_A.WORLD" or vice versa, depending upon the SQLNET settings. For Oracle 10, the latter is the default SQLNET setting. For the latter, you need to use ping to see server "A", and know if you need to use "SERVERA" or "SERVERA.DOMIN.COM" or an IP address.

本王不退位尔等都是臣 2024-07-13 09:29:19

请勿将@放入您正在设置的密码中或将其从密码中删除。
我也遇到了这个错误,修改后错误就解决了。

Do not put @ in the password you are setting or remove it from the password.
I was also getting the error and after changing it, the error got resolved.

埋情葬爱 2024-07-13 09:29:19

猜测:服务器 B 上没有安装 oracle 客户端。

如果您安装了 oracle 客户端,那么您仍然可以将 tnsnames 文件放在任何位置(例如网络共享上的目录)。 为此,请将 TNS_ADMIN 系统变量(XP 上的系统属性 -> 高级 -> 环境变量)设置为包含 tnsnames 文件的目录。

对于我来说,例如我有一个系统变量: TNS_ADMIN - C:\oracle\ora92\network\ADMIN

Guess: An oracle client is not installed on Server B.

If you do have an oracle client installed then you can still put a tnsnames file in any location (Such as a directory on a network share). In order to do this, set a TNS_ADMIN system variable (System Properties->Advanced->Environment Variables on XP) to the directory containing your tnsnames files.

For me for example I have a system variable: TNS_ADMIN - C:\oracle\ora92\network\ADMIN

芸娘子的小脾气 2024-07-13 09:29:19

服务器 B 上是否设置了 ORACLE_HOME?

Is ORACLE_HOME set on server B?

风筝在阴天搁浅。 2024-07-13 09:29:19

看来您需要在“服务器B”(应用程序服务器)上安装Oracle客户端,并配置它的TNSNAMES.ORA文件。 这是必需的,否则运行的代码将不知道在哪里查找您在应用程序中使用的数据库(可能您在 web.config 中配置了数据源或硬编码的内容)。
请记住 - 如果没有 Oracle 客户端,您将无法(轻松)访问 Oracle。

It seems you need to install Oracle Client on "Server B" (the application server), and configure it's TNSNAMES.ORA file. This is required since otherwise, the running code will have no idea where to look for the database you use in the application (probably you're configured a data source in web.config or hard-coded something).
Remember - you cannot access Oracle (easily) without Oracle Client.

甜点 2024-07-13 09:29:19

有同样的问题。 事实证明,部署环境中的 TNSNAMES.ORA 有不同的 ADDRESS_NAME 和 SID/SERVICE_NAME ,并且应用程序被配置为使用 SID - 这导致了问题。

您的连接字符串必须包含 ADDRESS_NAME 而不是 SID

Had the same problem. Turns out the TNSNAMES.ORA in out deployment environment had a different ADDRESS_NAME and SID/SERVICE_NAME ,and the application was configured to use the SID - which caused the problem.

Your connection string must contain the ADDRESS_NAME and not the SID

极度宠爱 2024-07-13 09:29:19

可能的解决方案 -

验证 TNSNAMES.ORA 是否存在并且可以访问。

确保 TNSNAMES.ORA 中没有语法错误。

验证连接字符串是否正确。

验证是否存在任何 DNS 问题。

如果问题是在使用 PL sql Developer 客户端连接到服务器时出现的。请尝试在 Program File 而不是 Program Files(x86) 中安装 SQL Developer

Possible Resolutions -

Verify that the TNSNAMES.ORA exists and is accessible.

Make sure that there are no syntax errors in TNSNAMES.ORA.

Verify that the connection string is correct.

Verify if there are any DNS issues.

If the problem is while connect to server using PL sql developer client.try to install SQL developer within Program File instead of Program Files(x86)'s

可遇━不可求 2024-07-13 09:29:19

添加环境:

Variable Name: TNS_ADMIN

Variable Value: (YourDrive):\app\(UserName)\product\11.2.0\dbhome_1\NETWORK\ADMIN

Add the environment:

Variable Name: TNS_ADMIN

Variable Value: (YourDrive):\app\(UserName)\product\11.2.0\dbhome_1\NETWORK\ADMIN
我是有多爱你 2024-07-13 09:29:19

我也遇到过类似的问题。 下面的代码在我的系统中工作,但在另一台服务器中无法工作,即使我在 tnsnames.ora 文件中添加了 tns 条目。

con = new OracleConnection();
con.ConnectionString = "User Id=username;Password=password;Data Source=uit45";
con.Open(); // throws error here

经过一番挖掘,我找到了解决方案。 我们需要忽略 tns 文件中的条目,并且可以将 tns 条目作为连接字符串给出,这对我来说效果很好。 尝试下面的代码。

con = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-uit45.xxx)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=uit45)));User Id=username;Password=password");
con.Open();

请注意,您需要提供关联的值,尤其是HOST、PORT、SID、User IdPassword

I had faced the similar issue. The below code was working in my system but was not working in another server even though I had added a tns entry in tnsnames.ora file.

con = new OracleConnection();
con.ConnectionString = "User Id=username;Password=password;Data Source=uit45";
con.Open(); // throws error here

After digging and digging, I found out the solution for this. We need to ignore the entry in tns file and can be given tns entry as connection string, which worked fine for me. Try the below code.

con = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-uit45.xxx)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=uit45)));User Id=username;Password=password");
con.Open();

Note that you need to give the associated values, especially for HOST,PORT,SID,User Id and Password.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文