我的问题如下:
我在一个32位的ubuntu服务器12.04 LTS中有一个Oracle,但我创建了另一个用于迁移到Windows 2008 R2 64位的数据库。我成功安装了oracle并复制了我拥有的所有数据。当我不得不将我的一个.NET项目的连接从第一个连接更改为第二个连接时出现问题,我得到了一个" ORA-12154:TNS:无法解析指定的连接标识符&#34 ;错误。我使用从Oracle下载的32位ODAC dll。
TNSNAMES:
A_LINUX = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) B_LINUX = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) C_LINUX = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) D_DBLILLY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) E_DBLILLY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) TEST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl2) ) ) A_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) ) B_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) ) C_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) ) D_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) ) E_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) ) TEST_WINDOWS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.c.local) ) )
_WINDOWS是Windows的一个和Linux的_LINUX。有了这个tnsnames,我只能连接到linux。 ips是正确的,端口和名称也是如此。 ODAC安装在C:\ OracleODAC \ x32中,我将目录添加到PATH中。我也添加了bin目录。此外,正确设置了ORACLE_HOME和ORACLE_SID。
任何提示?提前谢谢。
编辑:我可以使用TOAD与同一家连接。我可以将我的项目连接到LINUX,但不能连接到WINDOWS,使用x86 / x64编译版本。
EDIT2:<add name="PRD" connectionString="Data Source=D_WINDOWS;User ID=****;Password=****;" providerName="Oracle.DataAccess.Client" />
答案 0 :(得分:1)
我首先在databas-adm-program中测试oracle客户端。我使用Toad,我配置为使用与我的.net应用程序相同的oracle客户端。如果它在那里工作,你可以排除TNS是问题,只关注你的.net应用程序中的32对64位问题。 PS:我知道这适合作为评论,但我无法评论因为我在这里是一个n00b
答案 1 :(得分:1)
看起来你对我有简单的TNS分辨率错误。您可能有多个oracle家庭并且没有意识到它,因此您缺少第二个tns名称文件。 IMO是强制tns名称文件的最简单方法是使用TNS_ADMIN环境变量。您还可以直接在连接字符串中嵌入TNS字符串代替别名。如果您使用的是托管客户端,则可以在配置文件本身中定义tns别名。所有这些都在另一个答案中得到证明:
答案 2 :(得分:-2)
由于数据库是64位,我认为ODAC也应该是64位。看看这个页面,以获得一个好的: [http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html]
然后,我想一个听众正确启动了???
在你的tnsnames中,你可能需要为连接标识符添加后缀: TEST_ASTREA.cartif.local = (DESCRIPTION = (ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.109.103)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.cartif.local) ) )
希望有帮助...
基督教