在Linux Oracle訪問MySQL的Client端軟件介紹
Linux Oracle已被廣泛應(yīng)用但是也在不斷的更新,這里介紹Linux Oracle裝設(shè)置使用,幫助大家安裝更新Linux Oracle系統(tǒng)前一陣在公司通過Linux Oracle訪問MySQL,測(cè)試環(huán)境:CentOS5_X64, Oracle10g_X64, MySQL5 。把一些經(jīng)驗(yàn)分享給大家!
1, 首先在Linux Oracle所在計(jì)算機(jī)安裝MySQL的Client端軟件,并且x86_64和i386版本的都需要安裝,以便可以連接MySQL數(shù)據(jù)庫(kù)。查看Client安裝情況:
rpm -qa |grep mysql
mysql-5.0.45-7.el5
mysql-5.0.45-7.el5
得到兩條記錄,一條是x86_64的,一條是i386的。
如果看到還沒有安裝mysql客戶端軟件,則需要安裝:
yum install mysql
yum install mysql.i386
驗(yàn)證在此Linux Oracle所在計(jì)算機(jī)是可以連接目標(biāo)主機(jī)MySQL數(shù)據(jù)庫(kù):
mysql -h 192.168.1.1 -u root -p mysql
2, 檢查L(zhǎng)inux Oracle所在計(jì)算機(jī)是否已安裝MySQL ODBC客戶端,并且x86_64和i386版本的都需要安裝。 rpm -qa |grep mysql-connect 如果沒有安裝mysql-connector-odbc,則用下面命令下載和安裝:下載 mysql-connector-odbc:wget ftp://mirror.switch.ch/pool/3/mirror/centos/5.2/os/i386/CentO S/mysql-connector-odbc-3.51.12-2.2.i386.rpm 安裝mysql-connector-odbc: rpm -ivh mysql-connector-odbc-3.51.12-2.2.i386.rpm 得到提示 libltdl.so.3 is needed by mysql-connector-odbc-3.51.12-2.2.i386 ,發(fā)現(xiàn)需要安裝libtool的i386版本,因此通過如下命令安裝libtool-ltdl.i386:
yum list *.i386|grep libtool
yum install libtool-ltdl.i386
3, 在Linux Oracle所在計(jì)算機(jī)編輯/etc/odbc.ini文件,測(cè)試ODBC工作vi /etc/odbc.ini #odbc.ini內(nèi)容如下
[test] Driver=/usr/lib64/libmyodbc3.so Deion=MySQL Server=192.168.1.1(MySQL Server IP) Port=3306 User= (MySQL Username) UID= (MySQL Username) Password= (MySQL PWD) Database= (MySQL Database Name) Option=3 Socket= 在命令行中執(zhí)行下列命令,應(yīng)能夠順利登入MySQL Client窗口,即證明ODBC功能正常: isql -v testquit
4, 編輯hs配置文件 vi /ora10g/hs/admin/inittest.ora(注意文件名中藍(lán)色部分為odbc.ini中藍(lán)色名稱)
HS_FDS_CONNECT_INFO = test HS_FDS_TRACE_LEVEL = on(正式使用后,不需要排錯(cuò)的時(shí)候應(yīng)設(shè)為off) HS_FDS_TRACE_FILE_NAME = test.trc HS_FDS_SHAREABLE_NAME=/usr/lib/libmyodbc3.so set ODBCINI=/etc/odbc.ini 5, 編輯Linux Oracle所在計(jì)算機(jī)的Oracle listener的配置文件,建立一個(gè)模擬Oracle Listener的監(jiān)聽方式,為將來建立dblink做準(zhǔn)備: vi /ora10g/network/admin/listener.ora 加入如下語句:
(SID_DESC = (SID_NAME = test) (ORACLE_HOME = /ora10g) (PROGRAM = hsodbc) (ENVS=LD_LIBRARY_PATH=/ora10g/lib32:/usr/lib64:/ora10g/lib) listener.ora文件現(xiàn)在的內(nèi)容變成:
SID_LIST_LISTENER = ( SID_LIST = (SID_DESC = (ORACLE_HOME = /ora10g) (PROGRAM = extproc) (GLOBAL_DBNAME=prod) (SID_NAME=prod) (SID_DESC = (SID_NAME = test) (ORACLE_HOME = /ora10g) (PROGRAM = hsodbc) (ENVS=LD_LIBRARY_PATH=/ora10g/lib32:/usr/lib64:/ora10g/lib) LISTENER = (DEION_LIST = (DEION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1) (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521) 執(zhí)行l(wèi)snrctl reload使Listener生效:
su – oracle lsnrctl reload LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 09-FEB-2009 13:59:38 Copyright (c) 1991, 2007, Oracle. All rights reserved. Connecting to (DEION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) The command completed successfully lsnrctl status LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 12-FEB-2009 08:56:00 Copyright (c) 1991, 2007, Oracle.All rights reserved. Connecting to (DEION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1))) STATUS of the LISTENER AliasLISTENER Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production Start Date 03-JAN-2009 03:47:39 Uptime40 days 5 hr. 8 min. 20 sec Trace Leveloff SecurityON: Local OS Authentication SNMP OFF Listener Parameter File/ora10g/network/admin/listener.ora Listener Log File/ora10g/network/log/listener.log Listening Endpoints Summary... (DEION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1))) (DEION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) Services Summary... Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service... Service "test" has 1 instance(s). Instance "test", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully 6, 編輯Linux Oracle所在計(jì)算機(jī)中的tnsnames.ora文件,便于建立dblink。注意,此tnsnames的配置可以支持tnsping,但是不能支持sqlplus登錄,只用于dblink:vi /ora10g/network/admin/tnsnames.ora
test = (DEION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SID = test) (HS = OK) 7, 在Oracle Database建立dblink:
create public database link MYSQL connect to "mysql username" identified by "mysql pwd" using '(DEION = (ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT =1521) ) (CONNECT_DATA = (SID= test) ) (HS=OK) 要注意用戶名和密碼處需要用雙引號(hào),否則Linux Oracle所傳輸?shù)亩际谴髮懽帜福赡軣o法登錄進(jìn)入MySQL。
8, 由于MySQL中的表名的大小寫敏感,因此需要在進(jìn)行SQL查詢時(shí)對(duì)表名用雙引號(hào)擴(kuò)起來
select * from "tablename"@test
關(guān)鍵字:Linux Oracle、訪問、MySQL
新文章:
- CentOS7下圖形配置網(wǎng)絡(luò)的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗(yàn)證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機(jī)IP講解
- CentOS7使用hostapd實(shí)現(xiàn)無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡(luò)重啟出錯(cuò)
- 解決Centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認(rèn)iptable規(guī)則詳解