测试环境介绍
1、ORACLEServer
Database version:10.2.0
IP:192.168.1.5
ORACLE_HOME:D:\oracle\product\10.2.0\db_1
2、Oracle transparent Gateway Server
Version:10.2.0
IP:192.168.1.15
安装目录 D:\oracle\product\10.2.0\tg_1
3、MS sql server
Sqlserver Version:2008R2
IP:192.168.1.25
原有oracle数据库,sqlserver数据库都已经在用了,需要导一些数据到oracle数据库中。
Step1:安装ORACLE gateways 略…… 在安装透明网关过程中会询问你需要为那些数据库配置,选择里面的for sqlserver 就行
Step2:配置透明网关下的相关文件; 接下来的服务器,数据库可以不填;现在我们要做的是复制 D:\oracle\product\10.2.0\tg_1\tg4msql\admin下的 inittg4msql.ora文件,并修改成名字为init<sid>.
ora我这里测试连接GSLIMSDB_NingBo库,为配置方便改名为G5,所以就是initG5.ora内容为:
Oracle中使用透明网关链接到Sqlserver
测试环境介绍
1、ORACLEServer
Database version:10.2.0 IP:192.168.1.5
ORACLE_HOME:D:\oracle\product\10.2.0\db_1 2、Oracle transparent Gateway Server Version:10.2.0 IP:192.168.1.15
安装目录 D:\oracle\product\10.2.0\tg_1 3、MS sql server
Sqlserver Version:2008R2 IP:192.168.1.25
原有oracle数据库,sqlserver数据库都已经在用了,需要导一些数据到oracle数据库中。
Step1:安装ORACLE gateways 略……
在安装透明网关过程中会询问你需要为那些数据库配置,选择里面的for sqlserver 就行
Step2:配置透明网关下的相关文件;
接下来的服务器,数据库可以不填;现在我们要做的是复制
D:\oracle\product\10.2.0\tg_1\tg4msql\admin下的 inittg4msql.ora文件,并修改成名字为init<sid>.
ora我这里测试连接GSLIMSDB_NingBo库,为配置方便改名为G5,所以就是initG5.ora内容为:
=========================脚===本===如===下============================
# This is a sample agent init file that contains the HS parameters that are # needed for the Transparent Gateway for SQL Server #
# HS init parameters #
HS_FDS_CONNECT_INFO="SERVER=192.168.1.25;DATABASE=G5" HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
======================================================================
如果在安装时配置的话生成的HS_FDS_CONNECT_INFO=192.168.1.25.G5连接会出问题, HS_FDS_CONNECT_INFO的设置有多种格式,如:
HS_FDS_CONNECT_INFO=server_name.db_name,但这种写法server_name不能为IP,且端口必须为默认的1433,如:
HS_FDS_CONNECT_INFO=sqlserverhostname.G5
接下来是配置D:\oracle\product\10.2.0\tg_1\network\admin下的listener.ora文件
=========================脚===本===如===下============================
# listener.ora Network Configuration File: D:\oracle\product\10.2.0\tg_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\tg_1)
(PROGRAM = extproc) )
(SID_DESC =
(SID_NAME = G5)
(ORACLE_HOME = D:\oracle\product\10.2.0\tg_1)
(PROGRAM = tg4msql) ) )
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = rdserver2)(PORT = 1521))
)
)
======================================================================
这里的红色部分是新配置上去的,别的都是默认的,然后再配置
D:\oracle\product\10.2.0\tg_1\network\admin下的tnsnames.ora文件:
=========================脚===本===如===下============================
# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\tg_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
G5=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)(HOST=192.168.1.25)(PORT=1521))
(CONNECT_DATA=
(SID=G5)
)
(HS=OK)
)
======================================================================
Step3:启动或重新加载监听
查看监听状态
Step4:在oracle数据库上创建dblink 连接 sqlserver2008
=========================脚===本===如===下============================
create public database link con_mssql connect to "sa" identified by "password"
using '(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)(HOST=192.168.1.15)(PORT=1521))
(CONNECT_DATA=
(SID=G5)
)
(HS=OK)
)';
======================================================================
然后就可以测试:
=========================脚===本===如===下============================
selectcount(*) from gs_t_ApplicationForm@con_mssql;
======================================================================
执行后不会出错,有结果那么透明网管配置完成;