如何安装配置Oracle客户端?

Linux基础

1 前言

一个问题,一篇文章,一出故事。
笔者生产环境有一台服务器需要连接Oracle数据库,于是整理此文。

2 最佳实践

2.1 在线安装客户端

dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-basic-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-basiclite-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-sqlplus-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-tools-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-devel-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-jdbc-19.16.0.0.0-1.x86_64.rpm
dnf install https://download.oracle.com/otn_software/linux/instantclient/1916000/oracle-instantclient19.16-odbc-19.16.0.0.0-1.x86_64.rpm

以上连接可能会失效或你有其他的版本需求,请参考如下链接,
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

2.2 配置环境变量

vim /etc/profile.d/oracle-client.sh

加入如下配置,

export ORACLE_HOME=/usr/lib/oracle/19.16/client64
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin

然后,使用如下命令导入环境变量,

source /etc/profile

根据以上环境变量配置,我们需要创建以下文件和文件夹,

mkdir -p $TNS_ADMIN
vim $TNS_ADMIN/tnsnames.ora

加入如下配置,

ORADB_CON=
(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.168.0.34)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = oraser)
    )
)

2.3 测试连接

sqlplus oraUser/oraPassword@ORADB_CON

参阅文档
===============
https://docs.oracle.com/en/database/oracle/oracle-database/21/lacli/install-instant-client-using-rpm.html#GUID-2E81E2AE-E94C-413F-99B2-AE9A3949F05D

https://www.unixmen.com/install-oracle-client-centos/

没有评论

发表评论

Linux基础
如何二进制部署Metabase?

1 基础知识 1.1 Metabase的简介 – Metabase是一款简单、开源商业智 …

Linux基础
如何熟悉跨站点攻击CSRF?

1 CSRF的概念 – CSRF是英文“Cross-site request forge …

Linux基础
如何VIM替换Windows平台的换行符?

1 前言 一个问题,一篇文章,一出故事。 笔者打开一个之前在DOS平台编辑过的java配置文件发现没 …