软件 | 版本 | 主机 IP |
---|---|---|
SQL Server 数据库 | windows_server_2008_r2_enterprise_build_x64_dvd_617396 | 192.168.1.253 |
gateways | win64_11gR2_gateways | 192.168.1.202 |
Oracle 数据库 | win64_11gR2_database | 192.16.1.254 |
steup
安装,如下图:下一步
,如下图:下一步
,如下图:下一步
,如下图:dg4msql\admin
目录中相关配置注:如果安装过gateway的主机在安装gateway之前已经安装过Oracle,则先改下环境变量,将Oracle的环境变量放在gateway的环境变量之前
,否则导致Oracle相关命令无法执行,如下:C:\Oracle\product\11.2.0\dbhome_1\bin;\OracleGateways\product\11.2.0\tg_1\bin;...
C:\OracleGateways\product\11.2.0\tg_1\dg4msql\admin
目录下是否有initdg4msql.ora
、listener.ora.sample
、tnsnames.ora.sample
等三个文件,一般在gateway安装的最后几步中会配置gateway的监听,监听配置后会产生这个三个文件,如果没有则新建这三个文件,并按照下面的内容配置即可,如果有则不做任何更改。# 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=[192.168.1.253]/MSSQLSERVER/gatewayDB --默认的,会报ORA-28500错误
HS_FDS_CONNECT_INFO="192.168.1.253:1433;DATABASE=gatewayDB"
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
HS_FDS_CONNECT_INFO=[192.168.1.253]/MSSQLSERVER/gatewayDB
这样配置,则通过Oracle的DBLINK连接是会包OAR-28500
的错误,错误提示如下:HS_FDS_CONNECT_INFO="192.168.1.253:1433;DATABASE=gatewayDB"
这种配置代替.# This is a sample listener.ora that contains the NET8 parameters that are
# needed to connect to an HS Agent
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4msql)
(ORACLE_HOME=C:\OracleGateways\product\11.2.0\tg_1)
(PROGRAM=dg4msql)
)
)
#CONNECT_TIMEOUT_LISTENER = 0
# This is a sample tnsnames.ora that contains the NET8 parameters that are
# needed to connect to an HS Agent
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
)
NETWORK\ADMIN
目录中相关配置# listener.ora Network Configuration File: C:\OracleGateways\product\11.2.0\tg_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
#新增SID_LIST_LISTENER
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
# dg4msql这个是默认名称,用来配置远程SQL SERVER
(SID_NAME = dg4msql)
(ORACLE_HOME = C:\OracleGateways\product\11.2.0\tg_1)
(PROGRAM = dg4msql)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
#注意这里的ip与端口是gateways的ip及端口
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
)
)
# tnsnames.ora Network Configuration File: C:\OracleGateways\product\11.2.0\tg_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
dg4msql =
(DESCRIPTION =
(ADDRESS_LIST =
#这里HOST为gateways主机的ip及端口
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg4msql)
)
(HS = OK)
)
# listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
#找到SID_LIST_LISTENER配置,并添加gateways的SID_DESC
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
#添加gateway的SID_DESC内容
(SID_DESC =
(SID_NAME = dg4msql)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = dg4msql)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
)
)
ADR_BASE_LISTENER = D:\app\Administrator
# tnsnames.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
# 添加DG4MSQL内容
DG4MSQL =
(DESCRIPTION =
(ADDRESS_LIST =
#注意这里的HOST为gateway安装主机的ip及端口
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg4msql)
)
(HS = OK)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
注意:如果配置错误,可能出现ORA-28545的错误,如下图:
出现这种问题的原因有可能是监听、端口配置错误或dg4msql配置错误,仔细检查配置正确即可解决。
--创建DBLINK,第一个sa是SQL Server数据库登录的用户名,第二个sa为密码,密码要用双引号引起来
create database link gatewayDbLink
connect to sa identified by "sa"
using 'dg4msql';
--测试
select * from tb_user@gatewayDbLink;
1.操作系统的环境变量中:Oracle的bin环境变量配置要放到gateways环境变量之前
2.gateways中,在dg4msql\admin文件夹下修改的文件有三个:
(1).initdg4msql.ora ---改为如下内容:
HS_FDS_CONNECT_INFO="192.168.1.253:1433;DATABASE=FMEA"
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
(2).listener.ora.sample ---执行过典型配置后不用改,里面内容为:
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4msql)
(ORACLE_HOME=D:\app\Administrator\product\11.2.0\tg_1)
(PROGRAM=dg4msql)
)
)
#CONNECT_TIMEOUT_LISTENER = 0
(3).tnsnames.ora.sample ---执行过典型配置后会有如下内容因此改文件不用改
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
)
3.gateways中,在NETWORK\ADMIN文件夹下修改的文件有两个
(1).listener.ora ----在最前面添加如下内容:
---开头新增的内容
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
#这个是默认名称,用来配置远程SQL SERVER
(SID_NAME = dg4msql)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\tg_2)
(PROGRAM = dg4msql)
)
)
---修改的
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.109)(PORT = 1522)) #注意这里的ip与端口是gateways的ip及端口
)
)
(2).tnsnames.ora --(次文件一般不存,需手工创建),内容如下:
dg4msql =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.109)(PORT = 1522)) #这里为gateways的ip及端口
)
(CONNECT_DATA =
(SERVICE_NAME = dg4msql)
)
(HS = OK)
)
------
4.Oracle安装目录即:D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN下修改的文件有两个:
(1).listener.ora ---找到SID_LIST_LISTENER配置,并添加gatewaysde的SID_DESC
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
#在这里新增下面的SID_DESC描述
(SID_DESC =
(SID_NAME = dg4msql)
(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = dg4msql)
)
)
(2).tnsnames.ora ---在文件最后新增下面的配置
dg4msql =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.254)(PORT = 1522)) #注意这里为gateways所在服务器的ip及端口
)
(CONNECT_DATA =
(SERVICE_NAME = dg4msql)
)
(HS = OK)
)
4.配置完成后创建Oracle DBLink 测试
(1).创建DBLink:
create database link linkdbs
connect to sa identified by "sa"
using 'dg4msql';
(2).测试:
select * from TB_TEST@linkdbs;