Red Hat 64位安装oracle 客户端sqlplus
1.首先下载以下两个安装包:
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
下载路径:
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
根据需要选择对应版本的包,共5个包,其中三个是必须的,两个可选,建议五个都下载安装。 # 必须下载安装 oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm # 可安装 oracle-instantclient12.1-jdbc-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-odbc-12.1.0.2.0-1.x86_64.rpm
2.然后用rpm 命令安装(root权限)
rpm–ivh oracle-instantclient19.16-basic-19.16.0.0.0-1.x86_64.rpm
rpm–ivh oracle-instantclient19.16-sqlplus-19.16.0.0.0-1.x86_64.rpm
注意:两个包有安装顺序
3.安装成功后,可以看到/usr/lib目录下自动生成/oracle/12.1/client64里面的bin和lib文件:
在此目录下创建并设置tnsnames.ora文件,保存并退出
4.此时就应该配置属性文件了(回到用户根目录,vi .bash_profile),记得先切换到使用oracle客户端的那个用户再设置:
[oracle@test-cdh03 ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin # User specific environment and startup programs PATH=$PATH:$HOME/bin #export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/usr/lib/oracle/19.16/client64 export ORACLE_SID=KGDB export TWO_TASK=KGDB export TNS_ADMIN=/usr/lib/oracle/19.16/client64 export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=/usr/lib/oracle/19.16/client64/lib export LANG=en_US #export LANG=C export EDITOR=vi export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #export NLS_LANG=AMERICAN.utf8 stty erase ^H export PATH export PATH
5.此时便可登录验证是否配置正确:
报错信息1:
ERROR: ORA-01017: Enter user-name:
注意:
/home/oracle/.bash_profile oracle用户的配置
/root/.bash_profile root用户的配置