1. 程式人生 > >oracle通過DBlink連線mysql

oracle通過DBlink連線mysql

oracle:系統redhat 5.5  資料庫:11.2.0.1 mysql:系統centos6.3  資料庫:5.6.21 1.先裝 mysql-connector-odbc和unixODBC

[[email protected] ~]# rpm -qa | grep mysql
mysql-5.0.77-4.el5_4.2
mysql-5.0.77-4.el5_4.2
mysql-connector-odbc-5.1.13-1.rhel5

[[email protected] ~]# rpm -qa | grep ODBC
unixODBC-devel-2.2.11-7.1
unixODBC-2.2.11-7.1
unixODBC-devel-2.2.11-7.1
unixODBC-2.2.11-7.1

2.配置 /etc/odbc.ini
[myodbc3]
Driver       = /usr/lib64/libmyodbc5.so
Description  = MySQL ODBC 5.1 Driver DSN
SERVER       = 192.1.1.200
PORT         = 3306
USER         = bi
Password     = 123456
Database     = chanpin
OPTION       = 3
SOCKET       =
charset      = utf8

3.配置/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5.so
Setup = /usr/lib64/libodbcmyS.so
FileUsage = 1

4.測試連線
[
[email protected]
~]# isql myodbc3 -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

5.配置oracle環境變數
export ORACLE_BASE=/u01/app/oracle
export GRID_HOME=/u01/grid
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=rac1
export BASE_PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$BASE_PATH:/usr/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/hs/lib:/usr/lib64
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
ODBCINI=/etc/odbc.ini; export ODBCINI
ODBCSYSINI=/etc; export ODBCSYSINI
ODBCINSTINI=/etc/odbc.ini
export ODBCINSTINI

6.配置監聽
listener.ora:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1.1.100)(PORT = 1522))
    )
  )

SID_LIST_LISTENER=
   (SID_LIST=