安装
RPM包下载地址:https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
- 下载客户端,得到以下两个包
oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm
oracle-instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm
a)RedHat/CentOS直接rpm安装。
rpm -i oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm
rpm -i oracle-instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm
b)由于是rpm包,在Debian/Ubuntu下先将其转成deb包:
apt-get install alien
alien oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm
alien oracle-instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm
dpkg -i oracle-instantclient-basic_21.1.0.0.0-1.x86_64.rpm
dpkg -i oracle-instantclient-sqlplus_21.1.0.0.0-1.x86_64.rpm
安装在默认的目录下 /usr/lib/oracle/21/client64/
- 设置环境变量
~/.bash_profile
/~/.bashrc
$ vi ~/.bash_profile
ORACLE_HOME=/usr/lib/oracle/21/client64
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_HOME
export LD_LIBRARY_PATH
export PATH
生效
#centos
source ~/.bash_profile
#ubuntu
source~/.bashrc
使用
- 使用SQL * Plus连接服务器
sqlplus username/password@//host:port/sid
>show user;
执行SQLPlus,如出现找不到包libaio,apt-get/yum install libaio
即可。