异构功能实现oracle查询mysql

网络整理 - 07-27

  我现在有两种数据库,一个为oracle 11g,版本为:11.1.0.6.0 - 64bit,安装在HP-IA64的服务器上,一个为mysql 5.1,安装在同一台服务器中。

  现在要实现oracle的数据库能够查询mysql数据库的表,想要通过oracle的异构功能来实现,但由于小弟对数据库了解不深,还请各位帮忙。

  以下为我的各个配置文件,不知道错误出在哪儿里了:

  1、由于oracle 11g没有了hsodbc,需要采用dg4odbc,dg4odbc运行正常:

  $ dg4odbc

  Oracle Corporation — TUESDAY NOV 17 2009 16:36:56.450

  Heterogeneous Agent Release 11.1.0.6.0 - 64bit Production Built with

  Oracle Database Gateway for ODBC

  2、odbc.ini文件:

  [localdp]

  Description = hsdp

  Driver = /app/lib/libmyodbc3_r-3.51.25.so

  Server = localhost

  Database = dp

  Port = 3306

  UID = root

  Password = 123456

  Socket =

  Option = 7340295

  Stmt =

  3、isql运行正常:

  $ isql -v localdp

  +—————————————+

  | Connected! |

  | |

  | sql-statement |

  | help [tablename] |

  | quit |

  | |

  +—————————————+

  SQL>

  4、init <>.ora文件:

  $ cat initdp.ora

  HS_FDS_CONNECT_INFO=localdp

  HS_FDS_TRACE_LEVEL= off

  HS_FDS_SHAREABLE_NAME=app/lib/libmyodbc3_r-3.51.25.so

  HS_LANGUAGE=american_america.zhs16cgb231280

  HS_OPEN_CURSORS=300

  set ODBCINI=/app/configinfo/odbc.ini

  set ORACLE_HOME=/app/oracle/app/oracle/product/11.1.0/db_2

  5、listener.ora中加入的内容:

  (SID_DESC =

  (SID_NAME = dp)

  (ORACLE_HOME = /app/oracle/app/oracle/product/11.1.0/db_2)

  (PROGRAM = dg4odbc)

  (ENVS="LD_LIBRARY_PATH=/app/oracle/app/oracle/product/11.1.0/db_2/lib:/app/unixodbc/lib")

  )

  6、tnsnames.ora文件中加入内容:

  hsd =

  (DESCRIPTION =

  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))

  (CONNECT_DATA =

  (SERVER = DEDICATED)

  (SERVICE_NAME = dp)

  )

  (HS = OK)

  )

  7、tnsping hsd

  $ tnsping hsd

  TNS Ping Utility for HPUX: Version 11.1.0.6.0 - Production on 17-NOV-2009 16:43:46

  Copyright (c) 1997, 2007, Oracle. All rights reserved.

  Used parameter files:

  /app/oracle/app/oracle/product/11.1.0/db_2/network/admin/sqlnet.ora

  Used TNSNAMES adapter to resolve the alias

  Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dp)) (HS = OK))

  OK (0 msec)

  8、创建DBLINK可以成功。

  create public database link hsdlink connect to "root" identified by "123456" using 'hsd';

  9、查询出错:

  SQL> select * from dp.dp_path@hsdlink;

  select * from dp.dp_path@hsdlink

  *

  ERROR at line 1:

  ORA-28500: connection from ORACLE to a non-Oracle system returned this message:

  ORA-02063: preceding line from HSDLINK

  现在找不到错误的原因,还请各位大侠帮忙。先行谢过!!!

  附加:oracle的环境变量:

  export ORACLE_BASE=/app/oracle/app/oracle

  export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_2

  export ORA_CRS_HOME=$ORACLE_HOME/crs

  export ORACLE_SID=ora11ghs

  export ORACLE_PATH=$ORACLE_BASE/common/oracle/sql:$ORACLE_HOME/rdbms/admin

  export PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin:/app/unixodbc/bin:$HOME/bin:.

  export TNS_ADMIN=$ORACLE_HOME/network/admin

  export ORA_NLS10=$ORACLE_HOME/nls/data

  export SHLIB_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:/app/lib:/app/unixodbc/lib

  export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/oracm/lib:/app/unixodbc/lib:/app/lib

  export CLASSPATH=$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/jlib:$ORACLE_HOME/network/jlib:$ORACLE_HOME/JRE

  export THREADS_FLAG=native

  export TEMP=/tmp

  export TMPDIR=/tmp

  export NLS_LANG=american_america.zhs16cgb231280

  export ODBCINI=/app/configinfo/odbc.ini这个问题,没有哪位高手遇到过吗?