1.本机环境centos7.7.1908
[root@bogon ~]# uname -a Linux bogon 3.10.0-1062.1.2.el7.x86_64 #1 SMP Mon Sep 30 14:19:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux [root@bogon ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
2.下载oracle客户端
下载地址:https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
其他版本:https://www.oracle.com/database/technologies/instant-client/downloads.html
根据业务需要我们这里下载11.2.0.4版本的客户端
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm #必选 oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm #必选 oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm #可选 oracle-instantclient11.2-jdbc-11.2.0.4.0-1.x86_64.rpm #可选 oracle-instantclient11.2-odbc-11.2.0.4.0-1.x86_64.rpm #可选 oracle-instantclient11.2-tools-11.2.0.4.0-1.x86_64.rpm #可选 一般下载前两个即可,其他根据业务需要可选。
3.安装oracle客户端
我们先把下载的rpm放到服务器上,我们这里放到/root 目录
查看rpm默认安装的目录
[root@bogon ~]# rpm -qpl oracle-instantclient11.2-basic-11.2.0.4.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
安装有两种方式rpm 和yum 推荐采用yum安装
yum安装
[root@bogon ~]# yum install oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm安装
[root@bogon ~]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
依次把所下载的rmp包安装
4.创建所需目录和对应的环境变量
#创建存放TNS文件的目录 [root@bogon ~]# mkdir -p /usr/lib/oracle/11.2/client64/network/admin #可以直接修改/etc/profile全局变量 #[root@bogon ~]# vi /etc/profile [root@bogon ~]# vi ~/.bash_profile #install oracle client by:xiaofeng.org export ORACLE_VERSION=11.2 export ORACLE_HOME=/usr/lib/oracle/$ORACLE_VERSION/client64 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export TNS_ADMIN=$ORACLE_HOME/network/admin export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 export PATH=$PATH:$ORACLE_HOME/bin
5.测试安装是否完成
退出root用户重新登陆系统
[root@bogon ~]# sqlplus system/passwd@10.0.0.110:1521/dbtst SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 16 17:24:19 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
测试通过安装完成