To connect to an Oracle server, the client must have an Oracle client installed, however, the normal Oracle Client installation package is large and takes a long time to-instant client
1. Download the installation package
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html #选择对应的版本通常下载的包有: [Email Protected] ~]# ls mypackages/instantclient-basic-linux32-11.2.0.1.zip #基本的包instantclient-sdk-linux32-11.2.0.1.zip #客户端开发程序包, such as the need to compile PHP to connect to Oracle, this is not a required package, but it is best to install it. Instantclient-sqlplus-linux32-11.2.0.1.zip #sqlplus安装包 # Decompression for i in ' ls | Xargs '; Do unzip $i; Done[[email protected] mypackages]# ls-d instantclient_11_2/#解压后生成的目录instantclient_11_2/
2. Create the installation directory
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. Configure Environment variables
Export path= $PATH: $HOME/bin:/opt/oracle/instantclient_11_2export oracle_home=/opt/oracle/instantclient_11_2 # Home Directory Export ld_library_path=/opt/oracle/instantclient_11_2 #库文件目录export tns_admin=/opt/oracle/network/admin/# Configuration files that connect to an Oracle server can be customized [[email protected] 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) ) )
The following error occurred while performing the Sqlplus test connection:
[[email protected] oracle]# sqlplussqlplus:error while loading shared Libraries:libaio.so.1:cannot open Shared object file:no such file or directory# missing installation package, the workaround is as follows [[email protected] Orac le]# yum-y Install libaio[[email protected] ~]$ sqlplus zabbix/[email protected] #连接成功SQL *plus:release 11.2. 0.1.0 Production on Thu May 8 17:03:13 2014Copyright (c) 1982, D, Oracle. All rights reserved. Connected to:oracle Database 11g Enterprise Edition Release 11.2.0.1.0-productionwith The partitioning, OLAP, Data Minin G and Real Application testing options
[[email protected] ~]$ sqlplus scott/[email protected]:1521/zabbixsql*plus:release 11.2.0.1.0 Production on Thu May 8 17: 05:18 2014Copyright (c) 1982, Oracle. All rights reserved. Connected to:oracle Database 11g Enterprise Edition Release 11.2.0.1.0-productionwith The partitioning, OLAP, Data Minin Another connection method for G and Real application testing Options#sqlplus
This article from "Wave Scouring sand" blog, declined reprint!