oracle

linux安装oracle客户端

admin · 10月25日 · 2020年

1.下载rpm包

下载base和plus两个rpm安装包

https://download.luckinserver.cn:90/linux-software/oracle/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
https://download.luckinserver.cn:90/linux-software/oracle/oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

2.安装和配置环境变量

rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

vim /etc/profile
export ORACLE_HOME=/usr/local/oracle/instantclient_11_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
##export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH

3.配置tnsnames.ora

mkdir -p  /usr/lib/oracle/11.2/client64/network/admin

echo > /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora <EOF
# tnsnames.ora Network Configuration File: /home/ec2-user/data/app/ec2-user/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 52.83.83.125 )(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
EOF

#测试登录
sqlplus user/passwd@52.83.83.125/ORCL