数据库
首页 > 数据库> > centos安装oracle client客户端

centos安装oracle client客户端

作者:互联网

一、下载安装

1、官网下载所需的rpm包

rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-jdbc-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-odbc-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-tools-11.2.0.4.0-1.x86_64.rpm

2、添加环境变量

vim /etc/profile
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
export ORABIN=/usr/lib/oracle/11.2/client64/bin
export PATH=$PATH:$ORABIN
export PATH=$ORACLE_HOME:$PATH
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

3、使环境变量重新生效

source /etc/profile

4、配置监听配置文件

mkdir -p /usr/lib/oracle/11.2/client64/network/admin/
vim /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
TEST =
  (DESCRIPTION =
    (ENABLE = BROKEN)
    (FAILOVER = YES)
    (LOAD_BALANCE = OFF)
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.201)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = testdb)
      (FAILOVER_MODE =
        (TYPE = session)
        (METHOD = BASIC)
        (RETRIES = 30)
        (DELAY = 10)
      )
    )
  )
192.168.1.10 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = macpdb)
    )
  )

二、登录使用

1、使用sqlplus连接数据库

登录本机数据库

sqlplus / as sysdba
sqlplus username/password

登录远程数据库

sqlplus username/password@orcl
sqlplus username/password@hosrIP:port/sid

2、示例

sqlplus abc/abc#123@192.168.20.201:1521/testdb

 

标签:centos,11.2,client,sqlplus,export,oracle,PATH,rpm
来源: https://www.cnblogs.com/xcda/p/oracle_client.html