Oracle 之instant client

客戶端要想連接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 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服務器的配置文件
可自定義
[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]# sqlplus
sqlplus: 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 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
[oracle@jiang ~]$ 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的另一連接方法






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章