ORACLE透明網關訪問SQL Server配置總結


 

透明網關概念

 

ORACLE透明網關(Oracle Transparent Gateway)可以解決ORACLE數據庫和非ORACLE數據庫交互數據的需求。在一個異構的分布式環境中,通過ORACLE透明網關可以訪問其他類型數據庫,例如DB2,SQL Server、Sybase....。這個類似於SQL Server里面的LINKED SERVER可以直接訪問異構的數據庫環境,由於Windows本身提供了很多驅動,所以有時候不需要安裝額外的驅動程序,有時候也需要安裝相關驅動才能訪問(例如,SQL SERVER 通過LINKED SERVER訪問ORACLE數據庫,就必須安裝Oracle Client客戶端相關組件),而ORACLE則必須通過透明網關才能訪問其它類型數據庫,官方文檔關於透明網關的介紹如下:

 

 

Oracle Database Gateways provide the ability to transparently integrate with non-Oracle systems from an Oracle environment. This transparency eliminates the need for application developers to customize their applications to access data from different non-Oracle systems, thus decreasing development efforts and increasing the mobility of the application. Applications can be developed using a consistent Oracle interface for both Oracle and non-Oracle systems.

 

For smooth interoperability between disparate systems, SQL translations, data dictionary translations and data type translations are required, even if the non-Oracle systems are based on SQL standards. Gateways have the ability to translate one system's dialect to another.

 

Oracle has tailored Gateways to many systems, DB2, Sybase, Informix, SQL Server, IMS, VSAM, Adabas, to name a few. These are specifically coded for the target non-Oracle system. They provide an optimized solution and are also end-to-end certified.

 

ORACLE官方關於透明網關的文檔資料,請見鏈接http://www.oracle.com/technetwork/database/gateways/index.html,主要有Database Gateways Features Overview 與Database Gateways Technical Whitepaper等相關資料。

 

 

透明網關安裝

 

 

關於透明網關的安裝,透明網關可以安裝在Windows平台或Linux平台;它既可以和ORACLE數據庫實例安裝在一起(Oracle Server端),也可以安裝在其它數據庫服務器上(例如,安裝在SQL Server數據庫服務器上),也可以安裝在一台跟數據庫無任何關系的機器上。也就是說Oracle Gateway架構設計的耦合性非常低。剛開始接觸透明網關時,透明網關需要安裝在哪里這個問題一直困擾我,直到我一一驗證測試。通俗的來說,透明網關可以裝在任意的一台機器上,如果透明網關安裝在Oracle Server端,這時候Server自身擔當兩種角色:服務器和透明網關代理,如果安裝在非Oracle Server端,那么其他服務器就充當透明網關代理的角色。

 

clip_image001

 

 

 

 

Windows平台安裝

 

 

從官方網址下載win32_11gR2_gateways.zip  http://www.oracle.com/technetwork/cn/database/enterprise-edition/downloads/112010-win32soft-098630-zhs.html安裝介質后,解壓安裝,安裝步驟非常簡單,本身安裝文件里面也有詳細安裝文檔,本不需在這里過多介紹,不過,對於一些初次初學者,也有一些細節地方需要注意。如下所示,對一些步驟做了截圖處理。

 

 

clip_image002

 

 

選擇安裝路徑,這個路徑可以和ORACLE數據庫路徑一致(一般很少有ORACLE實例安裝在Windows平台,如果是安裝在Linux平台,可以和ORACLE實例的安裝路徑一致,也可以任意選擇一個路徑),也可以單獨選擇一個安裝路徑。

 

 

clip_image003

 

 

 

選擇需要安裝的組件,例如我這里只需要通過透明網關訪問SQL Server 數據庫。那么我只勾選了下面一個組件。

 

 

clip_image004

 

 

在這里需要提供SQL Server數據庫服務器名或IP、實例名稱、數據庫名稱等等。

 

 

clip_image005

 

clip_image006

 

安裝完成后,你會在D:\product\11.2.0\tg_1\dg4msql\admin這個路徑(這個與安裝目錄有關系,都是位於$ORACLE_HOME\dg4msql\admin)下看到initdg4msql.ora 文件。

 

 

