日期:2014-05-16  浏览次数:20698 次

linux下oracle客户端安装

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

由于本机是64位linux,所以选择Instant Client for Linux x86-64?

查看oracle服务器端的版本:

?select * from V$version?

结果中有:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

所以oracle客户端也选择11.2.0.3.0版本。

下载如下三个文件:

instantclient-basic-linux.x64-11.2.0.3.0.zip

instantclient-sqlplus-linux.x64-11.2.0.3.0.zip

instantclient-sdk-linux.x64-11.2.0.3.0.zip

?

二。解压

mkdir -p /opt/oracle/lib?
mkdir -p /opt/oracle/network/admin

?

解压三个下载文件

unzip?instantclient-basic-linux.x64-11.2.0.3.0.zip

unzip?instantclient-sqlplus-linux.x64-11.2.0.3.0.zip

unzip?instantclient-sdk-linux.x64-11.2.0.3.0.zip

?

解压后内容将在当前目录下的instantclient_11_2下

cd?instantclient_11_2

mv sdk??/opt/oracle/sdk

mv *??/opt/oracle/lib

?

三。配置环境变量

vi /etc/profile?

ORACLE_HOME=/opt/oracle
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$ORACLE_HOME/lib:$PATH  
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  
export JAVA_HOME ANT_HOME PATH CLASSPATH LD_LIBRARY_PATH ORACLE_HOME 

?保存后使其生效 source?/etc/profile 或者 .??/etc/profile

?

四。配置监听器和网络环境

cd ?/opt/oracle/network/admin

新建三个文件sqlnet.ora,tnsnames.ora,listener.ora

在sqlnet.ora中加入如下内容:

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES)

?在tnsnames.ora中加入如下内容:

orcl_db =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.xxx.xxx)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

?

在listener.ora中加入如下内容:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /opt/oracle)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

?

五。测试

# sqlplus username@orcl_db

SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 11 10:59:17 2013

?

Copyright (c) 1982, 2011, Oracle. ?All rights reserved.

?

Enter password:?

?

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

?

With the Partitioning, OLAP, Data Mining and Real Application Testing options

?

ok,说明链接服务器成功。

?

六。安装sqlldr

windows版本的client会有sqlldr命令,但是linux版本的client就没有这个命令了,不过可以从服务器端copy这个命令。

先按照上面的方式安装linux客户端,然后将服务器端的如下两个文件拷贝到客户端:

从服务器端将$ORACLE_HOME/bin/sqlldr拷贝到/opt/oracle/lib下,并授予执行权限,

从服务器端将$ORACLE_HOME/rdbms/mesg/ulus.msb 拷贝到/opt/oracle/rdbms/mesg下。

?

查看sqlldr的依赖是否都存在

$>?cd /opt/oracle/lib/

$>?ldd -r sqlldr

?

测试:

$> sqlldr?

打印帮助信息

?