在Linux平台下,想在Oracle数据库的SQL*PLUS的命令行提示符下,利用键盘上的上下箭头,调出历史执行的SQL命令,可以考虑采用rlwrap这一开源工具。
现,简单记录一下安装过程(Red Hat Enterprise Linux as 5.4环境)。以前在4版本的操作系统上安装时很顺利,就不再记录。
①解压并安装rlwrap工具:
01 [root@server1 ~]# tar -zxvf rlwrap-0.30.tar.gz
07 [root@server1 ~]# cd rlwrap-0.30 && ll
11 -rw-rw-r-- 1 hekan hekan 32266 Jan 8 2008 aclocal.m4
13 -rw-r--r-- 1 hekan hekan 638 Aug 15 2006 AUTHORS
15 -rw-r--r-- 1 hekan hekan 4740 Nov 10 2007 BUGS
17 -rw-r--r-- 1 hekan hekan 105 Aug 10 2003 ChangeLog
19 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 completions
21 -rw-rw-r-- 1 hekan hekan 5489 Jan 8 2008 config.h.in
23 -rwxr-xr-x 1 hekan hekan 217282 Jan 8 2008 configure
25 -rw-r--r-- 1 hekan hekan 9860 Jan 8 2008 configure.ac
27 -rw-r--r-- 1 hekan hekan 17992 Aug 8 2006 COPYING
29 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 distribution
31 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 doc
33 -rw-r--r-- 1 hekan hekan 1927 Nov 10 2007 INSTALL
35 -rw-r--r-- 1 hekan hekan 436 Nov 10 2007 Makefile.am
37 -rw-rw-r-- 1 hekan hekan 22987 Jan 8 2008 Makefile.in
39 -rw-r--r-- 1 hekan hekan 11187 Jan 3 2008 NEWS
41 -rw-r--r-- 1 hekan hekan 2745 Nov 10 2007 README
43 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 src
45 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 test
47 -rw-r--r-- 1 hekan hekan 480 Nov 10 2007 TODO
49 drwxrwxrwx 2 hekan hekan 4096 Jan 8 2008 tools
51 [root@server1 rlwrap-0.30]# ./configure
55 checking for tgetent... no
57 checking for tgetent in -lcurses... no
59 checking for tgetent in -lncurses... no
61 checking for tgetent in -ltermcap... no
63 configure: WARNING: No termcap nor curses library found
65 checking for readline in -lreadline... no
69 You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build
73 [root@server1 rlwrap-0.30]#
报错!提示需要安装readline-devel-5.1-1.1.i386.rpm包。 ② 安装readline-devel-5.1-1.1.i386.rpm 包:
1 [root@server1 ~]# rpm -ivh readline-devel-5.1-1.1.i386.rpm
3 warning: readline-devel-5.1-1.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
5 error: Failed dependencies:
7 libtermcap-devel is needed by readline-devel-5.1-1.1.i386
又报错提示缺失libtermcap-devel包!
继续安装:
01 [root@server1 ~]# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm
03 warning: libtermcap-devel-2.0.8-46.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
05 Preparing... ########################################### [100%]
07 1:libtermcap-devel ########################################### [100%]
09 [root@server1 ~]# rpm -ivh readline-devel-5.1-1.1.i386.rpm
11 warning: readline-devel-5.1-1.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
13 Preparing... ########################################### [100%]
15 1:readline-devel ########################################### [100%]
17 [root@server1 ~]# cd rlwrap-0.30
19 [root@server1 rlwrap-0.30]# ./configure
21 checking build system type... i686-pc-linux-gnu
23 checking host system type... i686-pc-linux-gnu
25 checking for a BSD-compatible install... /usr/bin/install-c
27 checking whether build environment is sane... yes
29 checking for a thread-safe mkdir -p... /bin/mkdir -p
31 checking for gawk... gawk
33 checking whether make sets $(MAKE)... yes
39 configure: creating ./config.status
41 config.status: creating Makefile
43 config.status: creating doc/Makefile
45 config.status: creating src/Makefile
47 config.status: creating doc/rlwrap.man
49 config.status: creating distribution/rlwrap.spec
51 config.status: creating config.h
53 config.status: executing depfiles commands
57 make (or gmake) to build rlwrap
59 make check for instructions how to test it
61 make install to install it
63 [root@server1 rlwrap-0.30]#
③ 根据执行执行,make,make install:
01 [root@server1 rlwrap-0.30]# make
07 [root@server1 rlwrap-0.30]# make install
13 make[2]: Leaving directory `/root/rlwrap-0.30'
15 make[1]: Leaving directory `/root/rlwrap-0.30'
17 [root@server1 rlwrap-0.30]#
④ 修改oracle 用户的配置文件,
5 [oracle@server1 ~]$ vi .bash_profile
在其中,添加类似配置信息:
1 alias sqlplus='rlwrap sqlplus /nolog'
⑤至此,oracle在SHELL提示符下,只需要执行sqlplus就可以进入SQL*PLUS的命令行提示符,并且可以利用键盘的上下箭头调出之前执行过的历史命令。
这是在RHEL 5.4版本的操作系统上安装时的简单记录,而之前没遇到过类似的问题,故简单记录之。
即先安装libtermcap-devel-2.0.8-46.1.i386.rpm
然后安装 readline-devel-5.1-1.1.i386.rpm
最后安装rlwrap工具包。