今天需要用Oracle的透明网关分别从sqlserver和sybase的数据库中取数据,特记下配置步骤。
Server1:
IP:21.15.18.109(Sql Server DB)
数据库名称:BusGPS
Server2:
IP:21.15.18.8 (Oracle DB)
Server3:
IP:21.15.18.95 (Oracle Gateways)
Server4:
IP:10.100.70.36 (Sybase DB)
数据库名称:xbcbxt
透明网关的安装较简单故省略,整个配置过程总共涉及以下几种文件:透明网关的listener.ora和tnsnames.ora文件,init+数据库名.ora文件,Oracle数据库中的tnsnames.ora文件。
一、首先修改init文件,这里需要注意sqlserver和sybase的init文件是在不同的文件夹下,sqlserver在product\11.2.0\tg_1\dg4msql\admin下,sybase在product\11.2.0\tg_1\dg4sybs\admin下,在admin文件夹下复制initdg4msql.ora的副本,修改名称为initBusGPS.ora,BusGPS为要连接的sqlserver数据库名称,文件内容修改如下:
# 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=21.15.18.109//BusGPS
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT= sqlserver数据库用户名
HS_FDS_RECOVERY_PWD= 连接密码
修改的地方有3处,其中account和pwd网上有些说法是不需要改的,也有说要改的,我这里还是修改了(如果修改请大写),Sybase的init文件和这个类似,如下:
# This is a customized agent init file that contains the HS parameters
# that are needed for the Database Gateway for Sybase
#
# HS init parameters
#
HS_FDS_CONNECT_INFO=10.100.70.36:5000//xbcbxt
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=Sybase数据库用户名
HS_FDS_RECOVERY_PWD=连接密码
# listener.ora Network Configuration File: D:\product\11.2.0\tg_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = BusGPS)
(ORACLE_HOME = D:\product\11.2.0\tg_1)
(PROGRAM = dg4msql)
)
(SID_DESC =
(SID_NAME = xbcbxt)
(ORACLE_HOME = D:\product\11.2.0\tg_1)
(PROGRAM = dg4sybs)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-OG2AO10IURK)(PORT = 1522))
)
)
ADR_BASE_LISTENER = D:\product\11.2.0\tg_1
三、修改透明网关下的tnsnames.ora文件,(如果没有该文件可创建或从别处拷贝后修改)按照如下配置:
# tnsnames.ora Network Configuration File: D:\product\11.2.0\tg_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
BusGPS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 21.15.18.95)(PORT = 1522))
)
(CONNECT_DATA =
(SID = BusGPS)
)
(HS = OK)
)
xbcbxt =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 21.15.18.95)(PORT = 1522))
)
(CONNECT_DATA =
(SID = xbcbxt)
)
(HS = OK)
)
四、修改Oracle数据库下的tnsnames.ora文件,按照上一步的信息添加服务器信息。
五、重启透明网关的监听程序。
六、在Oracle数据库中创建DBLink
create database link DBLINK_21_15_18_95_BUSGPS
connect to "user" identified by "pwd"
using 'BusGPS';
create database link DBLINK_21_15_18_95_xbcbxt
connect to "user" identified by "pwd"
using 'xbcbxt';
七、测试成功
总结:整个配置过程中出现了几个错误需要我们注意,一是监听起不来,注意是否是透明网关的监听端口被占用,如是需修改端口号。二是创建DBLink后在测试时查询返回用户名密码错误,那就请像我第六步那样在用户名和密码的前后加上双引号(注意输入法中英文状态)。