Oracle 通過透明閘道器訪問mysql
環境準備
oracle 伺服器 :
IP:192.168.142.11 ( redhel 6.4 )
mysql version: 5.6.35-log LLL for mysqltest
1. 首先要檢查 Oracle 和 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.
2. 下載並安裝 64 位的 ODBC Driver Manager UnixODBC
請參看官方文件 Detailed Overview of Connecting Oracle to MySQL Using DG4ODBC Database Link ( 文件 ID 1320645.1)
3. 下載並安裝 ODBC Driver
http://dev.mysql.com/downloads/connector/odbc/#downloads
-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
-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
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@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
4 .在安裝的 /usr/local/unixODBC/etc/ 路徑下配置 odbc.ini 配置檔案
[root@ljw /]# cd /usr/local/unixODBC/etc/
-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
Driver=/oracle/app/my-odbc-drive-5.3.8/lib/libmyodbc5w.so
Description=Connector/ODBC 5.3.8 Driver DSN
5. 在 .bash_profile 配置相關環節變數 LD_LIBRARY_PATH 、 UNIXODBC_DIR 、 ODBCINI 及 ODBCSYSINI
[oracle@ljw ~]$ vi .bash_profile
# Get the aliases and functions
# User specific environment and startup programs
export ORACLE_BASE=/oracle/app
export ORACLE_HOME=/oracle/app/product/11.2.0/db_1
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
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH UNIXODBC_DIR ODBCINI ODBCSYSINI
6. 驗證 ODBC 連線
mysql> create user mysql@ 192.168.142.11 identified by 'mysql';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on ljw .* to 'mysql'@'192.168.142.11';
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
[oracle@ljw ~]$ cd /usr/local/unixODBC/bin/
[oracle@ljw bin]$ ./isql myodbc5 -v
+---------------------------------------+
+---------------------------------------+
7. 配置 tnsnames.ora
[oracle@ljw /]$ vi /oracle/app/product/11.2.0/db_1/network/admin/tnsnames.ora
(ADDRESS = (PROTOCOL = TCP)(HOST = ljw)(PORT = 1521))
8. 配置 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.
(ADDRESS = (PROTOCOL = TCP)(HOST = ljw)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
ADR_BASE_LISTENER = /oracle/app
(ORACLE_HOME=/oracle/app/product/11.2.0/db_1)
(ENV="LD_LIBRARY_PATH=/usr/local/unixODBC/lib:/oracle/app/product/11.2.0/db_1/lib:/usr/lib")
9. 建立 oracle 相關 init<sid>.ora 檔案
[oracle@ljw /]$ vi /oracle/app/product/11.2.0/db_1/hs/admin/initmyodbc5.ora
HS_FDS_TRACE_FILE_NAME = myodbc5.trc
HS_LANGUAGE = AMERICAN_AMERICA.UTF8
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
10. 使上述配置檔案生效
[oracle@ljw /]$ lsnrctl reload
11. 驗證配置是否正確
[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.
/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))
12. 建立 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.
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';
SQL> select * from "table_test"@mysql_dblink;
-------------------- --------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23732248/viewspace-2757984/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 通過透明閘道器訪問mysql配置步驟OracleMySql
- Oracle 透過透明閘道器 訪問 mysqlOracleMySql
- ORACLE 透明閘道器訪問 MYSQL 表OracleMySql
- Oracle透明閘道器訪問Mysql—luckyfriendsOracleMySql
- Oracle透明閘道器訪問MySQL資料庫OracleMySql資料庫
- Oracle 11.2.0.4 透過透明閘道器訪問mysql 8.0.16OracleMySql
- oracle透過透明閘道器訪問sql serverOracleSQLServer
- Oracle10g中通過透明閘道器、DBLink訪問MySQL資料OracleMySql
- oracle通過透明閘道器連線mysql的配置OracleMySql
- Oracle Gateways透明閘道器訪問SQL ServerOracleGatewaySQLServer
- Oracle透明閘道器訪問SQLServer資料庫OracleSQLServer資料庫
- oracle通過透明閘道器(Oracle Transparent Geteways),訪問ms sql server和其他資料庫OracleSQLServer資料庫
- Oracle 透明閘道器連線MySQLOracleMySql
- ORACLE通過透明閘道器連線DB2OracleDB2
- Oracle配置透明閘道器訪問sql2000OracleSQL
- 10g透明閘道器訪問sqlserverSQLServer
- oracle透明閘道器之異構資料庫的訪問Oracle資料庫
- ORACLE通過透明閘道器建dblink連線Postgresql的幾個問題OracleSQL
- ORACLE透明閘道器的配置Oracle
- ORACLE 9i 建立透明閘道器訪問SQL Server 2008OracleSQLServer
- 【磐維資料庫】Oracle(透明閘道器)訪問磐維資料庫(PanWeiDB)資料庫Oracle
- oracle連線teradata透明閘道器配置Oracle
- transparent gateway 透明閘道器配置Gateway
- 安全閘道器 透明加解密解密
- oracle9i透明閘道器到sqlserver的配置OracleSQLServer
- ORACLE9i 的透明閘道器的配置 (轉)Oracle
- 透明閘道器 oracle 10g for sqlserver 和sybase的配置Oracle 10gSQLServer
- linux 作業系統下ORACLE資料庫使用透明閘道器連線MYSQLLinux作業系統Oracle資料庫MySql
- 配置Oracle Gateways透明閘道器連線多個MSSQL資料庫OracleGatewaySQL資料庫
- 通過Oracle Gateways 訪問SybaseOracleGateway
- 30分鐘通過Kong實現.NET閘道器
- ADSL+RH8.0透明閘道器指南(轉)
- 服務閘道器過濾器過濾器
- 時代億信檔案共享訪問控制閘道器概述
- 不設定預設閘道器,可訪問網路
- 透明閘道器一些特殊場景的配置
- 微服務6:通訊之閘道器微服務
- 透明閘道器的安裝配置及一般使用