Ubuntu安装Oracle InstantClient

以前都是在RedHat下安装Oracle数据库或者客户端,今天需要在ubuntu上安装Oracle InstantClient,按道理也比较简单,今天就将安装过程记录下来。


环境:

Ubuntu14.04 LTS Server

Oracle 10.2.0.5 InstantClient:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

根据要求,我分别下载了Basic、SDK和Sqlplus包。


下面介绍两种安装方式:


一、直接下载相关ZIP包,这种方式最为简单


1、将三个ZIP包解压之后,合并到一起,然后上传到Ubuntu的某个用户下

2、默认文件夹为instantclient_10_2,设置775权限即可

sm@computer:~$ sudo chmod 775 -R instantclient_10_2/
3、直接执行该文件夹里面的sqlplus
sm@computer:~/instantclient_10_2$ sqlplus
sqlplus: command not found
提示无效的命令,这肯定是环境变量的问题

4、添加环境变量,然后执行没有问题

sm@computer:~$ export PATH=/home/sm/instantclient_10_2/:$PATH
sm@computer:~$ export LD_LIBRARY_PATH=/home/sm/instantclient_10_2/:$LD_LIBRARY_PATH
sm@computer:~$ cd instantclient_10_2/
sm@computer:~/instantclient_10_2$ sqlplus

SQL*Plus: Release 10.2.0.5.0 - Production on Tue Apr 7 15:01:29 2015

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Enter user-name:
5、我们同样可以将该环境变量添加到系统级别,这时候每次重启就直接读取环境变量了

sm@computer:~$ sudo vi /etc/profile
将上面的信息添加到该文件的后面

然后生效环境变量

sm@computer:~$ source /etc/profile
sm@computer:~$ echo $PATH
/home/sm/instantclient_10_2/:/home/sm/instantclient_10_2/:/home/sm/instantclient_10_2/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

这样就安装完毕了。


二、下载相关的RPM包

这种方式就比较麻烦了,因为RPM包是红帽和CentOS才识别的,如何才能在Ubuntu上安装RPM呢?

1、安装alien工具

apt-get install alien

2、使用alien命令将RPM转换为Ubuntu识别的deb包

sm@computer:~$ sudo alien -k oracle-instantclient-basic-10.2.0.5-1.x86_64.rpm
oracle-instantclient-basic_10.2.0.5-1_amd64.deb generated
sm@computer:~$ sudo alien -k oracle-instantclient-devel-10.2.0.5-1.x86_64.rpm
oracle-instantclient-devel_10.2.0.5-1_amd64.deb generated
sm@computer:~$ sudo alien -k oracle-instantclient-sqlplus-10.2.0.5-1.x86_64.rpm
oracle-instantclient-sqlplus_10.2.0.5-1_amd64.deb generated

3、使用dpkg命令安装deb包
sm@computer:~$ sudo dpkg -i oracle-instantclient-basic_10.2.0.5-1_amd64.deb
Selecting previously unselected package oracle-instantclient-basic.
(Reading database ... 61710 files and directories currently installed.)
Preparing to unpack oracle-instantclient-basic_10.2.0.5-1_amd64.deb ...
Unpacking oracle-instantclient-basic (10.2.0.5-1) ...
Setting up oracle-instantclient-basic (10.2.0.5-1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.5) ...
sm@computer:~$ sudo dpkg -i oracle-instantclient-devel_10.2.0.5-1_amd64.deb
Selecting previously unselected package oracle-instantclient-devel.
(Reading database ... 61725 files and directories currently installed.)
Preparing to unpack oracle-instantclient-devel_10.2.0.5-1_amd64.deb ...
Unpacking oracle-instantclient-devel (10.2.0.5-1) ...
Setting up oracle-instantclient-devel (10.2.0.5-1) ...
sm@computer:~$ sudo dpkg -i oracle-instantclient-sqlplus_10.2.0.5-1_amd64.deb
Selecting previously unselected package oracle-instantclient-sqlplus.
(Reading database ... 61768 files and directories currently installed.)
Preparing to unpack oracle-instantclient-sqlplus_10.2.0.5-1_amd64.deb ...
Unpacking oracle-instantclient-sqlplus (10.2.0.5-1) ...
Setting up oracle-instantclient-sqlplus (10.2.0.5-1) ...

4、系统会默认安装在如下路径
supermap@computer:/usr/lib/oracle/10.2.0.5/client64$ pwd
/usr/lib/oracle/10.2.0.5/client64

5、同样,我们将环境变量添加上去即可
export ORACLE_HOME=/usr/lib/oracle/10.2.0.5/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

相对来说,还是第一种方法比较简单,但是通过第二种方法也学习到了如何在必须安装RPM条件下的解决办法!

你可能感兴趣的:(Ubuntu安装Oracle InstantClient)