如何在 RHEL 6/Linux 上设置 Oracle ODBC 驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13922415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I setup Oracle ODBC drivers on RHEL 6/Linux
提问by Kapil Vyas
I need to setup Oracle ODBC drivers on RHEL 6 to connect to an Oracle data source residing on a remote Windows machine.
我需要在 RHEL 6 上设置 Oracle ODBC 驱动程序以连接到驻留在远程 Windows 机器上的 Oracle 数据源。
I have taken the following steps:
[1] Installed oracle-instanceclient-basic
[2] Set environment variables: ORACLE_HOME and LD path
[3] Created /etc/oracle/TNSnames.ora and configured but it did not set it correctly
我采取了以下步骤:
[1] 安装 oracle-instanceclient-basic
[2] 设置环境变量:ORACLE_HOME 和 LD 路径
[3] 创建 /etc/oracle/TNSnames.ora 并配置但没有正确设置
Initially, I got the error, "Connect failed because target or object does not exist"
最初,我得到了错误, "Connect failed because target or object does not exist"
Then, I set: ORACLE_SID = DB_NAME
in the TNSnames.ora file.
然后,我ORACLE_SID = DB_NAME
在 TNSnames.ora 文件中设置:。
But, that did not fix the issue, I got a new error message now: "TNS: net service name is incorrectly specified"
但是,这并没有解决问题,我现在收到一条新的错误消息: "TNS: net service name is incorrectly specified"
采纳答案by Kapil Vyas
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
Also you need to set $TWO_TASK
(default location where Oracle is looking to pickup the server) to point to where the Oracle server is running on Windows - - don't forget to add the listener at the end after the port number:
此外,您还需要设置$TWO_TASK
(Oracle 希望提取服务器的默认位置)指向 Oracle 服务器在 Windows 上运行的位置 - 不要忘记在端口号后面添加侦听器:
export TWO_TASK=//213.123.23.19:1521/listener
To chech for the name of listener, type the following commands on the windows prompt that is running the Oracle server:
要检查侦听器的名称,请在运行 Oracle 服务器的 Windows 提示符下键入以下命令:
lsnrctl
status
It will enlist listeners and their state (READY or UNKNOWN). Connect to the listener that is in the ready state: Instance "zelistener", status READY
它将招募听众及其状态(READY 或 UNKNOWN)。连接到处于就绪状态的侦听器:Instance "zelistener", status READY
mkdir /etc/oracle
mkdir /etc/oracle
vi /etc/oracle/tnsnames.ora
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
导出 TNS_ADMIN=/etc/oracle
vi /etc/odbcinst.ini
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
vi /etc/odbc.ini
[simple]
Driver = OracleODBC-10g
DSN = OracleODBC-10g
ServerName = MY_SID
UserID = USER
Password = PASSWORD
isql -v simple
isql -v 简单
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
回答by bear_wang
I think that we should assign the version of unixODBC. if to connect the oracle12c, we should use the unixODBC-2.3.1
我认为我们应该分配unixODBC的版本。如果要连接oracle12c,应该使用unixODBC-2.3.1