如下所示,如果前面UI界面填寫了相關信息。那么在透明網關初始化參數文件initdg4msql.ora下就會有相關信息。如下所示。注意,默認使用的分隔符為/,ORACLE透明網關安裝在一個Windows 2012應用服務器上。實際上,使用分隔符"/"是會遇到一些問題的(應該使用//),Windows平台的正確分隔符為.。后續會介紹這個案例,當然如果是Linux平台使用分隔符/則沒有任何問題。

 

 

# 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=[192.168.27.57]/MSSQLSERVER/TEST

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

 

 

Oracle Net 配置,可以通過圖形界面配置,也可以忽略這些步驟,后續通過手工編輯配置Oracle Net

 

clip_image007

 

clip_image008

 

clip_image009

 

clip_image010

 

clip_image011

 

如下所示,在D:\product\11.2.0\tg_1\network\admin\listener.ora下面,你會看到下面配置信息:

 

 

# listener.ora Network Configuration File: D:\product\11.2.0\tg_1\network\admin\listener.ora

# Generated by Oracle configuration tools.

 

ADR_BASE_GW_LISTENER = D:\product\11.2.0\tg_1

 

GW_LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.27.132)(PORT = 1522))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))

    )

  )

 

當然這個配置信息不全,正確的配置信息如下所示(注意:這里監聽器名稱為GEW_LISTENER,這個與默認監聽器名稱LISTENER有細微不同):

 

ADR_BASE_GEW_LISTENER = D:\product\11.2.0\tg_1
 
 
 
