在学习oracle的过程中,除了要安装oracle数据库软件以外,我们经常要在没有oracle数据库环境的主机上安装oracle client,以便通过
前言
在学习oracle的过程中,除了要安装oracle数据库软件以外,我们经常要在没有oracle数据库环境的主机上安装oracle client,以便通过网络访问oracle服务器。现在将在rhel 5.5 x86 系统中安装oracle instant client具体步骤演示如下:
安装环境:
在本文中,rhel 5.5 x86是安装在虚拟机中,用securecrt进行连接。
一 、下载安装文件
安装文件在oracle官网有相应的下载地址,地址:
找到本文中所对应的系统,进行下载。在本文中,笔者选择下载一下三个文件:
二、将安装文件上传到要安装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 全部配置成功。