linux单独安装oracle客户端及exp/imp工具配置&proc c_c++

本篇文章的操作在实际环境中进行过测试!
闲话少说,直接进入正文,下面为大家介绍在linux环境中如何单独配置oracle客户端去远程访问oracle数据库。
1、下载

Linux 下的 Oracle Instant Client 有rpm包和zip包两种,下载任意一种即可,这里以下载的 zip 包为例,下载rpm包的安装见Oracle Instant Client rpm包安装

[下载]: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

    oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.zip
    oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.zip
    oracle-instantclient11.2-sdk-11.2.0.4.0-1.x86_64.zip

2、解压安装

命令如下:

 unzip oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.zip
 unzip oracle-instantclient11.2-sdk-11.2.0.4.0-1.x86_64.zip
 unzip oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.zip

 
3、创建数据库连接文件

在 instantclient_11_2 目录下创建 network/admin 目录,使用命令

             mkdir  -p network/admin,

并在 admin 目录下创建 tnsnames.ora 文件,文件内容类似如下:

# tnsnames.ora Network Configuration File: /sdb1/oracle/11gR2_database_X64/product/11.2.0.4.0/db_1/network/admin/tnsnames.ora  
      # Generated by Oracle configuration tools.  
     ZKL =  
        (DESCRIPTION =  
          (ADDRESS = (PROTOCOL = TCP)(HOST = glnode04)(PORT = 1521))  
          (CONNECT_DATA =  
            (SERVER = DEDICATED)  
            (SERVICE_NAME = zkl)  
           )  
        )

你也可以去安装了oracle机器去寻找这个配置文件 ,使用命令

     locate tnsnames.ora

找到之后可以使用ftp、scp或者sftp命令将文件传输至要安装oracle客户端机器(当然你也可以more打开复制过来),命令如下,以sftp为例

     sftp username@客户端ip
     输入密码后:
     put 你要传的文件 客户端机器的目录

5、配置环境变量

这里配置 root 用户环境变量: ~/.bashrc

export ORACLE_HOME=/你的安装路径/instantclient_11_2  
export PATH=$ORACLE_HOME:$PATH  
export TNS_ADMIN=$ORACLE_HOME/network/admin  
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH   
export NLS_LANG='simplified chinese_china.ZHS16GBK'

注意要配置LD_LIBRARY_PATH 变量,sqlplus等程序运行时需要加载相应库,若不配置,则运行时会出现如下错误:

    Error 6 initializing SQL*Plus
    SP2-0667: Message file sp1<lang>.msb not found
    SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

配置完毕后,进行刷新环境变量,进行生效

source  ~/.bashrc

6、测试

 sqlplus /nolog

出现下面结果

    SQL*Plus: Release 11.2.0.4.0 Production on 星期二 1月 10 11:14:31 2012
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    SQL> conn zkl/zkl@zkl
    已连接。
    SQL>

至此,安装成果,测试也通过!但exp/imp命令是会经常用到的,接下来配置这两个命令,十分简单。

7.安装proc编译环境
下载oracle-instantclient11.2-precomp-11.2.0.1.0-1.x86_64.zip 并解压
cp instantclient_11_2/precomp/admin/pcscfg.cfg instantclient_11_2/sdk/demo/
ln -sf libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so


8、exp/imp配置

简单来说就是去安装了oracle数据的机器将exp/imp命令的文件复制过来就可以了。
假设oracle安装地址是:/oracle/orahome/product/11.2.0.4.0
1)
将:

    /oracle/orahome/product/11.2.0.4.0/bin/exp
    /oracle/orahome/product/11.2.0.4.0/bin/imp
    复制到
    /你的安装路径/instantclient_11_2

2)
创建目录
/你的安装路径/instantclient_11_2 /rdbms/mesg/

3)

将:

    /oracle/orahome/product/11.2.0.4.0/rdbms/mesg/expus.msb
    /oracle/orahome/product/11.2.0.4.0/rdbms/mesg/impus.msb
    复制到
    /你的安装路径/instantclient_11_2 /rdbms/mesg/
    
    
9.sqlldr安装
1)
将:

    /oracle/orahome/product/11.2.0.4.0/bin/sqlldr
    复制到
    /你的安装路径/instantclient_11_2
2)
将:

    /oracle/orahome/product/11.2.0.4.0/rdbms/mesg/ulus.msb
    复制到
    /你的安装路径/instantclient_11_2 /rdbms/mesg/

    

10. 官方README

Installation


See the Instant Client Home Page for more information.

Installation of ZIP files:

1. Download the desired Instant Client ZIP files. All installations require the Basic or Basic Light package.

2. Unzip the packages into a single directory such as /opt/oracle/instantclient_12_2 that is accessible to your application. For example:

cd /opt/oracle            
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip


3. Create the appropriate libclntsh.so and libocci.so links for the version of Instant Client. For example:

cd /opt/oracle/instantclient_12_2
ln -s libclntsh.so.12.1 libclntsh.so
ln -s libocci.so.12.1 libocci.so


4. Install the libaio package, for example on Oracle Linux, run this as the root user:

yum install libaio


On some Linux distributions the package is called libaio1.

5. Set the environment variable LD_LIBRARY_PATH to the directory created in Step 2, for example:

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH


Alternatively, add this path to an ldconfig configuration file if there is no other Oracle software that will be impacted.

6. To use supplied binaries such as SQL*Plus, update your PATH environment variable, for example:

export PATH=/opt/oracle/instantclient_12_2:$PATH


7. Start your application.


ODBC users should follow the ODBC Installation Instructions.

Installation of RPM files:


1. Download the desired Instant Client RPM packages. All installations require the Basic or Basic Light RPM.

2. As the root user, install the packages with yum. For example:

yum install oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm


3. Set the environment variable LD_LIBRARY_PATH to the appropriate directory for the Instant Client version, for example:

export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH


Alternatively, add this path to an ldconfig configuration file if there is no other Oracle software that will be impacted.

4. To use supplied binaries such as SQL*Plus, update your PATH environment variable, for example:

export PATH=/usr/lib/oracle/12.2/client64/bin:$PATH


5. Start your application.


ODBC users should follow the ODBC Installation Instructions.




猜你喜欢

转载自blog.csdn.net/u012724167/article/details/78250787