Linux 下通过unixODBC使用Oracle+DBLINK 访问 Mysql

阅读更多

本文来自:Informatica技术超群(群号:0112443162 )【作者没找到 sorry。。。我转在这啦】

1-安装unixODBC

    tar zxvf unixODBC-2.2.12.tar.gz(或者tar.tar)

    cd unixODBC-2.2.12

    ./configure --prefix=/usr/local/unixODBC-2.2.12 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc

    make

    make install

2-将mysql驱动拷贝到linux,放到lib或lib64目录

3-配置odbc,并使用isql命令测试odbc

 

/etc/odbc.ini

 

[myodbc_test]

Driver = /usr/lib64/libmyodbc5.so

Server   = 192.168.2.1

User = root

Password = root

Port = 3306

database = fpyj_sms

 

显示以下内容表示测试连接成功:

[root@linux-vm001 ~]# isql myodbc_test

+---------------------------------------+

| Connected!                            |

|                                       |

| sql-statement                         |

| help [tablename]                      |

| quit                                  |

|                                       |

+---------------------------------------+

SQL> 

 

4-配置oracle监听

$TNS_ADMIN/listener.ora文件中添加

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = dg4odbc)

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

      (PROGRAM = dg4odbc)

    )

  )

 

5-配置oracle监听启动文件

$ORACLE_HOME/hs/admin/下添加文件 init名称.ora(如initdg4odbc.ora)

 

# This is a sample agent init file that contains the HS parameters that are

# needed for the Database Gateway for ODBC

 

#

# HS init parameters

#

HS_FDS_CONNECT_INFO = myodbc_test

HS_FDS_TRACE_LEVEL = off

HS_FDS_SHAREABLE_NAME = /usr/lib64/libmyodbc5.so

 

#

# ODBC specific environment variables

#

set ODBCINI=/etc/odbc.ini

 

#

# Environment variables required for the non-Oracle system

#

#set =

 

6-配置客户端连接tns

$TNS_ADMIN/tnsnames.ora文件中添加连接

 

dg4odbc = 

  (DESCRIPTION=

    (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))

    (CONNECT_DATA=(SID=dg4odbc))

    (HS=OK)

  )

 

7-建立db_link操作mysql

drop database link db4smsoto;

create database link db4smsoto

  connect to "root"

  identified by "y4yhl9tbz"

  using 'dg4odbc';

或者省略第六步,直接建立db_link

drop database link db4smsoto;

create database link db4smsoto

  connect to "root"

  identified by "y4yhl9tbz"

  using '(DESCRIPTION=

    (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))

    (CONNECT_DATA=(SID=myodbc4smsoto))

    (HS=OK)

  )';

 

你可能感兴趣的:(mysql,linux,oracle)