CentOS linux下安装Oracle客户端

来源:转载

本文目的是在CentOS 5.3上安装Oracle 11.2 instant client来访问远端的Oracle 10.2数据库,笔者测试通过,应该也适用于Redhat Linux 5.x

1.下载以下包,但是需要一个oracle的OTN的注册帐号(免费):
http://download.oracle.com/otn/linux/instantclient/112020/oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
http://download.oracle.com/otn/linux/instantclient/112020/oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
然后把该两包放到CentOS一个任意目录,比如 ~/tmp,以下过程我都用root帐号/

2.安装该包:

rpm -ivh ~/tmp/oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm

rpm -ivh ~/tmp/oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm

vi ~/.bashrc 加入

LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client/lib #对于64位版本可能是client64

3.测试一下:

sqlplus /nolog 系统报错

sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

4.然后需要:

vi /etc/ld.so.conf 加入

/usr/lib/oracle/11.2/client/lib/

/sbin/ldconfig

这样重新运行

sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:09:58 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL>
成功了

5.如需要连接远程oracle,必须配置TNS

mkdir -p /usr/lib/oracle/11.2/network/admin

vi /usr/lib/oracle/11.2/network/admin/tnsnames.ora

加入一个Oracle数据库tns信息
PRODB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.3.103.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(SID = PRODB2)
)
)

同时修改环境变量

vi ~/.bashrc

LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client/lib
export ORACLE_HOME=/usr/lib/oracle/11.2
export TNS_ADMIN=/usr/lib/oracle/11.2/network/admin
重启一下环境变量,或者用户logout/login一次

source ~/.bashrc

测试一下

sqlplus myOracleUsername/[email protected]

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:11:56 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select * from tab;
成功。

6.如果其他用户需要使用sqlplus,需要在该用户的~/.bashrc文件中添加上面提到的3行环境变量

感谢:本文完全参考:http://cysky.blog.51cto.com/211942/563294



分享给朋友:
您可能感兴趣的文章:
随机阅读: