前言
在学习Oracle的过程中,除了要安装Oracle数据库软件以外,我们经常要在没有Oracle数据库环境的主机上安装Oracle client,以便通过网络访问Oracle服务器。现在将在RHEL 5.5 x86 系统中安装Oracle Instant Client具体步骤演示如下:
安装环境:
在本文中,RHEL 5.5 x86是安装在虚拟机中,用secureCRT进行连接。
一 、下载安装文件
安装文件在Oracle官网有相应的下载地址,地址:docker中文入门学习手册 iis7站长之家
找到本文中所对应的系统,进行下载。在本文中,笔者选择下载一下三个文件:
1、instantclient-basic-linux-11.2.0.3.0.zip(58,502,865 bytes) (cksum - 2164488682)
2、instantclient-sqlplus-linux-11.2.0.3.0.zip(796,570 bytes) (cksum - 3693267088)
3、nstantclient-sdk-linux-11.2.0.3.0.zip(639,306 bytes) (cksum - 3741058433)
二、将安装文件上传到要安装Oracle client的虚拟机中
在本文中,笔者用secureCRT的SFTP向RHEL 5.5 x86传输数据:
sftp> lcd "~/Desktop/client /"
sftp> lls
instantclient-basic-linux-11.2.0.3.0.zip instantclient-sdk-linux-11.2.0.3.0.zip
instantclient-sqlplus-linux-11.2.0.3.0.zip listener.ora
sqlnet.ora tnsnames.ora
sftp> cd /home/oracle/
sftp> put instantclient-basic-linux-11.2.0.3.0.zip
sftp> put instantclient-sdk-linux-11.2.0.3.0.zip
sftp> put instantclient-sqlplus-linux-11.2.0.3.0.zip
sftp> ls
instantclient-basic-linux-11.2.0.3.0.zip instantclient-sdk-linux-11.2.0.3.0.zip
instantclient-sqlplus-linux-11.2.0.3.0.zip
至此,安装文件上传完毕。
三、创建用户
[root@frank ~]# groupadd dba
[root@frank ~]# groupadd oinstall
[root@frank ~]# useradd -g oinstall -G dba oracle
[root@frank ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
四、配置环境变量
[root@frank ~]# su - oracle
[oracle@frank ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_HOME=/home/oracle/instantclient_11_2
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME:/usr/local/lib:${LD_LIBRARY_PATH}
export SQLPATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME:/home/oracle/instantclient_11_2
[oracle@frank ~]$ source .bash_profile
至此,环境变量配置完毕。
五、解压安装文件
[oracle@frank ~]$ unzip instantclient-basic-linux-11.2.0.3.0.zip
[oracle@frank ~]$ unzip instantclient-sdk-linux-11.2.0.3.0.zip
[oracle@frank ~]$ unzip instantclient-sqlplus-linux-11.2.0.3.0.zip
[oracle@frank ~]$ ls
instantclient_11_2 instantclient-sdk-linux-11.2.0.3.0.zip oradiag_oracle
instantclient-basic-linux-11.2.0.3.0.zip instantclient-sqlplus-linux-11.2.0.3.0.zip
六、配置tnsname.ora文件
在这一步中,将要连接的数据库的相关信息配置在tnsname.ora中:
[oracle@frank ~]$ cd instantclient_11_2/
[oracle@frank instantclient_11_2]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ENMOEDU =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ENMOEDU)
)
)
DUPL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DUPL)
)
)
退出保存。至此,tnsname.ora配置成功。
七、测试连接
[oracle@frank ~]$ sqlplus sys/oracle@ENMOEDU as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 5 15:44:48 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
测试成功。
至此 Oracle instant client 全部配置成功。