Oracle 透明閘道器連線MySQL

壹頁書發表於2014-03-04
Oracle透明閘道器連線MySQL
聯結器下載:

1.配置unixODBC          
/etc/odbc.ini
[mysql]
Driver    =/usr/lib/libmyodbc5w.so
Server    =192.168.1.50
User    =mysql
Password=mysql
Port    =3306
database=edmond
Charset    =GBK

使用isql測試

 
2.配置HS
編輯$ORACLE_HOME/hs/admin/initmysql.ora
其中mysql是sid

HS_FDS_CONNECT_INFO = mysql
HS_FDS_TRACE_LEVEL = debug
HS_FDS_SHAREABLE_NAME = libodbc.so
HS_LANGUAGE=AMERICAN_AMERICA.ZHS16GBK
set ODBCINI=/etc/odbc.ini

語言這行不能缺少,否則報錯。

3.配置tns
mysql =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.50)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = mysql)
    )
    (HS = OK)
  )


4.配置監聽器
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = mysql)
      (ORACLE_HOME = /home/lihuilin/dev/app/lihuilin/product/11.2.0/dbhome_1)
      (SID_NAME = mysql)
      (PROGRAM    = dg4odbc)
      (ENVS="LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib")
    )
  )

LISTENER =
  (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (ADDRESS = (PROTOCOL = TCP)(HOST = lihuilin.home)(PORT = 1521))
  )

ADR_BASE_LISTENER = /home/lihuilin/dev/app/lihuilin

5.建立db link


在MySQL建立測試表
create table t(a varchar(20) primary key) engine=innodb,charset =gbk;
insert into t values('透明');
commit;

檢視結果:


如果前臺報錯如下所示
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[


$ORACLE_HOME/hs/log的後臺日誌報錯如下:
hgopoer, line 233: got native error 0 and sqlstate I; message follows...
[
Exiting hgopoer, rc=0 at 2014/03/04-21:40:18
hgocont, line 2752: calling SqlDriverConnect got sqlstate I
Exiting hgocont, rc=28500 at 2014/03/04-21:40:18 with error ptr FILE:hgocont.c LINE:2772 FUNCTION:hgocont() ID:Something other than invalid authorization
Exiting hgolgon, rc=28500 at 2014/03/04-21:40:18 with error ptr FILE:hgolgon.c LINE:781 FUNCTION:hgolgon() ID:Calling hgocont
Entered hgoexit at 2014/03/04-21:40:18

有兩個可能
1.HS_LANGUAGE沒有配置
2.HS_LANGUAGE和MySQL的字符集不匹配

參考:
http://blog.itpub.net/21601207/viewspace-709366






來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1101147/,如需轉載,請註明出處,否則將追究法律責任。

相關文章