Oracle连接Mysql透明网关配置
[数据库名]
Driver = /usr/lib64/libmyodbc5.so
Server =IP地址
Port = 端口号
database =数据库名
OPTION=3
User = user_name
Password = passwd
trace=0
注意:Driver:填写mysql connector驱动的路径;
SERVER、PORT、DATABASE分别写mysql数据库的IP,端口和数据库名;
执行命令:# isql [ODBC配置的数据库名],并执行query可以验证是否配置成功。可同时配置多个数据库。内容详情如下图:
HS_FDS_CONNECT_INFO = 数据库名
HS_FDS_TRACE_LEVEL = off
HS_FDS_SHAREABLE_NAME = /usr/lib64/libmyodbc5.so
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1
HS_FDS_SQLLEN_INTERPRETATION=32
set ODBCINI=/etc/odbc.ini
set LD_LIBRARY_PATH=/usr/lib64/
注意:HS_FDS_CONNECT_INFO填写上一步配置的ODBC数据源,必须指定HS_LANGUAGE参数的值,不然面步骤会出错。
文件截图如下:
数据库实例名 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 主机域名或IP)(PORT = 1552))
)
)
SID_LIST_[数据库实例名] =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME =/data/erpsit/db/tech_st/11.2.0)
(SID_NAME =数据库实例名)
(PROGRAM =dg4odbc)
)
)
如图:
数据库实例名=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=域名或IP)(PORT=1552))
(CONNECT_DATA=
(SID=数据库实例名)
)
(HS=OK)
)
如图:
sh addlnctl.sh start 数据库实例名
脚本路径:/data/erpsit/db/tech_st/11.2.0/appsutil/scripts/erpsit_hrdb2
CREATE PUBLIC DATABASE LINK TEST_DB_LINK CONNECT TO user_name IDENTIFIED BY passwd " USING
tnsname;
select * from “数据库表”@TEST_DB_LINK;
测试dblink,出现ORA-28546错误,如图:
解决方法:修改tnsname.ora
由
数据库实例名=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=主机域名或IP)(PORT=1552))
(CONNECT_DATA=
(SID=数据库实例名)
(HS=OK)
)
)
改为
数据库实例名=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=主机域名或IP)(PORT=1552))
(CONNECT_DATA=
(SID=数据库实例名)
)
(HS=OK)
)
提示ORA-28511的错误,详情如图:
解决办法:修改用户密码,并重新创建DBLINK。
解决办法,通过转码
select "id",CONVERT("category", 'WE8ISO8859P1', 'UTF8' )"category","f_id","type","status","sort","level","pid" fromtable_name@TEST_DB_LINK
如下图:转码前后对比
研发八部
李勇