Oracle 11g透明网关连接Sqlserver 2000
一、环境
公司网站系统使用的是IIS + Oracle
但公司某系统使用的是Sqlserver 2000, 但其数据需要做成报表放到网站上,为简化编程,使用Oracle做透明网关,定期从Sqlserver 抓取数据的方式
A: Web Server
- OS: Windows Server 2008
- IP: 10.108.3.10
- 安装软体:IIS, Oracle Client
B: Oralce DB Server
- OS: Windows Server 2008
- IP: 10.108.3.20
- 安装软体: Oracle DB, Oracle Gateway
C: Sqlserver 2000 DB Server
- OS: Windows Server 2003
- IP: 10.108.5.100
- 安装软体: Sqlserver 2000
这里面A和C的安装配置都很简单,主要说下B机器 Oracle透明网关的配置
二、Oracle透明网关配置
1. gateway安装
当然是要先安装好我们的Oracle DB,做好其它业务。然后再来安装Gateway
2. 配置 E:\Oracle\product\11.2.0\tg_1\dg4msql\admin\initdg4msql.ora
HS_FDS_CONNECT_INFO=[10.108.5.100].MSSQLSERVER.SQLDB HS_FDS_TRACE_LEVEL=OFF HS_FDS_RECOVERY_ACCOUNT=RECOVER HS_FDS_RECOVERY_PWD=RECOVER
Oracle Gateway在此文件中默认将sqlserver 2000的IP,实例名,数据库名以 / 分隔,这种设置后续会报错,改为以 . 分隔则OK
#HS_FDS_CONNECT_INFO=[10.108.5.100]/MSSQLSERVER/SQLDB
3. 配置E:\Oracle\product\11.2.0\tg_1\NETWORK\ADMIN\listener.ora
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = dg4msql) #此处为配置文件SID,要与initdg4msql.ora中的名字对应 (ORACLE_HOME = E:\Oracle\product\11.2.0\tg_1) (PROGRAM = dg4msql) #此处为配置文件目录名称,Oracle 11g中都为dg4msql,不需变更(注1) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.108.3.20)(PORT = 1522)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522)) ) ) ADR_BASE_LISTENER = E:\Oracle\product\11.2.0\tg_1
注1:如果将此处的dg4msql变掉,在最后通过Oracle访问SQL SERVER时会报以下错误
ORA-28545: 连接代理时 Net8 诊断到错误
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: 紧接着 2 lines
4. 配置E:\Oracle\product\11.2.0\tg_1\NETWORK\ADMIN\tnsnames.ora
dg4msql = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.108.3.20)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = dg4msql) ) (HS = OK) )
5. 配置E:\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = E:\Oracle\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:E:\Oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) #以下是其它业务的DB (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = E:\Oracle\product\11.2.0\dbhome_1) (SID_NAME = ORCL) ) #以下是透明网关的设置 (SID_DESC = (SID_NAME = dg4msql) (ORACLE_HOME = E:\Oracle\product\11.2.0\dbhome_1) (PROGRAM = dg4msql) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.108.3.20)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = E:\Oracle
6. 配置E:\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
dg4msql = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.108.3.20)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = dg4msql) ) (HS = OK) ) ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) )
7. 建立DB link
-- Create database link create database link SQLSERVERLINK connect to sa identified by password using 'dg4msql';