如何在RHEL 6 / Linux上设置Oracle ODBC驱动程序

前端之家收集整理的这篇文章主要介绍了如何在RHEL 6 / Linux上设置Oracle ODBC驱动程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我需要在RHEL 6上设置Oracle ODBC驱动程序以连接到驻留在远程Windows机器上的Oracle数据源.

我采取了以下步骤:
[1]安装了oracle-instanceclient-basic
[2]设置环境变量:ORACLE_HOME和LD路径
[3]创建了/etc/oracle/TNSnames.ora并进行了配置,但没有正确设置

最初,我收到错误,“连接失败,因为目标或对象不存在”

然后,我在TNSnames.ora文件中设置:ORACLE_SID = DB_NAME.

但是,这没有解决问题,我现在收到一条新的错误消息:“TNS:错误地指定了网络服务名称

最佳答案
yum install unixODBC
rpm -ivh oracle-instantclient-basic-10.2.0.3-1.i386.rpm #downloaded on http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
unzip instantclient-odbc-linux32-10.2.0.3-20061115.zip #downloaded on http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
cp ./instantclient_10_2/libsqora.so.10.1 /usr/lib/oracle/10.2.0.3/client/lib/
export ORACLE_HOME=/usr/lib/oracle/10.2.0.3/client
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

此外,您需要设置$TWO_TASK(Oracle希望获取服务器的默认位置)以指向Oracle服务器在Windows上运行的位置 – 不要忘记在端口号后面添加侦听器:

export TWO_TASK=//213.123.23.19:1521/listener

获取侦听器的名称,请在运行Oracle服务器的Windows提示符下键入以下命令:

lsnrctl
status

它将获得监听器及其状态(READY或UNKNOWN).连接到处于就绪状态的侦听器:Instance“zelistener”,状态为READY

mkdir / etc / oracle

vi /etc/oracle/tnsnames.ora

MY_SID =
 ( DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS =
  (PROTOCOL = TCP)
  (Host = 127.0.0.1)
  (Port = 1521)
  )
 )
 (CONNECT_DATA = (SID = MY_SID)
 )
)

export TNS_ADMIN = / etc / oracle

vi /etc/odbcinst.ini

[OracleODBC-10g]
Description = Oracle ODBC driver for Oracle 10g
Driver = /usr/lib/oracle/10.2.0.3/client/lib/libsqora.so.10.1
FileUsage = 1
Driver Logging = 7

vi /etc/odbc.ini

[simple]
Driver = OracleODBC-10g
DSN = OracleODBC-10g
ServerName = MY_SID
UserID = USER
Password = PASSWORD

isql -v简单

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

猜你在找的Linux相关文章