日期:2014-05-16  浏览次数:20426 次

Oracle通过dblink连接到多台MySQL

环境:oracle 11.2.0.1.0 RHEL5.3 64bit   mysql Server version: 5.5.9

1:下载[ODBC Driver Manager] unionODBC2.2.14,解压后放入/u01/app/tools/unionodbc  目录下

[oracle@wonder tools]$ ls /u01/app/tools/unionodbc/
bin  include  lib

2:下载mysql-connector-odbc-3.51.30-linux-rhel5-x86-64bit.tar.gz解压重命名到my5
 
[oracle@szmlserver12_32 tools]$ ls /u01/app/tools/
my5  odbc.ini  unionodbc

3:配置 ODBC data source for MySQLConnector/ODBC driver

[oracle@wonder tools]$ cat /u01/app/tools/odbc.ini 
[myodbc3]

Driver = /u01/app/tools/my5/lib/libmyodbc3.so
SERVER = 22.4.22.16
PORT = 3306
USER = soft
PASSWORD = Ugfd3589
DATABASE = estore
OPTION = 3
SOCKET = 

4:设置环境变量

[oracle@wonder tools]$ cat ~/.bash_profile 
PATH=$PATH:$HOME/bin
export PATH

export ORACLE_BASE=/u01/app
export ORACLE_HOME=/u01/app/oracle
export ORACLE_SID=hidb
export LANG=en
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/app/tools/unionodbc/lib
export ODBCINI=/u01/app/tools/odbc.ini
export PATH=$ORACLE_HOME/bin:$PATH:/u01/app/tools/unionodbc/bin

红色为新增部分

5:测试连接成功

[oracle@wonder tools]$ isql myodbc3 -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

6:配置listener.ora

[grid@wonder ~]$ cat /u01/app/11.2.0/grid/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = wonder.easou.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/11.2.0

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=OFF

SID_LIST_LISTENER=
   (SID_LIST=
        (SID_DESC=
          (SID_NAME= myodbc3)
          (ORACLE_HOME= /u01/app/oracle)
           (PROGRAM = dg4odbc)
           (ENVS=LD_LIBRARY_PATH=/u01/app/oracle/bin:/u01/app/tools/unionodbc/lib:/u01/app/tools/my5/lib)
         )
       )


7:配置tnsnames.ora,最后增加如下内容

myodbc3=
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SID = myodbc3)
    )
(HS = OK)
  )


8:配置HS