[Oracle-> MySQL] Oracle通過dblink連線MySQL--Oracle 19c連線到MySQL 5.7
[Oracle-> MySQL] Oracle通過dblink連線MySQL--Oracle 19c pdb連線到MySQL 5.7
更多理論參考:
http://blog.itpub.net/26736162/viewspace-2144661/
版本資訊:
Oracle: 19.2.0.0.0 OS: CentOS 7.3
MySQL: 5.7.19 OS: CentOS 6.5
1)判斷32位還是64位
[oracle@raclhr-18c-n1 ~]$ file $ORACLE_HOME/bin/dg4odbc /u01/app/oracle/product/19.2.0/dbhome_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]=4675eeb874fe889b960a29d3d084f9c1f4c471d0, not stripped [oracle@raclhr-18c-n1 ~]$ ll
2)下載並安裝ODBC Driver Manager
下載地址: http://www.unixodbc.org/download.html
可以在我的雲盤或QQ群下載,或者點選檔案:
解壓並進行編譯安裝:
tar -zxvf unixODBC-2.3.7.tar.gz ./configure make && make install
3)下載並按照ODBC Driver for MySQL
下載地址 : http://dev.mysql.com/downloads/connector/odbc/5.2.html#downloads
可以在我的雲盤或QQ群下載,或者點選檔案:
mysql-connector-odbc-5.3.13-1.el7.x86_64.zip
進行安裝:
[root@raclhr-18c-n1 oracle]# rpm -ivh mysql-connector-odbc-5.3.13-1.el7.x86_64.rpm warning: mysql-connector-odbc-5.3.13-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-connector-odbc-5.3.13-1.el7################################# [100%] Success: Usage count is 1 Success: Usage count is 1
4)配置ODBC Driver
vi /home/oracle/etc/odbc.ini [myodbc5] Driver = /usr/lib64/libmyodbc5w.so Description = Connector/ODBC 5.2 Driver DSN SERVER = 192.168.59.159 PORT = 3306 USER = root PASSWORD = lhr DATABASE = LHRDB OPTION = 0 TRACE = OFF set ODBCINI=/home/oracle/etc/odbc.ini cat $ODBCINI
5)驗證ODBC連線
export ODBCINI=/home/oracle/etc/odbc.ini export LD_LIBRARY_PATH=/home/oracle/unixODBC-2.3.7/libltdl/:$LD_LIBRARY_PATH cd /home/oracle/unixODBC-2.3.7/exe/ ./isql myodbc5 -v +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> EXIT
mysql準備資料:
[root@LHRDB ~]# mysql -h192.168.59.159 -uroot -plhr mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 5.7.19 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | LHRDB | | db_name | | db_name2 | | lhrdb | | lhrdb2 | | mysql | | performance_schema | | sakila | | sys | | test | +--------------------+ 11 rows in set (0.00 sec) mysql> use LHRDB; Database changed mysql> show tables; Empty set (0.00 sec) mysql> create table lhrtest(id int); Query OK, 0 rows affected (0.09 sec) mysql> insert into lhrtest values(1); Query OK, 1 row affected (0.00 sec) mysql> select count(1) from lhrtest; +----------+ | count(1) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec)
6)配置tnsnames.ora
myodbc5 = (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=192.168.59.52) (PORT=1521) ) (CONNECT_DATA= (SID=myodbc5) ) (HS=OK) )
7)配置listener.ora
SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (SID_NAME=myodbc5) (ORACLE_HOME=/u01/app/oracle/product/19.2.0/dbhome_1) (PROGRAM=dg4odbc) (ENVS=LD_LIBRARY_PATH=/home/oracle/unixODBC-2.3.7/libltdl:/u01/app/oracle/product/19.2.0/dbhome_1/lib) ) )
8)建立
init.ora檔案
建立檔案$ORACLE_HOME/hs/admin/initmyodbc5.ora,內容如下:
vi $ORACLE_HOME/hs/admin/initmyodbc5.ora HS_FDS_CONNECT_INFO=myodbc5 HS_FDS_SHAREABLE_NAME=/home/oracle/unixODBC-2.3.7/DriverManager/.libs/libodbc.so HS_FDS_SUPPORT_STATISTICS=FALSE HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P15
9)使上述配置檔案生效, 驗證配置是否正確
set ODBCINI=/home/oracle/etc/odbc.ini lsnrctl reload lsnrctl status tnsping myodbc5
[oracle@raclhr-18c-n1 unixODBC-2.3.7]$ 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/etc/odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8
10)建立dblink並驗證
create public database link mysqltest connect to "root" identified by "lhr" using 'myodbc5' ; select count(*) from lhrtest@mysqltest;
[oracle@raclhr-18c-n1 admin]$ sas SQL*Plus: Release 19.0.0.0.0 - Production on Sat May 11 22:13:20 2019 Version 19.2.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.2.0.0.0 SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 LHRPDB2 READ WRITE NO SQL> alter session set container=lhrpdb2; Session altered. SQL> select count(*) from "lhrtest"@mysqltest; COUNT(*) ---------- 1 SQL> select * from "lhrtest"@mysqltest; id ---------- 1 SQL> insert into "lhrtest"@mysqltest values(2) ; 1 row created. SQL> commit; Commit complete.
mysql中查詢:
mysql> select * from LHRDB.lhrtest; +------+ | id | +------+ | 1 | | 2 | +------+ 2 rows in set (0.00 sec)
About Me
........................................................................................................................ ● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除 ● 本文在itpub( http://blog.itpub.net/26736162 )、部落格園( http://www.cnblogs.com/lhrbest )和個人weixin公眾號( xiaomaimiaolhr )上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文部落格園地址: http://www.cnblogs.com/lhrbest ● 本文pdf版、個人簡介及小麥苗雲盤地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA寶典今日頭條號地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群號: 230161599 (滿) 、618766405 ● weixin群:可加我weixin,我拉大家進群,非誠勿擾 ● 聯絡我請加QQ好友 ( 646634621 ) ,註明新增緣由 ● 於 2019-05-01 06:00 ~ 2019-05-30 24:00 在魔都完成 ● 最新修改時間:2019-05-01 06:00 ~ 2019-05-30 24:00 ● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解 ● 版權所有,歡迎分享本文,轉載請保留出處 ........................................................................................................................ ● 小麥苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麥苗出版的資料庫類叢書 : http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麥苗OCP、OCM、高可用網路班 : http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麥苗騰訊課堂主頁 : https://lhr.ke.qq.com/ ........................................................................................................................ 使用 weixin客戶端 掃描下面的二維碼來關注小麥苗的weixin公眾號( xiaomaimiaolhr )及QQ群(DBA寶典)、新增小麥苗weixin, 學習最實用的資料庫技術。
........................................................................................................................ |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2644037/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 配置Oracle DBlink連線MySQL庫OracleMySql
- MySQL 5.7配置SSL連線MySql
- 通過跳板機連線MySQLMySql
- mysql5.7 ssl加密連線MySql加密
- Datax離線資料抽取(MySQL--Oracle)MySqlOracle
- 通過驅動建立與MySQL的連線MySql
- ORACLE通過透明閘道器建dblink連線Postgresql的幾個問題OracleSQL
- Oracle19c dblink連結mysql8.0OracleMySql
- Oracle DBLink連線數過多的問題(Ora-02020)Oracle
- Python 連線 MySQLPythonMySql
- python連線MySQLPythonMySql
- IDEA連線MySQLIdeaMySql
- GO 連線 MySQLGoMySql
- C連線MySQLMySql
- JDBC連線mysqlJDBCMySql
- MYSQL語法:左連線、右連線、內連線、全外連線MySql
- Sqlcl 連線Oracle DataBase 19cSQLOracleDatabase
- MySQL筆記3——內連線/外連線、多表連線MySql筆記
- MYSQL 連線登入過程分析MySql
- Oracle 19c透過SCAN連線ORA-12520Oracle
- Oracle 19c中連線RMAN客戶端的連線方法Oracle客戶端
- Java的JDBC通過SSH Tunnel連線MySQL資料庫JavaJDBCMySql資料庫
- CodeSmith 一、連線MysqlMITMySql
- JPA配置mysql連線MySql
- kettle連線本地MYSQLMySql
- Java JDBC連線MYsqlJavaJDBCMySql
- 使用pyMySql 連線mysqlMySql
- MySQL連線數管理MySql
- 06 建立MySQL連線MySql
- mysql INNER JOIN、LEFT JOIN、RIGHT JOIN;內連線(等值連線)、左連線、右連線MySql
- mysql階段04 連線工具, 連線方式, 啟動關閉mysqlMySql
- python 怎麼連線 sql server,不是連線 mysqlPythonServerMySql
- 連線mysql時提示is not allowed to connect不允許連線MySql
- CentOS 7 系統安裝與遠端連線 MySQL 5.7CentOSMySql
- 如何本機通過 SSH 通道連線雲伺服器 MySQL伺服器MySql
- mac開啟mysql,navicat連線mysqlMacMySql
- 【LISTENER】Oracle通過監聽連線緩慢分析Oracle
- MySQL伺服器連線過程淺析MySql伺服器