通过Oracle的GateWay,访问SQLServer的数据【方法一】

测试例子:通过Oracle的GateWay,访问SQLServer的数据。

Oracle 信息:

Oracle所在机器的IP : 192.168.2.28

oracle SID :test

Oracle 版本: 11.2.0.4

SQL Server 信息:

SQL Server所在机器的IP : 192.168.2.28

SQLServer SID : MSSQLSERVER   -- 其实这个不是很重要,在后面设置的时候,可以不填写。

SQL Server 数据库 : test

SQL Server 版本 : SQL Server 2008 R2

GateWay信息:

其实,就是11gr2对应的第五个安装包 p13390677_112040_MSWIN-x86-64_5of7 。

gateway所在的机器IP : 192.168.2.28  

这里做简单的测试,把SQL Server、Oracle、Gataway安装在一台机器上了 。

先看Gateway的安装  ,安装比较简单,安装过程如下:

注意,这里的截图和实际安装有点出入,时间安装的时候,下图的名称不是oragwt11g_home1,而是ORA_11g_home1,覆盖了Oracle_home,也就是和Oracle安装在一个目录了。 Oracle的MOS上有文章介绍,不建议这样安装,因为这样安装,可能会把Oracle的一些补丁给覆盖掉了。

 

配置:

监听器的配置,其中,dg4msql之类的是新增加的

  1. # listener.ora Network Configuration File: C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
  2. # Generated by Oracle configuration tools.
  3. SID_LIST_LISTENER =
  4. (SID_LIST =
  5. (SID_DESC =
  6. (GLOBAL_DBNAME = test)
  7. (ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1)
  8. (SID_NAME = test)
  9. )
  10. (SID_DESC =
  11. (GLOBAL_DBNAME = dg4msql)
  12. (PROGRAM = dg4msql)
  13. (ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1)
  14. (SID_NAME = dg4msql)
  15. )
  16. )
  17. LISTENER =
  18. (DESCRIPTION =
  19. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.28)(PORT = 1521))
  20. )
  21. ADR_BASE_LISTENER = C:\app\Administrator\product\11.2.0\dbhome_1\log

tnsnames.ora的配置。同样的dg4msql之类的也是新增加的内容

  1. # tnsnames.ora Network Configuration File: C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
  2. # Generated by Oracle configuration tools.
  3. TEST =
  4. (DESCRIPTION =
  5. (ADDRESS_LIST =
  6. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.28)(PORT = 1521))
  7. )
  8. (CONNECT_DATA =
  9. (SERVICE_NAME = test)
  10. )
  11. )
  12. dg4msql =
  13. (DESCRIPTION=
  14. (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.28)(PORT=1521))
  15. (CONNECT_DATA=(SID=dg4msql))
  16. (HS=OK)
  17. )

dg4msql的配置,其实这里在上面的图形界面中已经设置了,不需要修改,内容如下:

  1. # This is a customized agent init file that contains the HS parameters
  2. # that are needed for the Database Gateway for Microsoft SQL Server
  3. #
  4. # HS init parameters
  5. #
  6. HS_FDS_CONNECT_INFO=[192.168.2.28]//test
  7. HS_FDS_TRACE_LEVEL=OFF
  8. HS_FDS_RECOVERY_ACCOUNT=RECOVER
  9. HS_FDS_RECOVERY_PWD=RECOVER

查看监听状态

  1. LSNRCTL> status
  2. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.28)(PORT=1521)
  3. ))
  4. STATUS of the LISTENER
  5. ------------------------
  6. Alias LISTENER
  7. Version TNSLSNR for 64-bit Windows: Version 11.2.0.4.0 - Produ
  8. ction
  9. Start Date 30-6-2019 11:18:53
  10. Uptime 0 days 3 hr. 21 min. 38 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File C:\app\Administrator\product\11.2.0\dbhome_1\network\a
  15. dmin\listener.ora
  16. Listener Log File C:\app\Administrator\product\11.2.0\dbhome_1\log\diag\
  17. tnslsnr\WIN-LPCB8UCORM9\listener\alert\log.xml
  18. Listening Endpoints Summary...
  19. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.2.28)(PORT=1521)))
  20. Services Summary...
  21. Service "dg4msql" has 1 instance(s).
  22. Instance "dg4msql", status UNKNOWN, has 1 handler(s) for this service...
  23. Service "test" has 1 instance(s).
  24. Instance "test", status UNKNOWN, has 1 handler(s) for this service...
  25. The command completed successfully
  26. LSNRCTL>

创建Oracle到SQLServer的DBLINK

SYS@test>CREATE DATABASE LINK tomssql CONNECT TO "sa" IDENTIFIED BY "sysadminXXX" USING 'dg4msql';

测试访问:可以看到,可以访问SQL Server中的数据

插入一条数据,在Oracle中可以执行,在SQL Server中也可以看到结果。

 

END

posted @ 2022-04-20 21:50  yclizq  阅读(633)  评论(0编辑  收藏  举报