C/C++教程

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安装oracle client客户端的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!