GEW_LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.27.132)(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 
SID_LIST_GEW_LISTENER =                                                                          
  (SID_LIST =                                                                                
    (SID_DESC =                                                                              
      (SID_NAME = dg4msql)            
      (ORACLE_HOME = D:\product\11.2.0\tg_1)                                          
      (PROGRAM = dg4msql)   
    )                                                                                        
 

 

 

 

Linux平台安裝

 

 

以ORACLE 11g為例,首先從官網http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html下載linux.x64_11gR2_gateways.zip,我將ORACLE透明網關和ORACLE實例安裝在同一台服務器上,並且安裝目錄與ORACLE數據庫實例的安裝路徑一致,安裝步驟簡略。 關於ORACLE透明網關的安裝路徑,其實可以選擇一個跟ORACLE實例主目錄HOME不同的目錄,或者跟ORACLE實例主目錄相同的目錄,官方文檔介紹如下所示:

 

 

 

·         On the same computer as an existing Oracle database but in a different Oracle home.

 

·         On a system with no Oracle database.

 

·         On the same computer as the Oracle database and in the same Oracle home directory. Note that in this case, the Oracle database and the gateway must be at the same release level.

 

 

如果透明網關的安裝目錄跟ORACLE實例的$ORACLE_HOME一致的話,那么關於透明網關的監聽配置和本地服務名配置(Tnsnames)配置就位於數據庫的監聽文件,tnsnames.ora下,如果透明網關安裝一個單獨路徑下,那么它會有單獨的監聽文件和TNS文件。

 

 

 

透明網關配置

 

 

Gateway初始化參數文件配置

 

透明網關初始化參數文件一般位於$ORACLE_HOME/dg4msql/admin/下, $ORACLE_HOME為透明網關安裝目錄。透明網關初始化參數文件默為initdg4msql.ora, 這意味着gateway system identifier(SID)為dg4msql, 透明網關的SID用來標識一個透明網關,如果你定義了透明網關SID,那么參數文件名也必須隨之修改,這個跟ORACLE實例init{SID}.ora類似。當你需要訪問多個SQL Server數據庫或多個其它數據庫時,你就必須配置多個透明網關SID。

 

 

官方文檔關於透明網關初始化參數文件下參數HS_FDS_CONNECT_INFO的而配置形式為:

 

HS_FDS_CONNECT_INFO=host_name[[:port_number]|/[instance_name]][/database_name]

 

 

#要注意端口號、命令實例/默認實例,以及數據庫名稱。另外,需要注意的是平台不同,分隔符也不通,Windows平台如果使用分隔符"/"的話。則會遇到錯誤,具體參考案例問題3

 

# 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=[192.168.27.57].MSSQLSERVER.TEST

HS_FDS_TRACE_LEVEL=OFF         #默認,一般不需開啟

HS_FDS_RECOVERY_ACCOUNT=RECOVER  #訪問其他數據庫的賬號,這個參數似乎沒有用途,官方文檔也不見細節介紹

HS_FDS_RECOVERY_PWD=RECOVER    #訪問其他數據庫的賬號密碼,這個參數似乎沒有用途,官方文檔也不見細節介紹

 

官方文檔Database Gateway Installation and Configuration Guide關於ORACLE透明網關初始參數文件的介紹如下:

 

9.1.1 Choose a System Identifier for the Gateway

 

 

 

The gateway system identifier (SID) is an alphanumeric character string that identifies a gateway instance. You need one gateway instance, and therefore one gateway SID, for each SQL Server database you are accessing. The SID is used as part of the file name for the initialization parameter file. The default SID is dg4msql.

You can define a gateway SID, but using the default of dg4msql is easier because you do not need to change the initialization parameter file name. However, if you want to access two SQL Server databases, you need two gateway SIDs, one for each instance of the gateway. If you have only one SQL Server database and want to access it sometimes with one set of gateway parameter settings, and other times with different gateway parameter settings, then you will need multiple gateway SIDs for the single SQL Server database.

 

9.1.2 Customize the Initialization Parameter File

 

 

The initialization parameter file must be available when the gateway is started. During installation, the following default initialization parameter file is created:

$ORACLE_HOME/dg4msql/admin/initdg4msql.ora

 

 

Where $ORACLE_HOME is the directory under which the gateway is installed.

This initialization file is for the default gateway SID. If you are not using dg4msql as the gateway SID, you must rename the initialization parameter file using the SID you chose in the preceding step "Choose a System Identifier for the Gateway". This default initialization parameter file is sufficient for starting the gateway, verifying a successful installation, and running the demonstration scripts.

A number of initialization parameters can be used to modify the gateway behavior. Refer to Appendix C, "Initialization Parameters" for the complete list of initialization parameters that can be set. Changes made to the initialization parameters only take effect in the next gateway session. The most important parameter is the HS_FDS_CONNECT_INFO, which describes the connection to the non-Oracle system.

The default initialization parameter file already has an entry for this parameter. The syntax for HS_FDS_CONNECT_INFO is as follows:

HS_FDS_CONNECT_INFO=host_name[[:port_number]|/[instance_name]][/database_name]

 

 

Where:

Variable

Description

host_name

is the host name or IP address of the machine hosting the SQL Server database.

port_number

is the port number of the SQL Server database.

instance_name

is the instance of SQL Server running on the machine.

database_name

is the SQL Server Database database name.

 

Either of the variables port_number or instance_name can be used, but not both together. Optionally, they both can be omitted. The variable database_name is always optional. The slash (/) is required when a particular value is omitted. 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

 

This release of gateway can support IPv6. If IPv6 address format is to be specified, you have to wrap it with square brackets to indicate the separation from the port number. For example,

HS_FDS_CONNECT_INFO=[2001:0db8:20C:F1FF:FEC6:38AF]:1300//SQL_DB1

 

 

 

配置透明網關監聽

 

ORACLE透明網關需要Oracle Net與ORACLE數據庫進行通信,所以在ORACLE透明網關安裝后,必須為ORACLE透明網關配置監聽。Oracle Net 偵聽器偵聽來自 Oracle 數據庫的傳入請求。為了讓Oracle Net Listener為透明網關偵聽, 必須將有關透明網關的信息添加到Oracle Net Listener配置文件listener.ora中。該文件默認位於$ORACLE_HOME/network/admin下,其中$ORACLE_HOME是安裝透明網關的目錄。如果透明網關的安裝目錄和ORACLE實例一致的話,那么它會和數據庫共用監聽文件。

 

clip_image012

 

透明網關監聽的配置跟數據庫的監聽配置基本一致,除了需要注意配置合適的端口號。

 

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = MyTestNT10)(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 
SID_LIST_LISTENER =                                                                          
  (SID_LIST =                                                                                
    (SID_DESC =                                                                              
      (SID_NAME = dg4msql)   #此處為gateway system identifier(SID)的SID,要與initdg4msql.ora中的名字對應           
      (ORACLE_HOME = D:\product\11.2.0\tg_1)  #透明網關安裝的主目錄。                                          
      (PROGRAM = dg4msql)    #此處為固定格式
    )                                                                                        
 )   
 
 
ADR_BASE_LISTENER = D:\product\11.2.0\tg_1
 

另外,如下所示,數據庫實例和透明網關安裝在一起,紅色部分是為透明網關配置監聽而增加的部分。

 

 

[oracle@DB-Server admin]$ more listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = DB-Server.localdomain)(PORT = 1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.57.24)(PORT=1522))  #透明網關的監聽配置

    )

  )

 

 

