且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将MySQL DB链接到Oracle DB

更新时间:2021-10-23 01:38:21

是的,可以. 为此,可以将dg4odbc(假设oracle> = v11)与unixODBC一起用作odbc驱动程序管理器,将freeTDS用作SQLServer的odbc驱动程序.

Yes, you can. For that you use the dg4odbc (assuming oracle >= v11) in combination with unixODBC as odbc driver manager and freeTDS as odbc driver for SQLServer.

您要做的是在listener.ora中创建一个类似于

What you do is create a listener entry in your listener.ora similar to

   (SID_DESC =
       (SID_NAME=yourdb)
       (ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1 )
       (PROGRAM = dg4odbc)
       (ENVS = "LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0.3/dbhome_1/lib:/usr/local/freetds/lib")
   )

创建一个指向该特殊SID的tns别名-yourdb,它将用作SQLServer的网关.

create a tns alias that points to this special SID - yourdb - that is going to act as the gateway to SQLServer.

your_tns_alias =

your_tns_alias =

        (DESCRIPTION =
        (ADDRESS_LIST=
        (ADDRESS =(COMMUNITY = tcp.world)(PROTOCOL = TCP)(Host = your.db.server)
        (Port = 1521)
        )
        )
        (CONNECT_DATA =
        (SID = yourdb)
        )
        (HS=ok)
)

注意hs = ok条目,这表明我们与网关有关.

mind the hs=ok entry, this tells we have to do with a gateway.

在$ ORACLE_HOME/hs/admin中,创建一个名为inityourdb.ora的文件,该文件用于配置网关.

In $ORACLE_HOME/hs/admin create a file named inityourdb.ora where the configuration of the gateway comes.

HS_FDS_CONNECT_INFO = yourdsn
HS_DB_NAME = yourdsn
HS_FDS_SUPPORT_STATISTICS = FALSE
HS_FDS_SHAREABLE_NAME=/usr/local/unixODBC/lib/libodbc.so
#HS_FDS_TRACE_LEVEL=debug
HS_FDS_TRACE_LEVEL=off
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P15

这是Oracle rdbms环境和ODBC之间的接口.指定的是驱动程序管理器DSN,这里也可以是一些调整参数. DSN就像常规ODBC管理一样完成.一些驱动程序需要自己的特殊参数,例如Oracle的ORACLE_HOME才能找到自己的管理程序,例如错误消息....这是包含那些指针的文件.

This is the interface between the Oracle rdbms environment and ODBC. Specified are the driver manager, the DSN, here also can be some tuning parameters. The DSN is as done like regular ODBC administration. Some drivers need their own special parameters, similar like ORACLE_HOME for Oracle in order to find their own administration, like error messages .... This is the file to include those pointers.

玩得开心!