Linux Oracle accesses MySQL Client software

Source: Internet
Author: User

Linux Oracle has been widely used but is constantly updated. Here we will introduce how to install and use Linux Oracle to help you access MySQL through Linux Oracle some time before installing and updating the Linux Oracle System, test environment: CentOS5_X64, Oracle10g_X64, and MySQL5. Share some experiences with you!

1. First, install MySQL Client software on the computer where Linux Oracle is located, and install x86_64 and i386 versions to connect to the MySQL database. Check the Client installation status:
Rpm-qa | grep mysql
Mysql-5.0.45-7.el5
Mysql-5.0.45-7.el5
Two records, x86_64 and i386, are obtained.

If you see that the mysql client software has not been installed, you need to install:
Yum install mysql
Yum install mysql. i386
Verify that the computer on which the Linux Oracle is located can connect to the MySQL database of the target host:
Mysql-h 192.168.1.1-u root-p mysql

2. Check whether the MySQL ODBC client is installed on the Linux Oracle computer, and install the x86_64 and i386 versions. Rpm-qa | grep mysql-connect if mysql-connector-odbc is not installed, run the following command to download and install 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 install mysql-connector-odbc: rpm-ivh mysql-connector-odbc-3.51.12-2.2.i386.rpm to get the prompt libltdl. so.3 is needed by mysql-connector-odbc-3.51.12-2.2.i386 and found that libtool's i386 version needs to be installed, so install the libtool-ltdl.i386 through the following command:
Yum list *. i386 | grep libtool
Yum install libtool-ltdl.i386

3. Edit the/etc/odbc. ini file on the computer where Oracle is located in Linux, and test ODBC operations vi/etc/odbc. ini # odbc. ini. The content is as follows:

 
 
  1. [test]   
  2. Driver=/usr/lib64/libmyodbc3.so   
  3. Description=MySQL   
  4. Server=192.168.1.1(MySQL Server IP)   
  5. Port=3306   
  6. User= (MySQL Username)  
  7. UID= (MySQL Username)  
  8. Password= (MySQL PWD)  
  9. Database= (MySQL Database Name)  
  10. Option=3   
  11. Socket=  

If you run the following commands on the command line, you must be able to successfully log on to the MySQL Client window, proving that ODBC functions properly: isql-v testquit

4. Edit the hs configuration file vi/ora10g/hs/admin/inittest. ora. (Note that the blue part of the file name is the blue one in odbc. ini)

 
 
  1. HS_FDS_CONNECT_INFO=Test 
  2. HS_FDS_TRACE_LEVEL=OnAfter formal use, set it to off when troubleshooting is not required)
  3. HS_FDS_TRACE_FILE_NAME=Test. Trc
  4. HS_FDS_SHAREABLE_NAME=/Usr/lib/libmydbc3.so
  5. SetODBCINI=/Etc/odbc. ini

5. Edit the configuration file of the Oracle listener on the computer where the Linux Oracle is located, create a listening method to simulate the Oracle Listener, and prepare for dblink creation in the future: vi/ora10g/network/admin/listener. add the following statement to ora:

 
 
  1. (SID_DESC =  
  2. (SID_NAME = test)   
  3. (ORACLE_HOME = /ora10g)   
  4. (PROGRAM = hsodbc)   
  5. (ENVS=LD_LIBRARY_PATH=/ora10g/lib32:/usr/lib64:/ora10g/lib)  

The current content of the listener. ora file is changed:

 
 
  1. SID_LIST_LISTENER = (  
  2. SID_LIST =   
  3. (SID_DESC =   
  4. (ORACLE_HOME = /ora10g)   
  5. (PROGRAM = extproc)   
  6. (GLOBAL_DBNAME=prod)   
  7. (SID_NAME=prod)   
  8. (SID_DESC =   
  9. (SID_NAME = test)   
  10. (ORACLE_HOME = /ora10g)   
  11. (PROGRAM = hsodbc)   
  12. (ENVS=LD_LIBRARY_PATH=/ora10g/lib32:/usr/lib64:/ora10g/lib)   
  13. LISTENER =   
  14. (DESCRIPTION_LIST =   
  15. (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)  
  16. (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521) 

Execute lsnrctl reload to make Listener take effect:

 
 
  1. su – oracle   
  2. lsnrctl reload   
  3. LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 09-FEB-2009 13:59:38 Copyright (c) 1991, 2007, Oracle.   
  4. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))   
  5. The command completed successfully   
  6. lsnrctl status   
  7. LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 12-FEB-2009 08:56:00  
  8. Copyright (c) 1991, 2007, Oracle.All rights reserved.  
  9. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))  
  10. STATUS of the LISTENER  
  11. AliasLISTENER  
  12. Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production  
  13. Start Date 03-JAN-2009 03:47:39  
  14. Uptime40 days 5 hr. 8 min. 20 sec  
  15. Trace Leveloff  
  16. SecurityON: Local OS Authentication  
  17. SNMP OFF  
  18. Listener Parameter File/ora10g/network/admin/listener.ora  
  19. Listener Log File/ora10g/network/log/listener.log  
  20. Listening Endpoints Summary...  
  21. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))  
  22. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))  
  23. Services Summary...  
  24. Service "PLSExtProc" has 1 instance(s).  
  25. Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...  
  26. Service "test" has 1 instance(s).  
  27. Instance "test", status UNKNOWN, has 1 handler(s) for this service...  
  28. The command completed successfully 

6. Edit the tnsnames. ora file on the computer where Linux Oracle is located to create a dblink. Note: This tnsnames configuration supports tnsping, but does not support sqlplus logon. It is only used for dblink: vi/ora10g/network/admin/tnsnames. ora

 
 
  1. test =  
  2. (DESCRIPTION =  
  3.  (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))  
  4.  (CONNECT_DATA =  
  5. (SID = test)  
  6.  (HS = OK) 

7. Create a dblink in Oracle Database:

 
 
  1. create public database link MYSQL   
  2. connect to "mysql username" identified by "mysql pwd"   
  3. using '(DESCRIPTION =   
  4. (ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT =1521) )   
  5. (CONNECT_DATA = (SID= test) )   
  6. (HS=OK) 

Note that double quotation marks are required for the user name and password. Otherwise, all characters transmitted in Linux Oracle are uppercase letters, and you may not be able to log on to MySQL.

8. Because the table name in MySQL is case-sensitive, double quotation marks must be used to expand the table name during SQL queries.
Select * from "tablename" @ test

  1. Linux Oracle 10 Gb software installation database
  2. Linux Oracle can be installed on WMware virtual machines
  3. Linux mount Command System mounting and image processing
  4. Linux vmstat process information and memory information
  5. Linux PHP compilation and generation extension and Configuration Modification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.