SID_LIST_LISTENER=

        (SID_LIST =

           (SID_DESC =

                (SID_NAME =  dg4msql)

                (ORACLE_HOME =/u01/app/oracle/product/11.1.0/dbhome_1)

                (PROGRAM = dg4msql)   #此處是固定的

            )

         )

ADR_BASE_LISTENER = /u01/app/oracle

 

 

關於透明網關的監聽,這里我將透明網關和ORACLE實例安裝在相同的Linux服務器下,我們可以對比監聽重啟前后的不同

 

[oracle@DB-Server admin]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2018 09:37:58
 
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                09-JAN-2018 10:51:43
Uptime                    29 days 22 hr. 46 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/DB-Server/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB-Server.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
 

 

重啟后

 

[oracle@DB-Server admin]$ lsnrctl stop

 

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2018 09:43:37

 

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

 

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

The command completed successfully

[oracle@DB-Server admin]$ lsnrctl start

 

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2018 09:43:42

 

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

 

Starting /u01/app/oracle/product/11.1.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

System parameter file is /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/DB-Server/listener/alert/log.xml

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

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB-Server.localdomain)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.20.57.24)(PORT=1522)))

 

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

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date                08-FEB-2018 09:43:43

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/DB-Server/listener/alert/log.xml

Listening Endpoints Summary...

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

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB-Server.localdomain)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.20.57.24)(PORT=1522)))

Services Summary...

Service "dg4msql" has 1 instance(s).

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

The command completed successfully

 

注意,配置了透明網關的監聽后,需要重啟一下監聽服務。

 

 

 

 

配置服務器的TNS

 

數據庫通過TNS連接到透明網關,這個跟數據庫的TNS配置一些區別,例如, 透明網關的TNS配置是有HS=OK的

 

 

[oracle@DB-Server ~]$ cd $ORACLE_HOME

[oracle@DB-Server dbhome_1]$ cd network/admin/

[oracle@DB-Server admin]$ more tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.1.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

GSP =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = DB-Server.localdomain)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = gsp.localdomain)

    )

  )

 

MYGATEWAY=

(DESCRIPTION =

    (ADDRESS = (PROTOCOL=TCP)(HOST=10.20.57.24)(PORT=1522))

    (CONNECT_DATA=(SID=dg4msql))

       (HS=OK)

)

 

 

 

 

創建Database Link

 

在數據庫實例上創建database link,這個很簡單,沒有什么可說的。然后就是測試驗證。

 

 

SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO

 

 "user" IDENTIFIED BY "password" USING 'tns_name_entry';

 

 

透明網關的疑難雜症

 

 

問題1:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

 

如下測試所示,

SQL>  create database link sqlgatetest connect to kkk identified by "kkk123456" using 'SQLGATEWAY';                                                                   

 

Database link created.

 

SQL> select count(*) from dbo.mytest@sqlgatetest;

select count(*) from dbo.mytest@sqlgatetest

                                *

ERROR at line 1:

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

clip_image013

 

其中tnsnames.ora下SQLGATEWAY的配置如下:

 

MYGATEWAY=

(DESCRIPTION =

    (ADDRESS = (PROTOCOL=TCP)(HOST=10.20.57.24)(PORT=1522))

    (CONNECT_DATA=(SID=dg4msql))

       (HS=OK)

)

 

 

[oracle@DB-Server admin]$ tnsping SQLGATEWAY
 
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-FEB-2018 14:56:20
 
Copyright (c) 1997, 2009, Oracle.  All rights reserved.
 
Used parameter files:
/u01/app/oracle/product/11.1.0/dbhome_1/network/admin/sqlnet.ora
 
 
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS_LIST = (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=1522)) (CONNECT_DATA=(SID=dg4msql)) (HS=OK)))
OK (0 msec)

 

這個是因為在配置tnsnames.ora里面的配置錯誤導致,透明網關安裝在一台IP地址為192.168.27.132的Windows Server上,如下所示

 

