您的位置:首页 > 数据库 > Oracle

linux配置oracle客户端,sqlplus、sqlldr、exp、imp

2013-08-06 16:42 281 查看

一、配置环境

 需要在安装有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.4.0

instantclient-jdbc-linux.x64-11.2.0.4.0

instantclient-sdk-linux.x64-11.2.0.4.0

instantclient-sqlplus-linux.x64-11.2.0.4.0

四、配置

配置各个功能都一样,关键是环境变量的配置,根据自己实际情况配置。

[b]1、配置sqlplus[/b]
root用户登录,创建目录并赋权给oracle用户:

[root@localhost /]# mkdir /s01

[root@localhost /]# chown oracle:oinstall /s01



使用oracle用户创建目录app/oracle,最后的目录结构为/s01/app/oracle



将所有软件包解压缩至/s01/app/oracle下,所有文件将自动释放至目录/s01/app/oracle/instantclient_11_2/下



创建文件/s01/app/oracle/instantclient_11_2/tnsnames.ora
格式如下:

ljyh =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.55.15.244)(PORT = 1521)) #需要连接的IP,端口

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = ljyh) #需要连接的实例

    )

  )

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )



在需要使用oracle功能的测试用户环境变量中,添加如下配置,这里一定要注意,如果你失败了百分之八十都是这里的问题: 
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

export ORACLE_IC_HOME=/s01/app/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



生效后,测试sqlplus:
这里报了个错,没有执行权限,所以赋予了个执行权限





[oracle@localhost ~]$ source .bash_profile 

[oracle@localhost ~]$ sqlplus

-bash: /s01/app/oracle/instantclient_11_2/sqlplus: 权限不够

[oracle@localhost ~]$ chmod +x /s01/app/oracle/instantclient_11_2/sqlplus 

[oracle@localhost ~]$ sqlplus fdm/fdm@ljyh

SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 6 12:30:11 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

Ok,sqlplus工具可以使用了;
[b]2、配置tnsping[/b]
下面我们在此基础上增加tnsping工具
在其他装有相同版本Oracle的机器上获取必要的文件:
一、先获取到本地电脑
1.tnsping文件
2.mesg整个文件夹(network下的mesg,上传也是上传到network下)





二、新建network文件夹
[oracle@localhost instantclient_11_2]$ mkdir network



上传到我们的客户端





下面测试一下tnsping工具



Ok,tnsping能正确运行了!
[b]3.配置sqlldr[/b]
Oracle的instanct_client没有自带sqlldr工具,也要单独获取相关的文件:
一、获取文件
1.sqlldr
2.mesg(rdbms下的mesg,上传也是上传到rdbms下)





二、新建rdbms文件夹
[oracle@localhost instantclient_11_2]$ mkdir rdbms



上传文件到客户端





运行sqlldr:



Sqlldr工具可以运行了
[b]4、配置imp、exp[/b]
一、获取相关文件





二、上传文件



运行imp和exp



Ok!
[b]5、配置tkprof[/b]
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可以运行了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Oracle sqlplus sqlldr exp imp