有时我们需要在Linux操作系统下搭建Oracle客户端,可通过以下几步: (1)下载oracle-instantclient的rpm包: oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm oracle-instantclient19.3-sqlplus-19.3.0.0.0-1.x86_64.
有时我们需要在Linux操作系统下搭建Oracle客户端,可通过以下几步:
(1)下载oracle-instantclient的rpm包:
oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm
oracle-instantclient19.3-sqlplus-19.3.0.0.0-1.x86_64.rpm
下载地址: https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
(2)安装rpm包:
rpm -ivh oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm
rpm -ivh oracle-instantclient19.3-sqlplus-19.3.0.0.0-1.x86_64.rpm
安装完成后,oracle客户端默认装在/usr/lib/oracle下。
(3)设置环境变量及目录
编辑root用户的.bash_profile文件:
PATH=$PATH:$HOME/bin
export ORACLE_HOME=/usr/lib/oracle/19.3/client64/
export ORACLE_BASE=/usr/lib/oracle/19.3/
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
编译完成后使其立即生效:
source .bash_profile
创建不存在的目录:
mkdir -p $ORACLE_HOME/network/admin
(4)添加tns服务名
vim $ORACLE_HOME/network/admin/tnsnames.ora
yun_119 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.XX.XX)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
(5)验证是否成功
还可以直连数据库:
更多Oracle相关信息见Oracle 专题页面 https://www.558idc.com/topicnews.aspx?tid=12