|
Methods Windows platform Oracle MySQL connection has given you before, and now most of the Oracle and MySQL are Linux platform above, just recently this demand, shoving the whole process of recording up to build and share.
MySQL via ODBC connection schematics
Driver Manager: Communications, the main function responsible for managing applications and drivers between include: parsing DSN (data source name, ODBC data source name in the ODBC.INI configuration file), loading and unloading drivers, ODBC call processing, will it passed to the driver.
Connector / ODBC (MyODBC driver): Implementing the functionality provided by ODBC API, which is responsible for handling ODBC function calls, SQL requests will be submitted to the MySQL server, and returns the results to the application.
ODBC.INI is ODBC configuration file, driver record information and database information needed to connect to the server. Driver Manager will use it to determine which driver to load (using the data source name DSN). The driver will be read according to the specified DSN connection parameters.
Under Linux mysql ODBC configuration requires the following steps:
a) Install Driver Manager, as in this case using unixODBC Driver Manager
b) Install the MySQL driver, in this case using the Connector / ODBC
c) Configure ODBC.INI
Operating System: CentOS release 6.5 (Final)
Target database: ORACLE 11.2.0.3
Source database: mysql5.23
First, ODBC configuration
1.1, install unixODBC, the above script in the target database: yum install unixODBC
1.2, install mysql-connector-odbc, download link: http: //pan.baidu.com/s/1bnuiWCR Password: rf98
After extracting modify the file name in the / usr / local /
[Root @ test local] # pwd
/ Usr / local
[Root @ OTO-DBR-T02 local] # ll
total 56
drwxr-xr-x. 5 root root 4096 Oct 22 11:15 mysql-connector-odbc
1.3 odbc.ini configuration file
[Myodbc] # need to remember the name
Driver = /usr/local/mysql-connector-odbc/lib/libmyodbc5.so
Description = Connector / ODBC 5.1 Driver DSN
SERVER = 192.168.199.244
PORT = 3306
USER = root
PASSWORD = root
DATABASE = test
OPTION = 0
TRACE = OFF
1.4 Test Connection
[Root @ test local] # isql myodbc -v
+ --------------------------------------- +
| Connected! |
| |
| Sql-statement |
| Help [tablename] |
| Quit |
| |
+ --------------------------------------- +
SQL>
Congratulations, the pop-up window instructions may be connected to the mysql.
Second, the monitor configuration
2.1 into the ORACLE_HOME / hs / admin
[Oracle @ test admin] $ vi initmyodbc.ora
# This is a sample agent init file that contains the HS parameters that are
# Needed for the Database Gateway for ODBC
#
# HS init parameters
#
HS_FDS_CONNECT_INFO = myodbc
HS_FDS_TRACE_LEVEL = ON
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
#
# ODBC specific environment variables
#
set ODBCINI = /etc/odbc.ini
#
# Environment variables required for the non-Oracle system
#set =
2.2 listener.ora configuration file
Enter $ ORACLE_HOME / network / admin
[Oracle @ test admin] $ vi listener.ora
# Listener.ora Network Configuration File: /oracle/oracle11/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = test) (PORT = 1521))
)
)
ADR_BASE_LISTENER = / oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = / oracle / oracle11) #ORACLE_HOME
(PRESPAWN_MAX = 20)
)
(SID_DESC =
(SID_NAME = myodbc) # corresponding to the above file name
(ORACLE_HOME = / oracle / oracle11) #ORACLE_HOME
(PROGRAM = dg4odbc) # 11g is dg4odbc, 10g is not the same
)
)
~
After the restart the listener look myodbc service has been launched
[Oracle @ test oracle11] $ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-OCT-2015 15:22:12
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = test) (PORT = 1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 22-OCT-2015 15:08:57
Uptime 0 days 0 hr. 13 min. 15 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/oracle11/network/admin/listener.ora
Listener Log File /oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening Endpoints Summary ...
(DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = test) (PORT = 1521)))
Services Summary ...
Service "CLRExtProc" has 1 instance (s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler (s) for this service ...
Service "myodbc" has 1 instance (s).
Instance "myodbc", status UNKNOWN, has 1 handler (s) for this service ...
The command completed successfully
2.3 configuration file tnsnames.ora
myodbc =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = myodbc) # monitor corresponds with the above
)
(HS = OK)
)
2.4 Create dblink
create database link myodbc connect to "root" identified by "root" using 'myodbc';
2.5 Check the dblink
SQL> select * from dual @ myodbc;
D
-
X
Description has been completed in connection MySQL configuration ORACLE linux platform;
Another: After configuring the database itself might step 2.2 listening service disappeared, this time can be performed to allow the system to re-register
alter system set local_listener = '(address = (protocol = tcp) (port = 1521) (host = hostname))' scope = both; |
|
|
|