潇湘夜雨移动版

主页 > 数据库 >

oracle客户端配置(linux)

环境说明:
 
系统:centos7.2
客户端版本:instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip 
 
[root@localhost ~]# mkdir /opt/oracle
[root@localhost ~]# cd /opt/oracle/
[root@localhost oracle]# unzip /root/instantclient-basic-linux.x64-11.2.0.4.0.zip ./
Archive:  /root/instantclient-basic-linux.x64-11.2.0.4.0.zip
caution: filename not matched:  ./
[root@localhost oracle]# unzip /root/instantclient-basic-linux.x64-11.2.0.4.0.zip 
Archive:  /root/instantclient-basic-linux.x64-11.2.0.4.0.zip
  inflating: instantclient_11_2/BASIC_README  
  inflating: instantclient_11_2/adrci  
  inflating: instantclient_11_2/genezi  
  inflating: instantclient_11_2/libclntsh.so.11.1  
  inflating: instantclient_11_2/libnnz11.so  
  inflating: instantclient_11_2/libocci.so.11.1  
  inflating: instantclient_11_2/libociei.so  
  inflating: instantclient_11_2/libocijdbc11.so  
  inflating: instantclient_11_2/ojdbc5.jar  
  inflating: instantclient_11_2/ojdbc6.jar  
  inflating: instantclient_11_2/uidrvci  
  inflating: instantclient_11_2/xstreams.jar  
 
 [root@localhost oracle]# unzip  /root/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip 
Archive:  /root/instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
  inflating: instantclient_11_2/SQLPLUS_README  
  inflating: instantclient_11_2/glogin.sql  
  inflating: instantclient_11_2/libsqlplus.so  
  inflating: instantclient_11_2/libsqlplusic.so  
  inflating: instantclient_11_2/sqlplus  
 
[root@localhost oracle]# ls
instantclient_11_2
 
[root@localhost instantclient_11_2]# ln -s libclntsh.so.11.1 libclntsh.so
[root@localhost instantclient_11_2]# ln -s libocci.so.11.1 libocci.so
[root@localhost instantclient_11_2]# rpm -qa|grep libaio
libaio-0.3.109-13.el7.x86_64
root@localhost instantclient_11_2]# scp 192.168.80.130:/home/oracle/u01/app/oracle/product/11.2.0/bin/imp ./
root@192.168.80.130's password: 
imp                                                                                                                                                  100%  456KB 456.4KB/s   00:00    
[root@localhost instantclient_11_2]# scp 192.168.80.130:/home/oracle/u01/app/oracle/product/11.2.0/bin/exp ./
root@192.168.80.130's password: 
exp                                                                                                                                                  100%  961KB 961.2KB/s   00:00    
[root@localhost instantclient_11_2]# mkdir rdbms
[root@localhost instantclient_11_2]# cd rdbms
[root@localhost rdbms]# scp -r 192.168.80.130:/home/oracle/u01/app/oracle/product/11.2.0/rdbms/mesg ./
 
[root@localhost ~]# exp help=y #测试命令是否正常
 
Export: Release 11.2.0.4.0 - Production on Tue Jul 17 11:11:25 2018
 
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
 
[root@localhost ~]# exp mobile/mobile@192.168.80.130:1521/orcl owner=mobile file=./back.tmp log=./back.log #导出测试
 
Export: Release 11.2.0.1.0 - Production on Tue Jul 17 11:22:34 2018
 
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 
 
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
 
 
 
报错
 
[root@localhost ~]# exp mobile/mobile@192.168.80.130:1521/orcl owner=mobile file=./back.tmp log=./back.log
 
Export: Release 11.2.0.4.0 - Production on Tue Jul 17 11:14:26 2018
 
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
 
exp: symbol lookup error: exp: undefined symbol: sldext
 
 
$ORACLE_HOME/network/mesg/tnsus.msb和 $ORACLE_HOME/rdbms/mesg/ulus.msb
这两个文件的版本与本地的client的版本不一致的原因
 
解决方法:
 
从server端scp 一份$ORACLE_HOME/lib/libclntsh.so到client的$ORACLE_HOME目录下,并改名与原本client端的类库文件一样的名称
 
 
创建数据库连接文件
 
在 instantclient_11_2 目录下创建 network/admin 目录,使用命令
 
             mkdir  -p network/admin,
并在 admin 目录下创建 tnsnames.ora 文件,文件内容类似如下:
 
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.130)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
**你也可以去安装了oracle机器去寻找这个配置文件 **,使用命令
 
 
 
测试连接
[root@localhost admin]# sqlplus /nolog
 
SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 17 14:09:01 2018
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
SQL> con orcl/orcl@orcl
SP2-0734: unknown command beginning "con orcl/o..." - rest of line ignored.
SQL> conn orcl/orcl@orcl
ERROR:
ORA-01017: invalid username/password; logon denied
 
 
SQL> conn mobile/mobile@orcl
Connected.
 
 
[root@localhost oracle]# sqlplus mobile/mobile@192.168.80.130:1521/orcl
 
SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 17 13:29:46 2018
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
(责任编辑:liangzh)