数据库
首页 > 数据库> > Linux连接oracle

Linux连接oracle

作者:互联网

1、下载rpm包

https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

oracle-instantclient-basic-21.6.0.0.0-1.el8.x86_64.rpm
oracle-instantclient-sqlplus-21.6.0.0.0-1.el8.x86_64.rpm

2、安装rpm包

RedHat/CentOS直接rpm安装:

rpm -ivh oracle-instantclient-basic-21.6.0.0.0-1.el8.x86_64.rpm

rpm -ivh oracle-instantclient-sqlplus-21.6.0.0.0-1.el8.x86_64.rpm

在Debian/Ubuntu下先将其转成deb包:

alien oracle-instantclient-basic-21.6.0.0.0-1.el8.x86_64.rpm

alien oracle-instantclient-sqlplus-21.6.0.0.0-1.el8.x86_64.rpm

得到:

oracle-instantclient-basic-21.6.0.0.0-1.el8.x86_64.deb

oracle-instantclient-sqlplus-21.6.0.0.0-1.el8.x86_64.deb

然后dpkg安装:

dpkg -i oracle-instantclient-basic-21.6.0.0.0-1.el8.x86_64.deb

dpkg -i oracle-instantclient-sqlplus-21.6.0.0.0-1.el8.x86_64.deb

3、配置oracle连接

创建目录

cd /usr/lib/oracle/21/client64

mkdir network/admin

vim network/admin/tnsnames.ora

ORAL =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
  )
  (CONNECT_DATA =
  (SERVICE_NAME = oral)
  )
)

修改profile文件添加环境:

vim /etc/profile

export ORACLE_HOME=/usr/lib/oracle/21/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=/usr/lib/oracle/21/client64/lib
export PATH=$ORACLE_HOME:$PATH

生效:

source /etc/profile

4、连接oracle

直接连接:

sqlplus username/password@远端ip:端口号/服务名

其他连接方式:

sqlplus /nolog

conn user/password@//ip:port/database

 

标签:21.6,x86,el8,64,Linux,oracle,rpm,连接
来源: https://www.cnblogs.com/JesseGod/p/16223939.html