代码之家  ›  专栏  ›  技术社区  ›  Oscar Vicente Perez

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

  •  1
  • Oscar Vicente Perez  · 技术社区  · 9 年前

    我的问题是:

    我在32位ubuntu服务器12.04 LTS中有一个Oracle,但我创建了另一个数据库以迁移到Windows 2008 R2 64位。我成功地安装了oracle并复制了我所有的数据。当我不得不将我的一个.NET项目的连接从使用第一个更改为使用第二个时,出现了问题,在那里我得到了一个“ORA-12154:TNS:无法解析指定的连接标识符”错误。我使用了从Oracle下载的32位ODAC dll。

    名称:

    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的同一个家庭进行连接。我可以用x86/x64编译版本将我的项目连接到LINUX,但不能连接到WINDOWS。

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

    3 回复  |  直到 5 年前
        1
  •  1
  •   Marcus Höglund    9 年前

    我将首先在数据库adm程序中测试oracle客户端。我使用Toad,我将其配置为使用与.net应用程序相同的oracle客户端。如果它在那里起作用,您可以排除TNS是问题所在,只需关注.net应用程序中的32位与64位问题。 PS:我知道这更适合作为评论,但我不能评论,因为我在这里

        2
  •  1
  •   Community raghavsood33    7 年前

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

    https://stackoverflow.com/a/31592492/852208

        3
  •  -2
  •   Christian COMMARMOND    9 年前

    由于数据库是64位,我认为ODAC也应该是64位。请查看此页面以获得最佳结果: [ http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html]

    那么,我想听众是正确开始的???

    在tnsnames中,您可能需要为连接标识符添加后缀: 测试_应力软骨。本地= (说明= (地址=(协议=TCP)(主机=192.168.109.103)(端口=1521)) (连接数据= (服务器=专用) (SERVICE_NAME=orcl.carif.local) ) )

    希望这有助于。。。

    基督教的