客户端要想连接oracle服务器,必须先安装oracle客户端,然而,普通的oracle客户端安装包较大,耗费时间长,若以有了oracle的精简客户端-instant client
1.下载安装包
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html #选择对应的版本通常下载的包有:[root@jiang ~]# ls mypackages/instantclient-basic-linux32-11.2.0.1.zip #基本的包instantclient-sdk-linux32-11.2.0.1.zip #客户端开发程序包,比如编译php连接oracle时需要用到,此处不是必须的包,但最好安装。instantclient-sqlplus-linux32-11.2.0.1.zip #sqlplus安装包#解压for i in `ls | xargs`; do unzip $i; done[root@jiang mypackages]# ls -d instantclient_11_2/ #解压后生成的目录instantclient_11_2/
2.创建安装目录
useradd oinstalluseradd -g oinstall oracle && echo "123456" | passwd --stdin oraclemkdir -p /opt/oraclemv /root/instantclient_11_2 /opt/oraclechown -R oracle.oinstall /opt/oracle
3.配置环境变量
export PATH=$PATH:$HOME/bin:/opt/oracle/instantclient_11_2export ORACLE_HOME=/opt/oracle/instantclient_11_2 #家目录export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 #库文件目录export TNS_ADMIN=/opt/oracle/network/admin/ #连接oracle服务器的配置文件可自定义[oracle@jiang admin]$ cat /opt/oracle/network/admin/tnsnames.ora# tnsnames.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools.MYZABBIX = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.101)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = zabbix) ) )
当执行sqlplus测试连接时出现如下错误:
[root@jiang oracle]# sqlplussqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory#缺少安装包,解决方法如下[root@jiang oracle]# yum -y install libaio[oracle@jiang ~]$ sqlplus zabbix/zabbix@myzabbix #连接成功SQL*Plus: Release 11.2.0.1.0 Production on Thu May 8 17:03:13 2014Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@jiang ~]$ sqlplus scott/tiger@192.168.56.101:1521/zabbixSQL*Plus: Release 11.2.0.1.0 Production on Thu May 8 17:05:18 2014Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options#sqlplus的另一连接方法