************************************************************************-两篇结合参考*****************************************************
---------------------------------------------------------------------第一篇
第一步:下载透明网关文件win32_11gR2_gateways,并安装,安装步骤这边就省略了,装不好的问百度。
第二步:配置透明网关
安装过程中,将透明网关与Oracle数据文件安装在同台服务器上了,在这大家要注意下:
1)Oracle安装时监听器默认的端口是1521,透明网关监听器在安装时默认端口也是1521,这就导致端口冲突,报““ORA-28545: 连接代理时 Net8 诊断到错误Unable to retrieve text of NETWORK/NCR message 65535ORA-02063: 紧接着 2 lines (起自 dg4msql)”。将透明网关监听端口1521改为1522就OK了。
2)透明网关文件配置,需要用到文件为dg4msql(参数文件)和network(网络监听配置文件)
dg4msql:参数文文件
initdg4msql.ora参数文件,里面配置数据库配置信息,此文件命名格式为:init<sid>.ora,此示例采用默认文件名
数据库配置路径采用:http://IP//数据库名称,有的数据库可能不识别localhost,只能用.代替,不然会报:“ORA-28500: 连接 ORACLE 到非 Oracle 系统时返回此信息:
[Oracle][ODBC SQL Server Driver][DBNETLIB]SQL Server 不存在或访问被拒绝 {08001,NativeErr = 17}[Oracle][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). {01000,NativeErr = 53}[Oracle][ODBC SQL Server Driver]无效的连接字符串属性 {01S00}
ORA-02063: 紧接着 2 lines (起自 DG4MSQL)”
listener.ora.sample:透明网关监听器配置模板
tnsnames.ora.sample:Oracle数据库tns配置模板
network:文件
需要在listener.ora配置信息
第三步:重启透明网关监听器
点击 LSNRCTL.exe文件,进入下面界面:
第四步:Oracle数据文件配置
找到Oracle tns配置文件,进行一下配置:
第五步:创建dblink 语法如下:
- create database link dg4msql --dblink名称
- connect to sa --用户名
- identified by "scsoft" --密码,用引号括起来
- using 'dg4msql'; --服务名称
第六步:数据查询,语法如下:
- select * from 表明@dg4msql;
------------------------------------------------------------------第二篇
一、环境
公司网站系统使用的是IIS + Oracle
但公司某系统使用的是Sqlserver 2000, 但其数据需要做成报表放到网站上,为简化编程,使用Oracle做透明网关,定期从Sqlserver 抓取数据的方式
A: Web Server
B: Oralce DB Server
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';