Oracle创建到sqlserver的DBlink

时间:2021-10-02 07:41:36

脚步:create database link dg4msql2 connect to "wlgz" identified by "123" using '(DESCRIPTION=    (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.98.19)(PORT=1522))    (CONNECT_DATA=(SID=dg4msql))    (HS=OK)  ) '

网上的说创建TNS,其实不用,在DBLINK里直接写就OK!

listner配置

# listener.ora Network Configuration File: D:\Oracle\product\11.2.0\tg_1\network\admin\listener.ora
# Generated by Oracle configuration tools.


LISTENER =
 (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.98.87)(PORT=1522))
 )

SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
         (SID_NAME=dg4msql)
         (ORACLE_HOME=D:\Oracle\product\11.2.0\tg_1)
         (PROGRAM=dg4msql)
      )
  )

注意SID,他们说必须要和admin上一级目录一样,没测试,应该不一样也可以。

准备:

数据库服务器版本10.0.3,sqlserver 2000,gateway 11g,

安装过程略,服务器名,实例名可以不填,到时候再修改D:\Oracle\product\11.2.0\tg_1\dg4msql\admin文件夹下的init文件,

如下

# This is a customized agent init file that contains the HS parameters
# that are needed for the Database Gateway for Microsoft SQL Server

#
# HS init parameters
#

#HS_FDS_CONNECT_INFO=10.1.98.87:1433//master
#HS_FDS_CONNECT_INFO=10.1.47.169:1433//rgwlgz
HS_FDS_CONNECT_INFO=10.1.98.87//master
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER

-------------------------------------------------------

注意前面IP是sqlserver的IP,后面是数据库名,注意格式//要不老报连接字符串错,后来测试一下/也行,不知道怎么回事。

再配置tns,格式按照D:\Oracle\product\11.2.0\tg_1\dg4msql\admin的listener下的sample,其实复制过来就行,如果你的Listner修改为1522,再修改下端口

配置好后启动tns --

lsnrctl start .

测试select 1 from dual@dg4msql;

没问题OK,

遇到的问题,老是NET8错误,网上有的说是版本错误,有的说是SID没匹配好,


ORA-28545: error diagnosed by Net8 when connecting to an agent

Unable to retrieve text of NETWORK/NCR message 65535


版本,我用11G的测试,10G的测试没问题,难道是平台问题?靠,原来机房为了安全,所有端口访问都有限制,解决OK!