ODP.NET TNS 问题,32 位客户端 64 位数据库

ODP.NET problems with TNS, 32 bits client 64 bits database

我的问题如下:

我在 32 位 ubuntu 服务器 12.04 LTS 中有一个 Oracle,但我创建了另一个数据库以迁移到 Windows 2008 R2 64 位。我成功安装了 oracle 并复制了我拥有的所有数据。当我不得不将我的一个 .NET 项目的连接从使用第一个更改为第二个时,问题就出现了,我在其中遇到 "ORA-12154: TNS:could not resolve the connect identifier specified" 错误。我使用了从 Oracle 下载的 32 位 ODAC dll。

TNS 名称:

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。 IP 是正确的,端口和名称也是正确的。 ODAC 安装在 C:\OracleODAC\x32 中,我将其添加到 PATH 目录中。我也添加了 bin 目录。此外,ORACLE_HOME 和 ORACLE_SID 设置正确。

有什么建议吗?提前致谢。

编辑:我可以使用与 TOAD 相同的家进行连接。我可以将我的项目连接到 LINUX 但不能连接到 WINDOWS,编译版本为 x86/x64。

编辑 2:<add name="PRD" connectionString="Data Source=D_WINDOWS;User ID=****;Password=****;" providerName="Oracle.DataAccess.Client" />

我会先在 databas-adm-program 中测试 oracle 客户端。我使用 Toad,我将其配置为使用与我的 .net 应用程序相同的 oracle 客户端。如果它在那里工作,您可以排除 TNS 的问题,只关注 .net 应用程序中的 32 位与 64 位问题。 PS:我知道这更适合作为评论,但我无法评论,因为我在这里是 n00b

既然数据库是64位的,我想ODAC也应该是64位的。看看这个页面以获得好的页面: [http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html]

那么,我想监听器已经正确启动了???

并且在您的 tnsnames 中,您可能需要为连接标识符添加后缀: TEST_ASTREA.cartif.local = (说明 = (地址 =(协议 = TCP)(主机 = 192.168.109.103)(端口 = 1521)) (CONNECT_DATA = (服务器 = 专用) (SERVICE_NAME = orcl.cartif.local) ) )

希望对您有所帮助...

基督教徒

看来您遇到了简单的 TNS 解析错误。您可能有多个 oracle home 并且没有意识到这一点,因此您丢失了第二个 tns 名称文件。 IMO 强制使用 tns 名称文件的最简单方法是使用 TNS_ADMIN 环境变量。您还可以在连接字符串中直接嵌入 TNS 字符串来代替别名。如果您使用的是托管客户端,则可以在配置文件本身中定义 tns 别名。所有这些都在另一个答案中得到了证明: