Oracle 透過透明閘道器 訪問 mysql
部署環境說明
oracle 伺服器:
IP:192.168.142.13 (centos7.2 )
Database Version:11.2.0.4
mysql 伺服器
IP:192.168.142.12 (centos7.2 )
mysql version: 5.6.35
部署具體步驟
和DG4ODBC 是32 位還是64 位.
[oracle@ljw ~]$ file /oracle/app/product/11.2.0/db_1/bin/dg4odbc
/oracle/app/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.18, not stripped
這裡可以看到是64 位的。所以必須使用64 位的ODBC Driver Manager 和64 位的ODBC Driver.
下載並安裝64 位的ODBC Driver Manager UnixODBC
下載地址:
請參看官方文件 Detailed Overview of Connecting Oracle to MySQL Using DG4ODBC Database Link ( 文件 ID 1320645.1)
下載最新版本
下載並安裝ODBC Driver
http://dev.mysql.com/downloads/connector/odbc/#downloads
以上兩個介質上傳至: /tmp
Root 使用者 :
[root@ljw tmp]# ls –rtl
total 12756
-rw-r--r-- 1 root root 11230673 Jul 1 00:17 mysql-connector-odbc-5.3.8-linux-el6-x86-64bit.tar.gz
-rw-r--r-- 1 root root 1830660 Jul 1 00:21 unixODBC-2.3.4.tar.gz
[root@ljw tmp]# chmod 777 *
[root@ljw tmp]# ls -rtl
total 12756
-rwxrwxrwx 1 root root 11230673 Jul 1 00:17 mysql-connector-odbc-5.3.8-linux-el6-x86-64bit.tar.gz
-rwxrwxrwx 1 root root 1830660 Jul 1 00:21 unixODBC-2.3.4.tar.gz
Oracle 使用者:
tar -zxvf mysql-connector-odbc-5.3.8-linux-el6-x86-64bit.tar.gz
mv mysql-connector-odbc-5.3.8-linux-el6-x86-64bit /oracle/app/my-odbc-drive-5.3.8
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
在安裝的/usr/local/unixODBC/etc/ 路徑下配置odbc.ini 配置檔案
[root@ljw /]# cd /usr/local/unixODBC/etc/
[root@ljw etc]# ls –rtl
total 4
-rw-r--r-- 1 root root 0 Jul 1 14:08 odbcinst.ini
-rw-r--r-- 1 root root 0 Jul 1 14:08 odbc.ini
drwxr-xr-x 2 root root 4096 Jul 1 14:08 ODBCDataSources
[root@ljw etc]# vi odbc.ini
[myodbc5]
Driver=/oracle/app/my-odbc-drive-5.3.8/lib/libmyodbc5w.so
Description=Connector/ODBC 5.3.8 Driver DSN
SERVER=192.168.142.12
PORT=3306
USER=mysql
PASSWORD=mysql
DATABASE=ljw
OPTION=0
TRACE=OFF
在.bash_profile 配置相關環節變數LD_LIBRARY_PATH 、UNIXODBC_DIR 、ODBCINI 及ODBCSYSINI
Oracle 使用者:
[oracle@ljw etc]$ cd
[oracle@ljw ~]$ 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
LD_LIBRARY_PATH=/usr/local/unixODBC/lib:$ORACLE_HOME/lib:/usr/lib
UNIXODBC_DIR=/usr/local/unixODBC
ODBCINI=$UNIXODBC_DIR/etc/odbc.ini
ODBCSYSINI=$UNIXODBC_DIR/etc
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH UNIXODBC_DIR ODBCINI ODBCSYSINI
驗證ODBC 連線
Mysql 伺服器端
mysql> create user mysql@ 192.168.142.13 identified by 'mysql';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on ljw .* to 'mysql'@'192.168.142.13';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[oracle@ljw ~]$ cd /usr/local/unixODBC/bin/
[oracle@ljw bin]$ ./isql myodbc5 -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit;
配置tnsnames.ora
[oracle@ljw /]$ vi /oracle/app/product/11.2.0/db_1/network/admin/tnsnames.ora
myodbc5 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ljw)(PORT = 1521))
(CONNECT_DATA =
(SID = myodbc5)
)
(HS=OK)
)
配置listener.ora
[oracle@ljw /]$ vi /oracle/app/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /oracle/app/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ljw)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /oracle/app
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=myodbc5)
(ORACLE_HOME=/oracle/app/product/11.2.0/db_1)
(PROGRAM=dg4odbc)
(ENV="LD_LIBRARY_PATH=/usr/local/unixODBC/lib:/oracle/app/product/11.2.0/db_1/lib:/usr/lib")
)
)
建立oracle 相關init<sid>.ora 檔案
[oracle@ljw /]$ vi /oracle/app/product/11.2.0/db_1/hs/admin/initmyodbc5.ora
HS_FDS_CONNECT_INFO = myodbc5
HS_FDS_TRACE_LEVEL = off
HS_FDS_TRACE_FILE_NAME = myodbc5.trc
HS_LANGUAGE = AMERICAN_AMERICA.UTF8
HS_NLS_NCHAR = UCS2
HS_FDS_SHAREABLE_NAME =/usr/local/unixODBC/lib/libodbc.so
set LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/lib:/usr/lib64
set ODBCINI=/usr/local/unixODBC/etc/odbc.ini
使上述配置檔案生效
[oracle@ljw /]$ lsnrctl reload
驗證配置是否正確
[oracle@ljw /]$ tnsping myodbc5
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 01-JUL-2017 14:45:39
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used parameter files:
/oracle/app/product/11.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ljw)(PORT = 1521)) (CONNECT_DATA = (SID = myodbc5)) (HS=OK))
OK (0 msec)
建立dblink 名稱mysql_link 並查詢ljw 資料庫table_test 表中的資料
[oracle@ljw /]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jul 1 14:47:45 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link mysql_dblink connect to "mysql" identified by "mysql" using 'myodbc5';
Database link created.
SQL> select * from "table_test"@mysql_dblink;
id name
-------------------- --------------------
1 hzmcdba
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23825935/viewspace-2917441/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11.2.0.4 透過透明閘道器訪問mysql 8.0.16OracleMySql
- Oracle 通過透明閘道器訪問mysqlOracleMySql
- Oracle透明閘道器訪問MySQL資料庫OracleMySql資料庫
- Oracle透明閘道器訪問SQLServer資料庫OracleSQLServer資料庫
- 10g透明閘道器訪問sqlserverSQLServer
- 【磐維資料庫】Oracle(透明閘道器)訪問磐維資料庫(PanWeiDB)資料庫Oracle
- ORACLE通過透明閘道器建dblink連線Postgresql的幾個問題OracleSQL
- Oracle/MySQL透過odbc訪問PostgreSQL for LightDBOracleMySql
- 安全閘道器 透明加解密解密
- 透過Kerberos認證訪問Oracle11gROSOracle
- 不設定預設閘道器,可訪問網路
- 服務閘道器過濾器過濾器
- 透過API訪問HDFSAPI
- PLC透過Profinet轉Modbus閘道器與流量計通訊案例
- 如何實現PLC透過MQTT工業閘道器接入雲平臺MQQT
- 智慧儀表透過Modbus轉Profinet閘道器與PLC通訊方案
- 變頻器透過Modbus轉Profinet閘道器連線電機與PLC通訊
- PLC透過Modbus轉Profinet閘道器連線壓力計的配置方法
- vnc viewer透過外網訪問,vnc viewer透過外網訪問8個步驟VNCView
- Ceph物件閘道器,多區域閘道器物件
- Janusec應用安全閘道器(WAF閘道器)
- 日均數十億訪問量!解讀個推API閘道器高能演進API
- 臺達PLC透過工業智慧閘道器實現MQTT資料上雲?MQQT
- 什麼是閘道器?閘道器的作用是什麼,閘道器的作用詳解
- gateway 閘道器Gateway
- 閘道器GatewayGateway
- 感測器透過Profinet轉Modbus閘道器與PLC通訊在生產線的應用
- 影片閘道器如何配置透過GB28181協議推送到上級平臺協議
- 透過閘道器如何實現信捷PLC的遠端控制和程式上下載?
- 【.bat】IISExpress配置透過IP訪問程式BATExpress
- docker 中容器透過 API 互相訪問DockerAPI
- API閘道器,企業級閘道器可擴充套件API套件
- 《springcloud 二》微服務動態閘道器,閘道器叢集SpringGCCloud微服務
- SpringCloud-Gateway 閘道器路由、斷言、過濾SpringGCCloudGateway路由
- 使用路由閘道器的全域性過濾功能路由
- 臺達變頻透過Modbus轉Profinet閘道器可以在環網冗餘中使用
- svn透過https協議訪問的搭建過程HTTP協議
- RS485感測器資料透過物聯網閘道器上傳到雲端伺服器伺服器