上一次说了如何在Linux下安装oracle到sqlserver之间的透明网关,现在给大家继续介绍如何在windows下安装。
本文实验环境:
|-----------|------------|-----------------|
| 数据库类型 | 数据库版本 | IP |
| oracle | 11204 | 192.168.238.122 |
| MSSQL | MSSQL 2008 | 192.168.239.40 |
一、oracle服务器配置ODBC源
搜索栏搜索ODBC------>设置数据源(ODBC)------>系统DSN------>添加
名称定好,这就是我们虚拟出来的透明网关实例名;服务器是sqlserver的服务器IP
第二步、检查DG4ODBC驱动是否已经安装
方法如下:dg4odbc oracle服务器上cmd命令(dg4odbc或hsodbc)
第三步、配置透明网关的参数文件 ( 参数文件名要和虚拟的实例名一致 )
复制initdg4odbc.ora文件,拷贝为initzmh.ora,去ORACLE_HOME/hs/admin下配置initzmh.ora文件
HS_FDS_CONNECT_INFO填写为透明网关实例名,HS_FDS_TRACE_LEVEL配置为off
This is a sample agent init file that contains the HS parameters that are
needed for the Database Gateway for ODBC
HS init parameters
HS_FDS_CONNECT_INFO = zmh
HS_FDS_TRACE_LEVEL = off
Environment variables required for the non-Oracle system
#set <envvar>=<value>
编辑监听文件(标红部分就是新增的透明网关实例)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\11204\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\11204\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = zmh)
(ORACLE_HOME = D:\11204\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = dg4odbc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-SLFB9LHBV0T)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
第五步、重启监听或者reload
注意哦,这里tnsnames.ora里面的HOST填的是oracle服务器的地址,SID就是监听虚拟出来的实例名
ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.238.122)(PORT = 1521))
(CONNECT_DATA =
(SID = zmh)
)
(HS = OK)
)
创建dblink
create public database link pacs connect to sa identified by "Hzmc321#" using 'ORCL1';
成功查询
注意事项:
透明网关通过监听虚拟出来的实例名字不要和本地已有的oracle实例一样!不然会报错
ORA-28546: 连接初始化失败, 可能是 Net8 管理错误 ORA-28511: 丢失与使用