在centos中安装oracle客户端并配置环境变量

参考文章:http://cysky.blog.51cto.com/211942/563294

       http://blog.sina.com.cn/s/blog_5fd26d460100vyuk.html

1、本人环境

  oracle服务端为10.2.0.1.0,安装在win7 32位上,Linux系统为centos6.5 32位,安装在Oracle VM VirtualBox虚拟机上,现在centos中安装oracle10.2.0.3客户端,以下操作都在root用户下

2、下载oracle客户端包

  进入主页面:http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

  如安装oracle10.2.0.3客户端,搜索:oracle-instantclient-basic-10.2.0.3-1.i386.rpm和oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm,分别下载下来,注意要申请oracle账号

3、rpm方式安装包

  上述包放到centos中某个目录下,我的放在/ljxd/software/oracleclient/rpm10g/ 下面。

  安装:rpm -ivh /ljxd/software/oracleclient/rpm10g/oracle-instantclient-basic-10.2.0.3-1.i386.rpm

       rpm -ivh /ljxd/software/oracleclient/rpm10g/oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm

4、环境变量配置

  打开用户专属配置文件(个人理解相当于windows系统环境变量的用户变量,只针对当前用户生效):vi ~/.bash_profile

  在最后增加如下几行(注意路径是否正确):  

      LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/10.2.0.3/client/lib
      export ORACLE_HOME=/usr/lib/oracle/10.2.0.3
      export TNS_ADMIN=/usr/lib/oracle/10.2.0.3/network/admin

      export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

  保存退出后,执行:source ~/.bash_profile 命令,以便以后重启后生效

  A、执行sqlplus时,如果出现sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory

  尝试在/etc/ld.so.conf中最后加入/usr/lib/oracle/10.2.0.3/client/lib/

  B、export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK 这里是配置字符集,如果配置不对,导出的数据会有乱码

5、配置TNS

  复制oracle服务端的tnsnames.ora文件,放到/usr/lib/oracle/10.2.0.3/network/admin/目录下,并且改成如下内容,注意host和port、SERVICE_NAME:

  # tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
  # Generated by Oracle configuration tools.

  win7orcl =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.101)(PORT = 1521))
      (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = orcl)
      )
    )

6、测试

  centos终端输入命令,测试成功:sqlplus centos/centos@win7orcl

  

posted @ 2015-03-27 15:37  crazyMyWay  阅读(16908)  评论(1编辑  收藏  举报