fedora12下安装oracle11客户端

来源:http://archive.cnblogs.com/a/1989819/

目标:将oracle-client(v11)安装到”/opt/oracle/”下

  1. 准备好如下三个安装包,放在某个目录下,如:/root/software/oracle

       [root@localhost oracle]# pwd

       /root/software/oracle

       [root@localhost oracle]# ls

       oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm

       oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm            //  这个是SDK开发包

       oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm

       [root@localhost oracle]#

  1. 创建目标文件夹(oracle将安装在/opt/下)

[root@localhost opt]# mkdir oracle

[root@localhost opt]# mkdir oracle/network oracle/sdk

[root@localhost opt]# mkdir oracle/network/admin

  1. 解压其中2个rpm包(basic, sqlplus)

[root@localhost ~]# cd /root/software/oracle

[root@localhost oracle]# pwd

/root/software/oracle

[root@localhost oracle]# ls

oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm

oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm

oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm

[root@localhost oracle]# rpm2cpio oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm | cpio -div

./usr/lib/oracle/11.2/client/bin/adrci

./usr/lib/oracle/11.2/client/bin/genezi

./usr/lib/oracle/11.2/client/lib/libclntsh.so.11.1

./usr/lib/oracle/11.2/client/lib/libnnz11.so

./usr/lib/oracle/11.2/client/lib/libocci.so.11.1

./usr/lib/oracle/11.2/client/lib/libociei.so

./usr/lib/oracle/11.2/client/lib/libocijdbc11.so

./usr/lib/oracle/11.2/client/lib/ojdbc5.jar

./usr/lib/oracle/11.2/client/lib/ojdbc6.jar

./usr/lib/oracle/11.2/client/lib/xstreams.jar

336597 块

[root@localhost oracle]# rpm2cpio oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm | cpio -div

./usr/bin/sqlplus

./usr/lib/oracle/11.2/client/bin/sqlplus

./usr/lib/oracle/11.2/client/lib/glogin.sql

./usr/lib/oracle/11.2/client/lib/libsqlplus.so

./usr/lib/oracle/11.2/client/lib/libsqlplusic.so

5321 块

[root@localhost oracle]# ls

oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm

oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm

oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm

usr

  1. 将解压出来的usr目录下的bin和lib移动到/opt/oracle/下,再删除usr目录:

[root@localhost oracle]# mv usr/lib/oracle/11.2/client/bin /opt/oracle/

[root@localhost oracle]# mv usr/lib/oracle/11.2/client/lib /opt/oracle/

[root@localhost oracle]# rm -rf usr

  1. 解压剩下的rpm包(devel)

[root@localhost oracle]# rpm2cpio oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm | cpio -div

./usr/include/oracle/11.2/client/ldap.h

./usr/include/oracle/11.2/client/nzerror.h

./usr/include/oracle/11.2/client/nzt.h

./usr/include/oracle/11.2/client/occi.h

./usr/include/oracle/11.2/client/occiAQ.h

./usr/include/oracle/11.2/client/occiCommon.h

./usr/include/oracle/11.2/client/occiControl.h

./usr/include/oracle/11.2/client/occiData.h

./usr/include/oracle/11.2/client/occiObjects.h

./usr/include/oracle/11.2/client/oci.h

./usr/include/oracle/11.2/client/oci1.h

./usr/include/oracle/11.2/client/oci8dp.h

./usr/include/oracle/11.2/client/ociap.h

./usr/include/oracle/11.2/client/ociapr.h

./usr/include/oracle/11.2/client/ocidef.h

./usr/include/oracle/11.2/client/ocidem.h

./usr/include/oracle/11.2/client/ocidfn.h

./usr/include/oracle/11.2/client/ociextp.h

./usr/include/oracle/11.2/client/ocikpr.h

./usr/include/oracle/11.2/client/ocixmldb.h

./usr/include/oracle/11.2/client/ocixstream.h

./usr/include/oracle/11.2/client/odci.h

./usr/include/oracle/11.2/client/oratypes.h

./usr/include/oracle/11.2/client/ori.h

./usr/include/oracle/11.2/client/orid.h

./usr/include/oracle/11.2/client/orl.h

./usr/include/oracle/11.2/client/oro.h

./usr/include/oracle/11.2/client/ort.h

./usr/include/oracle/11.2/client/xa.h

./usr/lib/oracle/11.2/client/lib/libclntsh.so

./usr/lib/oracle/11.2/client/lib/libocci.so

./usr/lib/oracle/11.2/client/lib/ottclasses.zip

./usr/share/oracle/11.2/client/cdemo81.c

./usr/share/oracle/11.2/client/demo.mk

./usr/share/oracle/11.2/client/occidemo.sql

./usr/share/oracle/11.2/client/occidemod.sql

