Oracle使用dblink连接MySQL以及遇到的一些问题
主要参考了mos文档:Detailed Overview of Connecting Oracle to MySQL Using DG4ODBC Database Link (文档 ID 1320645.1)
但实际上文档个人觉得还不算特别详细,而且unixODBC实际是可以不用编译安装的,减少改动风险。
其中,设计了一些概念:| [ORACLE] <---> [DG4ODBC] <---> [ODBC Driver Manager] <---> [ODBC Driver] |
先按照文档步骤来,根据需要会做些改动。
步骤1.确定[Oracle] and [DG4ODBC]位数:
[oracle@qadb ~]$ file $ORACLE_HOME/bin/dg4odbc /u01/app/oracle/product/11.2.0/db_1/bin/dg4odbc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=8f5a341e1cb474a4aabc76f1c3ba26d70be2d2a5, not stripped
现在应该基本都是64位了吧。
步骤2.安装ODBC Driver Manager
文档一句话带过,就让你安装配置ODBC Driver Manager。
目前下载最新安装包为:unixODBC-2.3.11.tar.gz,跟Nginx,openssh之类的一样是需要编译安装的,
但是实际上Oracle服务器,比如11G版本的Oracle是要求安装:传送门,引用关键信息如下:
-
On Oracle Linux 6, Red Hat Enterprise Linux 6, and Asianux Server 4:
unixODBC-2.2.14-11.el6 (x86_64) or later unixODBC-2.2.14-11.el6.i686 or later unixODBC-devel-2.2.14-11.el6 (x86_64) or later unixODBC-devel-2.2.14-11.el6.i686 or later
-
On Oracle Linux 7, and Red Hat Enterprise Linux 7:
unixODBC-2.3.1-6.el7.x86_64 or later unixODBC-2.3.1-6.el7.i686 or later unixODBC-devel-2.3.1-6.el7.x86_64 or later unixODBC-devel-2.3.1-6.el7.i686 or later
因此,ODBC Driver Manager在一台正常运行的Oracle服务器上已经默认安装好了的,无需通过编译源码安装的方式增加风险。
[oracle@qadb ~]$ rpm -qa | grep unix unixODBC-2.3.1-14.0.1.el7.x86_64 unixODBC-devel-2.3.1-14.0.1.el7.x86_64 unixODBC-devel-2.3.1-14.0.1.el7.i686 unixODBC-2.3.1-14.0.1.el7.i686
查看相关配置:
[oracle@qadb ~]$ odbcinst -j unixODBC 2.3.1 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /home/oracle/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8
步骤3:安装ODBC Driver
官网:http://dev.mysql.com/downloads/connector/odbc/#downloads
下载上传后解压重命名:
[oracle@qadb soft]$ tar -zxvf mysql-connector-odbc-8.0.31-linux-glibc2.27-x86-64bit.tar.gz [oracle@qadb soft]$ mv mysql-connector-odbc-8.0.31-linux-glibc2.27-x86-64bit mysql-connector-odbc-8.0.31
步骤4:配置ODBC数据源
[root@qadb ~]# vi /etc/odbc.ini [mysqldb] Driver = /soft/mysql-connector-odbc-8.0.31/lib/libmyodbc8w.so Description = MySQL ODBC 8.0 Unicode Driver SERVER = 192.168.1.124 PORT = 3306 USER = root PASSWORD = root DATABASE = cbepcapture OPTION = 0 TRACE = OFF
步骤5:验证ODBC连接
故障1:
[root@qadb lib]# isql mysqldb -v [01000][unixODBC][Driver Manager]Can't open lib '/soft/mysql-connector-odbc-8.0.31/lib/libmyodbc8w.so' : file not found [ISQL]ERROR: Could not SQLConnect [root@qadb lib]# ll /soft/mysql-connector-odbc-8.0.31/lib/libmyodbc8w.so -rw-r--r-- 1 oracle oinstall 15541312 Sep 2 00:02 /soft/mysql-connector-odbc-8.0.31/lib/libmyodbc8w.so [root@qadb lib]# [root@qadb lib]# ldd libmyodbc8w.so ldd: warning: you do not have execution permission for `./libmyodbc8w.so' ./libmyodbc8w.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./libmyodbc8w.so) ./libmyodbc8w.so: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./libmyodbc8w.so) ./libmyodbc8w.so: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./libmyodbc8w.so) ./libmyodbc8w.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./libmyodbc8w.so) ./libmyodbc8w.so: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /soft/mysql-connector-odbc-8.0.31/lib/./private/libcrypto.so.1.1) linux-vdso.so.1 => (0x00007ffc303fb000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff3f47d1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007ff3f45cd000) libcrypto.so.1.1 => /soft/mysql-connector-odbc-8.0.31/lib/./private/libcrypto.so.1.1 (0x00007ff3f40fd000) libssl.so.1.1 => /soft/mysql-connector-odbc-8.0.31/lib/./private/libssl.so.1.1 (0x00007ff3f3e69000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007ff3f3c4f000) libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007ff3f3a3d000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff3f3735000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff3f351f000) libc.so.6 => /lib64/libc.so.6 (0x00007ff3f3151000) /lib64/ld-linux-x86-64.so.2 (0x00007ff3f53d6000) libltdl.so.7 => /lib64/libltdl.so.7 (0x00007ff3f2f47000) libm.so.6 => /lib64/libm.so.6 (0x00007ff3f2c45000) [root@qadb lib]# strings /lib64/libstdc++.so.6 | grep GLIBC GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBCXX_3.4.14 GLIBCXX_3.4.15 GLIBCXX_3.4.16 GLIBCXX_3.4.17 GLIBCXX_3.4.18 GLIBCXX_3.4.19 GLIBC_2.3 GLIBC_2.2.5 GLIBC_2.14 GLIBC_2.4 GLIBC_2.3.2 GLIBCXX_DEBUG_MESSAGE_LENGTHView Code
标签:GLIBCXX,unixODBC,dblink,3.4,libmyodbc8w,so,MySQL,Oracle,lib64 From: https://www.cnblogs.com/PiscesCanon/p/16977636.html