如果有錯,謝謝指出!
一、配置環境
需要在安裝有oracle軟件的相同操作系統上獲取部分oracle的系統文件
二、配置目標
無需安裝oracle服務器或客戶端軟件,達到能使用以下功能的目標:
? oci、occi、jdbc的支持
? tnsping
? sqlplus
? sqlldr
? exp
? imp
? tkprof
三、軟件下載
http://www.oracle.com/technetwork/cn/database/features/instant-client/index-092699-zhs.html
instantclient-basic-linux.x64-11.2.0.3.0
instantclient-jdbc-linux.x64-11.2.0.3.0
instantclient-sqlplus-linux.x64-11.2.0.3.0
instantclient-sdk-linux.x64-11.2.0.3.0
四、配置步驟
配置各個功能都一樣,關鍵是環境變量的配置,根據自己實際情況配置,這些基本上都是在網上找的,關鍵環境變量做了改動
1、配置sqlplus
root用戶登錄,創建目錄:
將所有軟件包解壓縮至/opt/oracle/下,所有文件將自動釋放至目錄/opt/oracle/instantclient_10_2/下
創建文件/opt/oracle/instantclient_10_2/tnsnames.ora
格式如下:
CZJGBS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 81.17.1.23)(PORT = 1521)) //需要連接的IP
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = czjgbs) //需要連接的實例
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
) 在需要使用oracle功能的測試用戶環境變量中,添加如下配置,這里一定要注意,如果你失敗了百分之八十都是這里的問題:
export ORACLE_HOME=/opt/oracle
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_IC_HOME=/opt/oracle/instantclient_11_2
export ORACLE_HOME=$ORACLE_IC_HOME
export TNS_ADMIN=$ORACLE_IC_HOME
export PATH=$PATH:$HOME/bin:$ORACLE_IC_HOME
export LD_LIBRARY_PATH=$ORACLE_IC_HOME:/usr/lib
export ORACLE_SID=czjgbs //(需要連接的實例名稱)
生效后,測試sqlplus:
$ sqlplus scott/tiger@ora215
SQL*Plus: Release 10.2.0.4.0 - Production on 星期五 8月 3 10:41:44 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL>
Ok,sqlplus工具可以使用了;
2、配置
tnsping 下面我們在此基礎上增加tnsping工具
回到root用戶,在其他裝有Oracle的機器上獲取必要的文件:
# cd /opt/oracle/instantclient_10_2/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/bin/tnsping ./ //這是從其他安裝了oracle服務器的機子上拷貝文件過來,不一定非要通過這種方法,
root@192.168.21.16's password:
tnsping 100% 13KB 13.3KB/s 00:00
# mkdir-p network/mesg
# cd network/mesg
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/network/mesg/tnsus.msb ./
root@192.168.21.16's password:
tnsus.msb 100% 46KB 46.0KB/s 00:00
#
下面測試一下tnsping工具
$ tnsping ora16
TNS Ping Utility for Linux: Version 10.2.0.4.0 - Production on 03-8月 -2012 11:03:39
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.21.16)(PORT = 1521))) (CONNECT_DATA = (SID = neizxmdb1) (SERVER = DEDICATED)))
OK (0 msec)
$
Ok,tnsping能正確運行了!
3、配置
sqlldr Oracle的instanct_client沒有自帶sqlldr工具,也要單獨獲取相關的文件:
root用戶登錄:
# cd /opt/oracle/instantclient_10_2/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/bin/sqlldr ./
root@192.168.21.16's password:
sqlldr 100% 717KB 717.5KB/s 00:00
# mkdir -p rdbms/mesg/
# cd rdbms/mesg/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/rdbms/mesg/ulus.msb ./
root@192.168.21.16's password:
ulus.msb 100% 37KB 37.0KB/s 00:00
#
在測試用戶中運行sqlldr:
$ sqlldr
SQL*Loader: Release 10.2.0.4.0 - Production on 星期五 8月 3 11:20:04 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Usage: SQLLDR keyword=value [,keyword=value,...]
Valid Keywords:
……
Sqlldr工具可以運行了
4、配置imp、exp
root用戶登錄:
# cd /opt/Oracle/instantclient_10_2/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/bin/imp ./
root@192.168.21.16's password:
imp 100% 348KB 348.3KB/s 00:00
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/bin/exp ./
root@192.168.21.16's password:
exp 100% 697KB 697.1KB/s 00:00
# cd rdbms/mesg/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/rdbms/mesg/impus.msb ./
root@192.168.21.16's password:
impus.msb 100% 16KB 15.5KB/s 00:00
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/rdbms/mesg/expus.msb ./
root@192.168.21.16's password:
expus.msb 100% 17KB 16.5KB/s 00:00
#
測試用戶下運行imp和exp
$ imp
Import: Release 10.2.0.4.0 - Production on 星期五 8月 3 11:31:24 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Username:
$ exp
Export: Release 10.2.0.4.0 - Production on 星期五 8月 3 11:31:13 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Username:
Ok!
5、配置
tkprof Tkprof是一個格式化sql trace文件的工具,在簡單客戶端中,我們也可以添加進來:
root用戶登錄:
# cd /opt/oracle/instantclient_10_2/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/bin/tkprof ./
root@192.168.21.16's password:
tkprof 100% 135KB 135.1KB/s 00:00
# mkdir -p oracore/mesg/
# cd oracore/mesg/
# scp root@192.168.21.16:/oracle/orahome/product/10.2.0/oracore/mesg/lrmus.msb ./
root@192.168.21.16's password:
lrmus.msb 100% 4608 4.5KB/s 00:00
#
測試用戶下執行
$ tkprof
Usage: tkprof tracefile outputfile [explain= ] [table= ]
[print= ] [insert= ] [sys= ] [sort= ]
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements.
aggregate=yes|no
insert=filename List SQL statements and data inside INSERT statements.
sys=no TKPROF does not list SQL statements run as user SYS.
record=filename Record non-recursive statements found in the trace file.
waits=yes|no Record summary for any wait events found in the trace file.
sort=option Set of zero or more of the following sort options:
prscnt number of times parse was called
……
tkprof可以運行了