./usr/share/oracle/11.2/client/occidml.cpp

./usr/share/oracle/11.2/client/occiobj.cpp

./usr/share/oracle/11.2/client/occiobj.typ

./usr/share/oracle/11.2/client/ott

3833 块

[root@localhost oracle]#

  1. 将上面解压后的usr目录下所有文件移动到/opt/oracel/sdk下,删除无用的目录usr

[root@localhost oracle]# mv usr/* /opt/oracle/sdk/

[root@localhost oracle]# rm -rf usr

  1. 至此,oracle11的客户端安装完成,接下来进行配置

7.1   添加环境变量,在文件/etc/profile末尾添加如下两行:

export ORACLE_HOME=/opt/oracle

export LD_LIBRARY_PATH=/opt/oracle/lib

     7.2 启用刚才的设置

[root@localhost oracle]# source /etc/profile

通过echo $ORACLE_HOME可以查看刚才添加的环境变量是否已启用,如:

[root@localhost oracle]# echo $ORACLE_HOME

/opt/oracle

可见,已经启用成功!

  1. 配置监听器和网络

因为本地没有安装oracle数据库,所以需要从安装oracle数据库的目录弄三个文件过来,分别是:listener.ora  sqlnet.ora  tnsnames.ora ,放到/opt/oracle/network/admin下

  1. 修改文件tnsnames.ora如下:

# tnsnames.ora Network Configuration File: D:\DB\Oracle10g\network\admin\tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = Loveme)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

yuan =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.103)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

)

10.  修改listener.ora:

# listener.ora Network Configuration File: D:\DB\Oracle10g\network\admin\listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /opt/oracle)

              // 对应$ORACLE_HOME

      (PROGRAM = extproc)

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.103)(PORT = 1521))

    )

  )

11.   所有配置完成,接着测试是否可连接上远程的oracle数据库

[root@localhost bin]# cd ~

[root@localhost ~]# cd /opt/oracle/bin

[root@localhost bin]# ls

adrci  genezi  sqlplus

[root@localhost bin]# sqlplus

bash: sqlplus: command not found    // 这表示找不到sqlplus命令,还需要配置

事实上,ORACLE_HOME等都已经配置好了,但为什么还不行呢?记得windows系统下的环境变量path吗,只有这些目录下的可执行文件是可以直接在cmd窗口下运行的。所以我们先来看下当前系统下path变量的值吧:

[root@localhost bin]# echo $PATH

/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin

可见,“/opt/oracle/bin”并不在$PATH下,所以sqlplus命令无法直接运行。因此,只要将“/opt/oracle/bin”加进$PATH下就可以了(未尝试)。但是,我采用了如下的办法来解决:

#ln -s /opt/oracle/bin/sqlplus /usr/bin            

// 建立sqlplus文件的软连接到/usr/bin下

这样,sqlplus命令就可以直接在终端执行了。

但是仔细一运行,发现还是有错误:

./sqlplus: error while loading shared libraries: libnnz11.so: cannot enable executable stack as shared object requires: Permission denied

网上搜索了下,找到如下的答案(来源:http://seven.blog.51cto.com/120537/60173

[oracle@linux5 bin]$ sqlplus /nolog 
sqlplus: error while loading shared libraries: /u01/oracle/lib/libnnz11.so: cannot restore segment prot after reloc: Permission denied

Linux下执行程序时发生错误: cannot restore segment prot after reloc: Permission denied 
原来这是SELinux搞的鬼,解决办法有两个 
1. 使用chcon 命令 
示例: chcon -t texrel_shlib_t /usr/local/rsi/idl_6.1/bin/bin.linux.x86/*.so 
2. 禁止掉SELinux 
更改/etc/sysconfig/selinux 文件的内容为 SELINUX=disabled

于是,修改文件/etc/sysconfig/selinux,将SELINUX改为disabled.

再次运行sqlplus,发现结果还是一样,还是一样的错误。这时,我看到SELinux仍然在运行着,想想可能还是它的错,既然不知道怎么关闭,就重启吧。重启后,果真可以成功登录远程oracle数据库了:

[root@localhost ~]# sqlplus scott/scott@yuan

SQL*Plus: Release 11.2.0.2.0 Production on Sun Mar 20 23:02:44 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> select sysdate from dual;

SYSDATE

---------

20-MAR-11

SQL>

哈哈,把SELinux关闭后,发现我的网络再也不会经常掉线了,而且QQ也可以成功登录了!原来这一切都是SELinux搞的鬼。难怪我虚拟机下的QQ就可以一直正常登录,也不掉线,因为那里的SELinux默认是没有启动的。

本文转自孤舟夜航之家博客51CTO博客,原文链接http://blog.51cto.com/cysky/563299如需转载请自行联系原作者


cysky

已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页