由于本机是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
- DYLD_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 DYLD_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
打印帮助信息
注意:运行sqlplus时可能会遇到如下错误:
oracle instant client 安装 libaio.so.1: cannot open shared object file
原因是sqlplus命令引用到的这个包没有找到,先使用ldd看一下还有其它包没有找到否:
cd /opt/oracle/lib/
ldd sqlplus
linux-vdso.so.1 => (0x00007fff4ccce000)
libsqlplus.so => /opt/oracle/lib/libsqlplus.so (0x00007faa788d4000)
libclntsh.so.11.1 => /opt/oracle/lib/libclntsh.so.11.1 (0x00007faa76042000)
libnnz11.so => /opt/oracle/lib/libnnz11.so (0x00007faa75c76000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007faa75a6a000)
libm.so.6 => /lib64/libm.so.6 (0x00007faa757e5000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007faa755c8000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007faa753af000)
libc.so.6 => /lib64/libc.so.6 (0x00007faa7501b000)
/lib64/ld-linux-x86-64.so.2 (0x00007faa78abd000)
libaio.so.1 => not found
只有libaio.so.1没有找到,ok,安装即可:
查找:yum search libaio
安装:yum install libaio.x86_64