錯誤的配置

 

SQLGATEWAY=

  (DESCRIPTION=

     (ADDRESS_LIST =

       (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=1522))

         (CONNECT_DATA=(SID=dg4msql))

          (HS=OK)

      )

  )

 

正確的配置:

 

SQLGATEWAY=

  (DESCRIPTION=

       (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=1522))

         (CONNECT_DATA=(SID=dg4msql))

          (HS=OK)

  )

 

另外,如果缺失一個括號之類的,也會遇到這個問題。例如,如下這樣設置,你也會遇到這個錯誤。

 

SQLGATEWAY=

  (DESCRIPTION=

       (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=1522)  #這里少了一個括號

         (CONNECT_DATA=(SID=dg4msql))

          (HS=OK)

  )

 

 

 

問題2:遇到ORA-28545 & ORA-02063錯誤

 

這個問題比較特殊,引起這個錯誤的原因較多,我這里記錄一個我測試時遇到的案例,如下所示:

 

SQL> select count(*) from dbo.mytest@sqlgatetest;

select count(*) from dbo.mytest@sqlgatetest

                                *

ERROR at line 1:

ORA-28545: error diagnosed by Net8 when connecting to an agent

Unable to retrieve text of NETWORK/NCR message 65535

ORA-02063: preceding 2 lines from SQLGATETEST

 

 

clip_image014

 

 

我這里不是默認監聽,而是一個命名監聽,如下所示,檢查監聽狀態,發現沒有

 

 

 

clip_image015

 

修改前配置(注意紅色部分是引起錯誤的原因)

 

ADR_BASE_GW_LISTENER = D:\product\11.2.0\tg_1
 
GW_LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.27.132)(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 
SID_LIST_LISTENER =                                                                          
  (SID_LIST =                                                                                
    (SID_DESC =                                                                              
      (SID_NAME = dg4msql)            
      (ORACLE_HOME = D:\product\11.2.0\tg_1)                                          
      (PROGRAM = dg4msql)   
    )                                                                                        

 

修改為正確的監聽配置 

 

ADR_BASE_GEW_LISTENER = D:\product\11.2.0\tg_1
 
 
 
GEW_LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.27.132)(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 
SID_LIST_GEW_LISTENER =                                                                          
  (SID_LIST =                                                                                
    (SID_DESC =                                                                              
      (SID_NAME = dg4msql)            
      (ORACLE_HOME = D:\product\11.2.0\tg_1)                                          
      (PROGRAM = dg4msql)   
    )                                                                                        

 

clip_image016

 

 

當然,你也可以修改為默認監聽服務,如下所示

 

ADR_BASE_LISTENER = D:\product\11.2.0\tg_1
 
SID_LIST_LISTENER =                                                                          
  (SID_LIST =                                                                                
    (SID_DESC =                                                                              
      (SID_NAME = dg4msql)            
      (ORACLE_HOME = D:\product\11.2.0\tg_1)                                          
      (PROGRAM = dg4msql)   
    )                                                                                        
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.27.132)(PORT = 1522))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
    )
  )
 

 

C:\>lsnrctl status

 

LSNRCTL for 32-bit Windows: Version 11.2.0.1.0 - Production on 08-FEB-2018 15:32

:53

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=152

2)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.1.0 - Produ

ction

Start Date                08-FEB-2018 15:32:20

Uptime                    0 days 0 hr. 0 min. 36 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   D:\product\11.2.0\tg_1\network\admin\listener.ora

Listener Log File         d:\product\11.2.0\tg_1\diag\tnslsnr\GETTestNT38\listen

er\alert\log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.27.132)(PORT=1522)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1522ipc)))

Services Summary...

Service "dg4msql" has 1 instance(s).

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

The command completed successfully

 

 

SQL>  select count(*) from dbo.mytest@sqlgatetest;

 

  COUNT(*)

----------

    339968

 

SQL>

 

 

2、有時候tnsnames.ora中不正確的配置也會遇到這個錯誤。如下所示:

 

 

SQLGATEWAY=

  (DESCRIPTION=

       (ADDRESS_LIST= (PROTOCOL=TCP)(HOST=192.168.27.132)(PORT=1522))  #正確配置為ADDRESS

         (CONNECT_DATA=(SID=dg4msql))

          (HS=OK)

  )

 

