Oracle 12c中使用透明网关(gateways) 12.1数据链接到SQL Server 2012

Installing Oracle Database Gateway for SQL Server

 

1. 拓扑结构

SQL Server

-->

Gateways

-->

Oracle

Version:2012

172.16.28.207:1433

Version:12.1

172.16.28.41:1533

Install Dir:/home/gateways

Version:12.1.0.2.0

172.16.28.44:1521

Install Dir:/oracle/app/oracle

 

2. 硬件要求:

Hardware Items

Required for Linux x86 64 bit

 

Temporary Disk Space

400 MB

 

Disk Space

750 MB

 

Physical Memory*

512 MB

 

Swap Space

1 GB

 

Processor

x86_64

 

2.1. 检查硬件要求

[root@orcl2 ~]# grep MemTotal /proc/meminfo

MemTotal:       131707600 kB

[root@orcl2 ~]# grep SwapTotal /proc/meminfo

SwapTotal:       4194300 kB

[root@orcl2 ~]# df -k /tmp

文件系统                   1K-块     已用     可用 已用%挂载点

/dev/mapper/centos-root 52403200 36685908 15717292   71% /

[root@orcl2 ~]# df -k

df: "/run/user/0/gvfs": 传输端点尚未连接

文件系统                        1K-块      已用       可用 已用%挂载点

/dev/mapper/centos-root      52403200  36685904   15717296   71% /

devtmpfs                     65838288         0   65838288    0% /dev

tmpfs                        65853800    870652   64983148    2% /run

tmpfs                        65853800         0   65853800    0% /sys/fs/cgroup

/dev/mapper/centos-home     527384988  27693340  499691648    6% /home

/dev/sda1                      508588    211728     296860   42% /boot

tmpfs                        13170760        28   13170732    1% /run/user/0

orcl1pri:/oradata/oradata  1056762880   4055040  999021568    1% /oradata/oradata

orcl1pri:/oradata/oradata2 3169917952 643731456 2365134848   22% /oradata/oradata2

orcl1pri:/oradata/flash     515930112  33312768  456402944    7% /oradata/flash

orcl1pri:/ASM/crs1           52403200  44312352    8090848   85% /home/ASM/crs1

orcl2pri:/ASM/crs2           52403200  36685888   15717312   71% /home/ASM/crs2

orcl2pri:/ASM/crs3           52403200  36685888   15717312   71% /home/ASM/crs3

tmpfs                        67108864    646184   66462680    1% /dev/shm

tmpfs                        13170760        16   13170744    1% /run/user/54322

[root@orcl2 ~]#

3. 软件要求

操作系统版本Linux 5.0 以上。

---------------------------------------------------------------------------------------------------------------

[root@orcl2 ~]# cat /proc/version

Linux version 3.10.0-327.13.1.el7.x86_64 ([email protected]) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Mar 31 16:04:38 UTC 2016

[root@orcl2 ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@orcl2 ~]#

 

4. 安装

4.1. 运行 runInstaller

 

 

4.2. Specify Installation Location

Oracle base: /oracle/app/oracle

Software location:/home/gateways

 

 

4.3. Available Product Components

 

4.4. Gateways for Microsoft SQL Server

 

4.5. Perform Prerequisite Checks

 

 

4.6. Summary

 

 

4.7. Install Product

 

 

4.8. Net CA(此步可先跳过)

 

 

 

4.9. Execute Configuration scripts

 

 

Last login: Fri Aug 19 16:07:21 2016 from 10.1.11.200

[root@orcl2 ~]# /home/gateways/root.sh

Performing root user operation.

 

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /home/gateways

 

Enter the full pathname of the local bin directory: [/usr/local/bin]:

The contents of "dbhome" have not changed. No need to overwrite.

The contents of "oraenv" have not changed. No need to overwrite.

The contents of "coraenv" have not changed. No need to overwrite.

 

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

[root@orcl2 ~]#

4.10. Finish

 

 

5. 配置网关初始化参数文件

For example, all of the following entries are valid:

HS_FDS_CONNECT_INFO=host_name/instance_name/database_name

HS_FDS_CONNECT_INFO=host_name//database_name

HS_FDS_CONNECT_INFO=host_name:port_name//database_name

HS_FDS_CONNECT_INFO=host_name/instance_name

HS_FDS_CONNECT_INFO=host_name 

 

5.1. 自定义初始化参数文件

[oracle@orcl2 /home/gateways/dg4msql/admin]$ll -a

总用量 28

drwxr-xr-x 2 oracle oinstall   123 8月  19 17:35 .

drwxr-xr-x 7 oracle oinstall    62 8月  19 17:35 ..

-rw-r--r-- 1 oracle oinstall 11120 1217 2013 dg4msql_cvw.sql

-rw-r--r-- 1 oracle oinstall   746 6月   8 2007 dg4msql_tx.sql

-rw-r--r-- 1 oracle oinstall   370 8月  19 17:35 initdg4msql.ora

-rw-r--r-- 1 oracle oinstall   386 8月  19 17:35 listener.ora.sample

-rw-r--r-- 1 oracle oinstall   244 8月  19 17:35 tnsnames.ora.sample

[oracle@orcl2 /home/gateways/dg4msql/admin]$

 

