客户端要想连接oracle服务器,必须先安装oracle客户端,然而,普通的oracle客户端安装包较大,耗费时间长,若以有了oracle的精简客户端-instant client
1.下载安装包
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 #客户端开发程序包,比如编译php连接oracle时需要用到,此处不是必须的包,但最好安装。 instantclient-sqlplus-linux32-11.2.0.1.zip #sqlplus安装包 #解压 for i in `ls | xargs`; do unzip $i; done [[email protected] mypackages]# ls -d instantclient_11_2/ #解压后生成的目录 instantclient_11_2/
2.创建安装目录
useradd oinstall useradd -g oinstall oracle && echo "123456" | passwd --stdin oracle mkdir -p /opt/oracle mv /root/instantclient_11_2 /opt/oracle chown -R oracle.oinstall /opt/oracle
3.配置环境变量
export PATH=$PATH:$HOME/bin:/opt/oracle/instantclient_11_2 export ORACLE_HOME=/opt/oracle/instantclient_11_2 #家目录 export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 #库文件目录 export TNS_ADMIN=/opt/oracle/network/admin/ #连接oracle服务器的配置文件 可自定义 [[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) ) )
当执行sqlplus测试连接时出现如下错误:
[[email protected] oracle]# sqlplus sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory #缺少安装包,解决方法如下 [[email protected] oracle]# 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 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] ~]$ sqlplus scott/[email protected]:1521/zabbix SQL*Plus: Release 11.2.0.1.0 Production on Thu May 8 17:05:18 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options #sqlplus的另一连接方法
Oracle 之instant client
时间: 2024-11-02 18:54:41