1.环境
[root@blliu etc]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[root@blliu etc]# uname -a
Linux blliu 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
2.下载
2.1 unixODBC
下载地址:
http://www.unixodbc.org/
下载文件:
unixODBC-2.3.0.tar.gz
2.2 Oracle ODBC Driver
下载地址:
http://www.oracle.com/technology/global/cn/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html
下载文件:
basic-10.2.0.4.0-linux-x86_64.zip
odbc-10.2.0.4.0-linux-x86_64.zip
其他平台到下面地址下载:
http://www.oracle.com/technology/global/cn/software/tech/oci/instantclient/index.html
将所有文件上传至服务器的/opt/odbc/目录下。
3.安装unixODBC(root用户)
#cd /opt/odbc/
#tar xvf unixODBC-2.3.0.tar.gz
#cd /opt/odbc/unixODBC-2.3.0
#./configure
#make
#make install
(默认是被安装到/usr/local)
4.安装Oracle ODBC(root用户)
#cd /opt/odbc/
#unzip basic-10.2.0.4.0-linux-x86_64.zip
#unzip odbc-10.2.0.4.0-linux-x86_64.zip
(两个文件解压到同一个目录instantclient_10_2下)
#cd /opt/odbc/instantclient_10_2
#chmod 775 odbc_update_ini.sh
#./odbc_update_ini.sh /usr/local
(没有提示表示安装成功)
odbc_update_ini.sh参数说明:
参数1:unixODBC DM安装路径。
参数2:驱动安装的绝对路径(可选)。默认为运行脚本的路径。
参数3:驱动名(可选),默认为Oracle 10g ODBC driver。
参数4:数据源名称(可选),默认为OracleODBC-10g。
运行完成后将添加一个DNS条目到$HOME/.odbc.ini , /etc/odbcinst.ini,名称为:OracleODBC-10g
修改odbc目录的权限:
chown –R 775 /opt/odbc
5.配置本地服务名:
添加本地服务名。
$TNS_ADMIN/tnsnames.ora
或
$ORACLE_HOME/network/admin/tnsnames.ora
例如:
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)
如果是非Oracle用户,可以通过设置环境变量TNS_ADMIN来制定tnsnames.ora所在位置,当该改用户有对tnsnames.ora读的权限。
6.检查驱动配置
/usr/local/etc/odbcinst.ini
[Oracle 10g ODBC driver]
Description = Oracle ODBC driver for Oracle 10g
Driver = /opt/odbc/instantclient_10_2/libsqora.so.10.1
Setup =
FileUsage =
CPTimeout =
CPReuse =
7.添加oracle odbc配置(oracle用户):
vi ~/.odbc.ini
[OracleODBC-10g]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
BindAsFLOAT = F
CloseCursor = F
DisableDPM = F
DisableMTS = T
Driver = Oracle 10g ODBC driver #对应/usr/local/etc/odbcinst.ini中的驱动配置名称
DSN = OracleODBC-10g
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName =test #对应tnsnames.ora中配置的本地服务名
SQLGetData extensions = F
Translation DLL =
Translation ption = 0
DisableRULEHint = T
UserID =
8.设置环境变量(oracle用户):
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: /opt/odbc/instantclient_10_2:/usr/local/lib
PATH=$PATH:/usr/local/bin
TNS_ADMIN(如果安装有oracle软件那么对应的就是$ORACLE_HOME/network/admin/目录,如果没有安装相应oracle软件,需要指定tnsnames.ora所在的目录,可选)
NLS_LANG(设定合适的字符集,可选)
9.测试(oracle用户)
[oracle@blliu ~]$ isql OracleODBC-10g system oracle -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from v$version;
+-----------------------------------------------------------------+
| BANNER |
+-----------------------------------------------------------------+
| Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi|
| PL/SQL Release 10.2.0.5.0 - Production |
| CORE 10.2.0.5.0 Production |
| TNS for Linux: Version 10.2.0.5.0 - Production |
| NLSRTL Version 10.2.0.5.0 - Production |
+-----------------------------------------------------------------+
SQLRowCount returns 4294967295
5 rows fetched
isql -v
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23135684/viewspace-667126/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23135684/viewspace-667126/