得之坦然,失之淡然,争其必然,顺其自然!
分类: Oracle
2012-08-03 11:56:53
Linux CentOS release 6.2 x86_64
需要在安装有oracle软件的相同操作系统上获取部分oracle的系统文件
二、配置目标无需安装oracle服务器或客户端软件,达到能使用以下功能的目标:
Ø oci、occi、jdbc的支持
Ø tnsping
Ø sqlplus
Ø sqlldr
Ø exp
Ø imp
Ø tkprof
三、软件下载在网站下载如下package:
basic-10.2.0.4.0-linux-x86_64.zip
jdbc-10.2.0.4.0-linux-x86_64.zip
sdk-10.2.0.4.0-linux-x86_64.zip
sqlplus-10.2.0.4.0-linux-x86_64.zip
四、配置步骤 1、配置sqlplus
root用户登录,创建目录:
# mkdir -p /opt/oracle
将所有软件包解压缩至/opt/oracle/下,所有文件将自动释放至目录/opt/oracle/instantclient_10_2/下
创建文件/opt/oracle/instantclient_10_2/tnsnames.ora
格式如下:
ORA16 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.21.16)(PORT = 1521))
)
(CONNECT_DATA =
(SID = orcl)
(SERVER = DEDICATED)
)
)
在需要使用oracle功能的测试用户环境变量中,添加如下配置:
export ORACLE_HOME=/opt/oracle
export LANG="zh_CN.GBK"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
ORACLE_IC_HOME=/opt/oracle/instantclient_10_2
ORACLE_HOME=$ORACLE_IC_HOME
TNS_ADMIN=$ORACLE_IC_HOME
PATH=$PATH:$ORACLE_IC_HOME
LD_LIBRARY_PATH=$ORACLE_IC_HOME
export ORACLE_IC_HOME ORACLE_HOME TNS_ADMIN PATH LD_LIBRARY_PATH
生效后,测试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 ./
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可以运行了