天天看點

Linux環境下oracle client安裝和配置

  1.要遠端使用oracle,先下載下傳下面三個檔案,注意版本最好一緻。

oracle-instantclient-basic-10.2.0.4-1.i386.rpm

oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm

oracle-instantclient-devel-10.2.0.4-1.i386.rpm

  2.pm安裝

oracle-instantclient-basic-10.2.0.4-1.i386.rpm是基本的動态庫、jar包,預設安裝路徑是:/usr/lib/oracle/10.2.0.4/client

oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm是用戶端sqlplus安裝包, 預設安裝路徑是:/usr/lib/oracle/10.2.0.4/client

oracle-instantclient-devel-10.2.0.4-1.i386.rpm是api接口檔案,預設安裝路徑是:/usr/include/oracle/10.2.0.4/client

  這裡不需要修改預設路徑,直接安裝即可:

sudo rpm-avi oracle-instantclient-basic-10.2.0.4-1.i386.rpm

sudo rpm-avi oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm

sudo rpm-avi oracle-instantclient-devel-10.2.0.4-1.i386.rpm

  3.配置環境變量

vi /etc/profile

export oracle_home=/usr/lib/oracle/10.2.0.4

export tns_admin=$oracle_home/network/admin

export nls_lang=american_america.zhs16gbk

exportld_library_path=$oracle_home/client/lib:$ld_library_path

exportoci_headers_home=/usr/include/oracle/10.2.0.4/client

export oci_libs_home=$oracle_home/client/lib

  後面兩項是為了我們的程式程式編譯時使用友善,編譯時直接加入選項:

  -i$( oci_headers_home) –l$( oci_libs_home) –l occi

  4.配置監聽器和網絡環境

[huangxw@ubuntu admin]$

cat/usr/lib/oracle/10.2.0.4/network/admin/tnsnames.ora

test_base=

(description =

(address_list =

(address = (protocol = tcp)(host = *.*.*.*)(port = ****))

)

(connect_data =

(service_name = tt4adol)

  5.測試連接配接

[huangxw@ubuntu bin]$./sqlplus username/passwd@test_base

sql*plus: release 10.2.0.4.0 - production onmon jan 13 10:09:31 2014

copyright (c) 1982, 2007, oracle.  all rights reserved.

connected to:

oracle database 11g enterprise edition release11.2.0.2.0 - 64bit production

with the partitioning, olap, data mining andreal application testing options

sql> select * from username.tablename  where accountid = 8401428;

accountid   invta     snda    raina   insb    spen    remn

---------- ---------- ---------- -------------------- ---------- ----------

invtc     spdc    rein

---------- ---------- ----------

8401428          0          0    100000          0          0          0

0          0          0

最新内容請見作者的github頁:http://qaseven.github.io/