此時,你就會遇到這個錯誤

 

SQL> select count(*) from dbo.mytest@sqlgatetest;

select count(*) from dbo.mytest@sqlgatetest

                                *

ERROR at line 1:

ORA-28545: error diagnosed by Net8 when connecting to an agent

Unable to retrieve text of NETWORK/NCR message 65535

ORA-02063: preceding 2 lines from SQLGATETEST

 

 

clip_image017

 

 

3:如果透明網關的監聽服務關閉的話,也會遇到這個錯誤。

 

 

問題3:遇到ORA-28500 & ORA-02063錯誤

 

 

clip_image018

 

遇到這個錯誤,是因為D:\product\11.2.0\tg_1\dg4msql\admin下的initdg4msql.ora配置有問題

 

HS_FDS_CONNECT_INFO=[192.168.27.57]/MSSQLSERVER/TEST

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

如下所示,將分隔符/ 改成. 就能避免這個問題 或者你用//都可以。

 

HS_FDS_CONNECT_INFO=[192.168.27.57].MSSQLSERVER.TEST

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

   HS_FDS_CONNECT_INFO=[192.168.27.57]//MSSQLSERVER//TEST

   HS_FDS_TRACE_LEVEL=OFF

   HS_FDS_RECOVERY_ACCOUNT=RECOVER

   HS_FDS_RECOVERY_PWD=RECOVER

 

 

clip_image019

 

 

問題4:遇到ORA-28500 & ORA-02063錯誤

 

SQL> select count(*) from dbo.mytest@mylink;

select count(*) from dbo.mytest@mylink

                                *

ERROR at line 1:

ORA-28500: connection from ORACLE to a non-Oracle system returned this message:

[Oracle][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access

denied. {08001,NativeErr = 17}[Oracle][ODBC SQL Server

Driver][DBNETLIB]ConnectionOpen (Connect()). {01000,NativeErr =

53}[Oracle][ODBC SQL Server Driver]Invalid connection string attribute {01S00}

ORA-02063: preceding 2 lines from MYLINK

 

 

clip_image020

 

SQL> select count(*) from dbo.mytest@mylink;

select count(*) from dbo.mytest@mylink

                                *

ERROR at line 1:

ORA-28500: connection from ORACLE to a non-Oracle system returned this message:

[Oracle][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access

denied. {08001,NativeErr = 17}[Oracle][ODBC SQL Server

Driver][DBNETLIB]ConnectionOpen (Connect()). {01000,NativeErr =

53}[Oracle][ODBC SQL Server Driver]Invalid connection string attribute {01S00}

ORA-02063: preceding 2 lines from MYLINK

 

出現ORA-28500錯誤,需要關注ORA-28500后面的詳細錯誤信息,根據具體錯誤信息進行判別,例如,此處提示SQL Server does not exist or access denied",檢查后發現,是因為initdg4msql.ora下,IP地址配置錯誤了。修改為正確的IP地址后就OK了。

 

 

HS_FDS_CONNECT_INFO=[192.168.27.57].MSSQLSERVER.TEST

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

 

 

[oracle@DB-Server admin]$ tnsping mytest;

 

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 06-FEB-2018 11:15:33

 

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

 

Used parameter files:

/u01/app/oracle/product/11.1.0/dbhome_1/network/admin/sqlnet.ora

 

 

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.103.51)(PORT=1522)) (CONNECT_DATA=(SID=mylis)) (HS=OK))

TNS-12541: TNS:no listener

 

 

 

ERROR at line 1:

ORA-28513: internal error in heterogeneous remote agent

Solution:

This error can happen when the gatewayinit file is not found in the gateway/admin directory or if it has an error inthe file. When there's a config error in the file it commonly reports the linein which the error is.

 

 

其它關於透明網關訪問SQL Server的一些報錯或疑難雜症,可以參考官方文檔How to Resolve Common Errors Encountered while using Database Gateways (DG4IFMX, Dg4MSQL, DG4SYBS), DG4ODBC or Generic Connectivity (文檔 ID 234517.1)。 在此不一一測試。

 

 

參考資料:

 

How to Resolve Common Errors Encountered while using Database Gateways (DG4IFMX, Dg4MSQL, DG4SYBS), DG4ODBC or Generic Connectivity (文檔 ID 234517.1)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM