ITPub博客

首页 > 数据库 > Oracle > oracle 透明网关,oracle到mysql的dblink

oracle 透明网关,oracle到mysql的dblink

原创 Oracle 作者:wanglinghua0907 时间:2024-01-22 10:19:29 0 删除 编辑

总体思路

oracle——>dg4odbc——>odbc——>mysql


1、查看DG4ODBC版本

[oracle@node1 ~]$ file $ORACLE_HOME/bin/dg4odbc

/tmp/soft/app/oracle/product/112040/dbhome_1/bin/dg4odbc: ELF 64-bit LSB executable, x86-64,

version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped


2.下载并安装64位的ODBC Driver Manager UnixODBC

下载地址:

请参看官方文档 Detailed Overview of Connecting Oracle to MySQL Using DG4ODBC Database Link

 (文档 ID 1320645.1)

下载最新版本

uniHO C unixODBC , Manager Drivers Links Download „ Manuals GUI-Qt Testing Contact Information Nick Gorham Support this Distribution Format unixODBC is currently availible in a gzip, tar format. This means that you should; 1 . copy the unixODBC-2.3.12.tar.gz file somewhere you can create files and directories 2. gunzip unixODBC*.tar.gz 3. tar xvf unixODBC•.tar Doing so will create a unixODBC directory with all source files inside. Via HTTP: unixODBC-2.3.12.tar.gz MD5 (d62167d85bCb459C200coe4b5a63ee48): Source Access Public git access is also availible for those that want the very latest Sources (bleeding edge). so you may want to use these commands, When prompted for a password for anonymous, simply press the Enter key git clone https://github.com/lurcher/unixODBC.git unixodbc Developers Of unixODBC work from this git so the state Of the sources in there will vary. To build from the tree downloaded, run the following command (in the root of the downloaded tree) autoreconf -fi This will build the configure script. To build from git, you need some current tools, these are what we recommend: • automake . autoconf • libtool These can be found from the GNU web site or its many mirrors.


安装

介质上传/tmp

root赋权:

[root@ljw tmp]# chmod 777 *

[root@ljw tmp]# ls -rtl

total 12756

-rwxrwxrwx 1 root root  1830660 Jul  1 00:21 unixODBC-2.3.4.tar.gz


oracle解压:

解压unixODBC

tar -zxvf unixODBC-2.3.4.tar.gz


root安装:

[root@ljw /]# mkdir -p /usr/local/unixODBC

[root@ljw /]# cd /tmp/unixODBC-2.3.4

[root@ljw unixODBC-2.3.4]# ./configure --prefix=/usr/local/unixODBC

[root@ljw unixODBC-2.3.4]# make & make install


测试:

[root@node1 etc]# odbcinst -j

[ rootßnodel odbcinst -j urnxooac 2.2.14 DRIVERS.... ..... ... • . letc/odbcinst . ini SYSTEM DATA SOURCES: /etc/odbc . ini FILE DATA SOURCES.. : USER DATA SOURCES.. : 'root/ . odbc. ini SQLULEN Size. 8 SQLLEN Size. SQLSETPOSIROI,N Size. : 8 [ rootsnodel etc]e

3.下载并安装ODBC Driver

http://dev.mysql.com/downloads/connector/odbc/#downloads 


安装

rpm -ivh mysql-connector-odbc-8.0.33-1.el6.x86_64.rpm

 

4.配置:

vi /etc/odbc.ini

[mysql]

Description = mysql

Driver = MySQL ODBC 8.0 Unicode Driver

Server = ** //MySQL服务器IP

Database = yqt_if //MySQL数据库名 (对大小写敏感)

Port = 3306 //端口

USER = root //数据库用户名

Password = root //用户名密码

Socket =

Option = 3

Stmt =

CHARSET = UTF8 //数据库字符集

[ rootßnodel more odbc.ini (mysql] Description = mysql Driver = MYSQL ODBC 8.8 urncode Driver Server = 192. 168.83 .95 Database = hzmc port 3306 USER kaka Password = oracle Socket = Option = 3 Stmt = CHARSET - UTF8


driver的内容见同路径下的odbcinst.ini 

PostgreSQL I Description Driver Setup Driver64 Setup64 FileUsage [hYSQLl Description Driver Setup Driver64 setup64 FileUsage [ QL ODBC Driver UsageCount [hySQL ODBC Driver UsageCount [ rootOnode1 [ rootOnode1 [inysql I root@nodel etc] # 8.8 more odbcinst . ini = ODBC for postgresQL = /usr/lib/psqlodbc.so = /usr/1ib/1ibodbcpsq1S.so = /usr/1ib64/psq10dbc.so = /usr/1ib64/1ibodbcpsq1S. so = ODBC for MYSQL = /usr/1ib/1ibmyodbc5. so = /usr/1ib/1ibodbcmyS. so = /usr/1ib64/1ibmyodbc5. so = /usr/1ib64/1ibodbcmyS.so Unicode us r Driverl 1 myo w. so 8.8 ANSI Driver] = /usr/1ib64/1ibmyodbc8a. so etc] # etc] more odbc. ini Driver = MySQL ODBC 8.0 Unicode Driver Database = hzmc port =


验证:

isql mysql -v

[rootßnodel Connected ! sql-statement help [tablenamel quit isq1 mysql -

5. 在.bash_profile配置相关环节变量 

[oracle@ljw etc]$ vi ~/.bash_profile

 

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
 
# User specific environment and startup programs
 
PATH=$PATH:$HOME/bin
 
export PATH
 
umask 022
export ORACLE_BASE=/oracle/app
export ORACLE_HOME=/oracle/app/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH

6.配置监听

添加静态监听

vi listener.ora

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.83.50)(PORT = 1521))
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC=
      (SID_NAME=myodbc5)
      (ORACLE_HOME=/tmp/soft/app/oracle/product/112040/dbhome_1)
      (PROGRAM=dg4odbc)
    )
  )

7.配置tns

vi tnsnames.ora

myodbc5 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.83.50 )(PORT = 1521))
    (CONNECT_DATA =
      (SID=myodbc5)
    )
      (HS=OK)
  )

8.配置odbc

cd $ORACLE_HOME/hs/admin


vi initmyodbc5.ora

HS_FDS_CONNECT_INFO=mysql   
HS_FDS_SHAREABLE_NAME=/usr/lib64/libodbc.so
HS_FDS_SUPPORT_STATISTICS= FALSE
HS_LANGUAGE=AMERICAN_AMERICA.UTF8
HS_NLS_NCHAR=UCS2  
set  ODBCINI=/etc/odbc.ini

9.监听重启

lsnrctl reload


10.创建dblink

create public database link new_e connect to "kaka" identified by "oracle" using 'myodbc5';


select * from gaga@new_e;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69980685/viewspace-3004623/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE、sql server、oceanbase数据库专家,拥有7年以上的大型数据库运维经验,主方向oracle,擅长故障排除、诊断,大体量(TB)迁移,异常故障修复等。拥有丰富主导大型项目经验。服务行业包括:运营商、银行、金融业、政府单位、医疗、制造业、高校等等。

注册时间:2020-07-31

  • 博文量
    116
  • 访问量
    88778