ORACLE9i 的透明网关的配置

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

ORACLE实现异种数据库连接服务的技术叫做透明网关(Transparent Gateway)。
目前ORACLE利用透明网关可以实现和SQL SERVER、SYBASE、DB2等多种主流数据库的互联。

笔者由于工作需要,通过ORACLE访问sybase数据库,把配置ORACLE9i TRANSPARENT GATEWAY FOR SYBASE
的步骤写成文档,供需要的网友参考!
 
配置TRANSPARENT GATEWAY FOR SYBASE步骤

1.
ORACLE所在服务器上安装sybase client(或者在同一台server上安装ORACLE、sybase服务器)
确保能够访问sybase数据库

2.
安装TRANSPARENT GATEWAY FOR SYBASE选件,要用自定义安装。
正确选择sybase的安装目录

3.
选择一个sid字符串准备赋给sybase数据库。如:tg4sybs
设置SYBASE的dll路径到环境变量PATH(这一步很重要)

4.
修改初始化文件,默认的是:
ORACLE_HOME g4sybsadmininittg4sybs.ora
设置参数
HS_FDS_CONNECT_INFO
格式:HS_FDS_CONNECT_INFO= server_name. database_name[,INTERFACE= interface_file]
server_name. database_name是大小写敏感的。
INTERFACE可选

例子:如下
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
# This is a sample agent init file that contains the HS parameters that are
# needed for the Transparent Gateway for Sybase

#
# HS init parameters
#
HS_FDS_CONNECT_INFO=migration_serv.tax
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER

#
# Environment variables required for Sybase
#
set SYBASE=d:sybase
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
上例中
server_name是migration_serv
database_name是tax

5.
配置ORACLE网络服务的listener,配置文件是:listener.ora
默认路径:ORACLE_HOMEetworkadmin
加入如下

SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME= gateway_sid)
(ORACLE_HOME= ORACLE_home_directory)
(PROGRAM=tg4sybs)
)
)

gateway_sid就是3选择的sid字符串
ORACLE_home_directory是ORACLE_HOME
tg4sybs若是SYBASE是特定的。如果是其他数据库,会不同。
例子如下:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    (SID_DESC=
      (SID_NAME=tg4sybs)
      (ORACLE_HOME = D:ORACLEora92)
      (PROGRAM=tg4sybs)
    )
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

6.
停止监听

lsnrctl stop


重新启动监听程序

lsnrctl start

7.
配置ORACLE server的tnsnames.ora使其能够访问sybase
connect_descriptor=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST= host_name)
(PORT= port_number)
)
(CONNECT_DATA=
(SID= gateway_sid))
(HS=OK))

connect_descriptor是连接串,任取,一般为sybs
host_name:ORACLE server的name
port_number:ORACLE监听端口
gateway_sid就是3选择的sid字符串

例子如下:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
sybs=
   (DESCRIPTION=
       (ADDRESS_LIST =
       (ADDRESS=(PROTOCOL=TCP)(HOST= dw-server1)(PORT= 1521))
       )
   (CONNECT_DATA=
       (SID= tg4sybs)
   )
       (HS=OK)
   )

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

8.建立database link

如:
CREATE  DATABASE LINK sybs  CONNECT TO sa
    IDENTIFIED BY prient 
    USING 'SBYS' ;
   
即可访问sybase 数据库。


需要注意的是,sybase数据库的表名,字段名,如果是小写的,那么在ORACLE里访问的时候要加上双引号""

如:
SQL〉select "a" from "b"@sybs;

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: 数据库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