1.下载安装包
-
下载链接 https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
-
找到对应版本,我使用的是11.2版本
oracle-instantclient11.2-basic-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-sqlplus-11.2.0.4.0-1.x86_64.rpm
2. 安装
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm --nodeps --force
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm --nodeps --force
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm --nodeps --force
3.配置Oracle连接
-
创建目录
mkdir -p /usr/lib/oracle/11.2/client64/network/admin
-
创建文件并写入
vi /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
dg01 =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 10.0.17.149)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dg01)
)
)
- 修改环境变量文件
vi ~/.bashrc
#末尾添加
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LANG=zh_CN.UTF-8
export NLS_LANG=AMERICAN_AMERICA.utf8
export PATH=$PATH:$ORACLE_HOME/bin
- 刷新环境变量
source ~/.bashrc
其他
- 查询rpm包
rpm -qa | grep oracle
- 卸载rpm包
rpm -e --nodeps oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64
rpm -e --nodeps oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64
rpm -e --nodeps oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64