centos6.2 64位上配置oracle客户端

新项目为了使用php连接oracle数据库,对几台php服务器进行了oracle拓展支持的安装,搜了一下网上现有的几篇centos配置oracle的文章,其实都是有问题的.结合了相关搜索结果进行了整理,给出最完美的解决方案如下:

1. 下载oracle官方的rpm包 

http://download.oracle.com/otn/linux/instantclient/11203/oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

http://download.oracle.com/otn/linux/instantclient/11203/oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

这两个下载地址都很恶心地被oracle墙在用户登录验证成功之后才能下载,所以你要去注册很恶心的oracleID(虽然是免费注册的.)直接wget来的将会是一个错误页面.

 

2.查看一下两个包的默认安装路径

rpm -qpl oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

rpm -qpl oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

一般正常情况下,默认安装路径为:

oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm:

/usr/bin/sqlplus64
/usr/lib/oracle/11.2/client64/bin/sqlplus
/usr/lib/oracle/11.2/client64/lib/glogin.sql
/usr/lib/oracle/11.2/client64/lib/libsqlplus.so
/usr/lib/oracle/11.2/client64/lib/libsqlplusic.so

 

oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm:

/usr/lib/oracle/11.2/client64/bin/adrci
/usr/lib/oracle/11.2/client64/bin/genezi
/usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
/usr/lib/oracle/11.2/client64/lib/libnnz11.so
/usr/lib/oracle/11.2/client64/lib/libocci.so.11.1
/usr/lib/oracle/11.2/client64/lib/libociei.so
/usr/lib/oracle/11.2/client64/lib/libocijdbc11.so
/usr/lib/oracle/11.2/client64/lib/ojdbc5.jar
/usr/lib/oracle/11.2/client64/lib/ojdbc6.jar
/usr/lib/oracle/11.2/client64/lib/xstreams.jar

 

3.修改全局环境变量

nano /etc/profile
# Oracle InstantClient PATH by Daishengxiang 2013/04/06 2:56
export PATH=$PATH:/usr/lib/oracle/11.2/client64/bin
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client64/lib
export ORACLE_HOME=/usr/lib/oracle/11.2
export TNS_ADMIN=/usr/lib/oracle/11.2/network/admin

 

4.创建配置文件

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

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

 

其中tnsnames.ora的内容可以从oracle server那边直接拷贝过来,形式如同:

PRODB2 =
    (DESCRIPTION =
            (ADDRESS_LIST =
                    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.3.103.1)(PORT = 1521))
            )
            (CONNECT_DATA =
                    (SERVER=DEDICATED)
                    (SID = PRODB2)
            )
    )

 

最后,通过sqlplus测试连接oracle,通过连接.证明配置成功有效

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注