Create dblink from oracle to memsql
- Install required RPM packages
- Configure ODBC gateway
- Setup environment variable
- Configure listener.ora and tnsnames.ora
- Configure ODBC listener
- Create database link and test2
Environment:
Database | DB Name | DB Version | Host Name | OS Version |
Oracle | PCRADMN | 11.2.0.4 | oracle-myvm | RHEL 6.7 |
memsql | gen_ap_s1 | 5.5.8 | memsql-myvm | N/A |
- Required package check
- [Dev root @ oracle-myvm ~] # rpm -qa | grep mysql
- mysql-community-client-5.7.9-1.el6.i686
- mysql-community-libs-5.7.9-1.el6.i686
- *mysql-connector-odbc-5.3.4-1.el6.i686
- mysql-community-common-5.7.9-1.el6.i686
- *mysql-connector-odbc-5.3.4-1.el6.x86_64
- [Dev root @ oracle-myvm ~] # rpm -qa | grep unixODBC
- unixODBC-devel-2.2.14-14.el6.x86_64
- unixODBC-2.2.14-14.el6.i686
- unixODBC-devel-2.2.14-14.el6.i686
- unixODBC-2.2.14-14.el6.x86_64
- Configure ODBC gateway and test connection
- [Dev root @ oracle-myvm ~] # vi /etc/odbc.ini
- [myodbc3]
- Driver = /usr/lib64/libmyodbc5w.so
- Description = MySQL ODBC 5.1 Driver DSN
- SERVER = memsql-myvm.dbversity.com
- PORT = 3383
- USER= gen_fad_etl_rw_s1
- Password= <clear-text password>
- Database= gen_ap_s1
- OPTION= 3
- SOCKET =
- charset = utf8
- [Dev root @ oracle-myvm ~] # vi /etc/odbcinst.ini
- =>
- [MySQL]
- Description = ODBC forMySQL
- Driver = /usr/lib/libmyodbc5w.so
- Setup = /usr/lib/libodbcmyS.so
- Driver64 = /usr/lib64/libmyodbc5w.so
- Setup64 = /usr/lib64/libodbcmyS.so
- FileUsage = 1
- [Dev root @ oracle-myvm ~] # isql myodbc3 -v
- +—————————————+
- | Connected! |
- | |
- | sql-statement |
- | help [tablename] |
- | quit |
- | |
- +—————————————+
- SQL> quit
- set environment variable as oracle
- export LD_LIBRARY_PATH=$ORACLE_HOME:lib:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/hs/lib:/usr/lib64
- export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
- export ODBCINI=/etc/odbc.ini
- export ODBCSYSINI=/etc
- export ODBCINSTINI=/etc/odbc.ini
- configure listener.ora and tnsnames.ora under $ORACLE_HOME/network/admin
- SID_LIST_LISTENER_PCRADMN =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = PCRADMN)
- (ORACLE_HOME = /optware/oracle/11.2.0.4/db_1)
- (SID_NAME = PCRADMN)
- )
- (SID_DESC =
- (PROGRAM = dg4odbc)
- (SID_NAME = myodbc3)
- (ORACLE_HOME = /optware/oracle/11.2.0.4/db_1)
- (ENVS=LD_LIBRARY_PATH=/optware/oracle/11.2.0.4/db_1/lib:/lib:/usr/lib:/usr/local/lib:/optware/oracle/11.2.0.4/db_1/hs/lib:/usr/lib64)
- )
- )
- LISTENER_PCRADMN =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-myvm.dbversity.com )(PORT = 7777))
- )
- )
- –restart LISTENER_PCRADMN
- myodbc3 =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-myvm.dbversity.com)(PORT = 7777))
- (CONNECT_DATA =
- (SID = myodbc3))
- (HS = OK)
- )
- bash-4.1$ tnsping myodbc3
- TNS Ping Utility forLinux: Version 11.2.0.4.0 – Production on27-OCT-2015 11:00:16
- Copyright (c) 1997, 2013, Oracle. Allrights reserved.
- Used TNSNAMES adapter toresolve the alias
- Attempting tocontact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-myvm.dbversity.com)(PORT = 7777)) (CONNECT_DATA = (SID = myodbc3)) (HS = OK))
- OK (20 msec)
- Configure ODBC listener
- bash-4.1$ cd $ORACLE_HOME/hs/admin
- bash-4.1$ vi initmyodbc3.ora
- =>
- HS_FDS_CONNECT_INFO = myodbc3
- HS_FDS_TRACE_FILE_NAME=odbc_test.log
- HS_FDS_TRACE_LEVEL=4
- HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
- HS_FDS_SUPPORT_STATISCTICS = FALSE
- HS_LANGUAGE = AMERICAN_AMERICA.WE8ISO8859P1
- setODBCINI = /etc/odbc.ini
- Test dblink
# dblink using tns entry
- SQL> createpublic database link myodbc connect to “gen_fad_etl_rw_s1” identified by “<password>” using ‘myodbc3’;
- Databaselink created.
- SQL> selectcount(1) from M_SUBGL_TRF_PRC@myodbc;
- COUNT(1)
- ———-
- 0
# dblink using connection string
- SQL> createdatabase link myodbc2 connect to “gen_fad_etl_rw_s1” identified by “<password>”
- using ‘(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-myvm.dbversity.com)(PORT = 7777)) (CONNECT_DATA = (SID = myodbc3)) (HS = OK))’;
- Databaselink created.
- SQL> selectcount(1) from dual@myodbc2;
- COUNT(1)
- ———-
- 1
- Known Issue
7.1 Error: ORA-28511: lost RPC connection to heterogeneous remote agent using SID=
- SQL> selectcount(1) from “M_SUBGL_TRF_PRC”@myodbc;
- selectcount(1) from “M_SUBGL_TRF_PRC”@myodbc
- *
- ERROR atline 1:
- ORA-28511: lost RPC connectionto heterogeneous remote agent usingSID=ORA-28511: lost RPC connection to heterogeneous remote agent using
- SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle-myvm.dbversity.com)(PORT=
- 7777))(CONNECT_DATA=(SID=myodbc3)))
- ORA-02063: preceding line fromMYODBC
- Process ID: 1848
- Session ID: 15 Serial number: 511
Solution: Remove HS_FDS_SQLLEN_INTERPRETATION=32 from $ORACLE_HOME/hs/admin/initmyodbc3.ora.