[oracle@orcl2 /home/gateways/dg4msql/admin]$cat initdg4msql.ora

# 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=[172.16.28.207]:1433//MSSQLSERVER

#HS_FDS_CONNECT_INFO=[172.16.28.207]:1433//lisdb

HS_FDS_CONNECT_INFO=[172.16.28.207]/lisdb

# alternate connect format is hostname/serverinstance/databasename

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

[oracle@orcl2 /home/gateways/dg4msql/admin]$

5.2. 配置网关监听

[oracle@orcl2 /home/gateways/network/admin]$cat listener.ora

# listener.ora Network Configuration File: /home/gateways/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LSN_GATEWAYS =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl2)(PORT = 1533))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1533))

    )

  )

 

 

#add sid_list_lsn_gateways

SID_LIST_LSN_GATEWAYS=

   (SID_LIST=

      (SID_DESC=

         (SID_NAME=dg4msql)

         (ORACLE_HOME=/home/gateways)

         (PROGRAM=dg4msql)

      )

   )

[oracle@orcl2 /home/gateways/network/admin]$

 

5.3. 停止并重启网关监听

[oracle@orcl2 ~]$export TNS_ADMIN=/home/gateways/network/admin

[oracle@orcl2 ~]$echo $TNS_ADMIN

/home/gateways/network/admin

[oracle@orcl2 ~]$lsnrctl

 

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 19-AUG-2016 20:07:59

 

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

 

Welcome to LSNRCTL, type "help" for information.

 

LSNRCTL> status lsn_gateways

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl2)(PORT=1533)))

STATUS of the LISTENER

------------------------

Alias                     LSN_GATEWAYS

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                19-AUG-2016 18:11:02

Uptime                    0 days 1 hr. 57 min. 5 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /home/gateways/network/admin/listener.ora

Listener Log File         /oracle/app/oracle/diag/tnslsnr/orcl2/lsn_gateways/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orcl2)(PORT=1533)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1533)))

The listener supports no services

The command completed successfully

LSNRCTL> stop lsn_gateways

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl2)(PORT=1533)))

The command completed successfully

LSNRCTL> status lsn_gateways    

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl2)(PORT=1533)))

TNS-12541: TNS:no listener

 TNS-12560: TNS:protocol adapter error

  TNS-00511: No listener

   Linux Error: 111: Connection refused

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1533)))

TNS-12541: TNS:no listener

 TNS-12560: TNS:protocol adapter error

  TNS-00511: No listener

   Linux Error: 2: No such file or directory

LSNRCTL> start lsn_gateways

Starting /oracle/app/oracle/product/12.1/db_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 12.1.0.2.0 - Production

System parameter file is /home/gateways/network/admin/listener.ora

Log messages written to /oracle/app/oracle/diag/tnslsnr/orcl2/lsn_gateways/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orcl2)(PORT=1533)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1533)))

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl2)(PORT=1533)))

STATUS of the LISTENER

------------------------

Alias                     lsn_gateways

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production

Start Date                19-AUG-2016 20:09:16

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /home/gateways/network/admin/listener.ora

Listener Log File         /oracle/app/oracle/diag/tnslsnr/orcl2/lsn_gateways/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orcl2)(PORT=1533)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1533)))

Services Summary...

Service "dg4msql" has 1 instance(s).

  Instance "dg4msql", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

LSNRCTL>

 

6. 为网关访问配置数据库

[oracle@orcl2 /oracle/app/oracle/product/12.1/db_1/network/admin]$cat tnsnames.ora

# tnsnames.ora Network Configuration File: /oracle/app/oracle/product/12.1/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

#conn hylisdb

conn_sqlserver=

   (DESCRIPTION=

      (ADDRESS=

         (PROTOCOL=TCP)

         (HOST=172.16.28.41)

         (PORT=1533)

      )

      (CONNECT_DATA=

         (SID=dg4msql))

      (HS=OK))

[oracle@orcl2 /oracle/app/oracle/product/12.1/db_1/network/admin]$

 

[oracle@orcl2 /oracle/app/oracle/product/12.1/db_1/network/admin]$tnsping conn_sqlserver

 

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 19-AUG-2016 21:27:34

 

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

 

Used parameter files:

/oracle/app/oracle/product/12.1/db_1/network/admin/sqlnet.ora

 

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=172.16.28.41) (PORT=1533)) (CONNECT_DATA= (SID=dg4msql)) (HS=OK))

OK (0 msec)

[oracle@orcl2 /oracle/app/oracle/product/12.1/db_1/network/admin]$

7. 创建数据库连接

create public database link hislinkhylisdb connect to "sa" identified by "Holiday123" using 'conn_sqlserver';

8. 测试

SELECT * from DI_ADI_LARDRU_LIST@HISLINKHYLISDB;

SELECT * from DI_ADI_LARGERM_LIST@HISLINKHYLISDB;

SELECT * from DI_HDI_LARDRU_LIST@HISLINKHYLISDB;

SELECT * from DI_HDI_LARGERM_LIST@HISLINKHYLISDB;

9. 错误

 

 

10. 附件:

 

 

 

 

 

你可能感兴趣的:(Oracle,12c)