在linux中oracle的sqlplus是没办法像linux的shell一样可以上下调回历史输入的。rlwrap就很好的解决了这个问题。rlwrap 可以用来支持Oracle下sqlplus历史命令的回调功能,提高效率。
rlwrap安装包下载地址:https://download.csdn.net/download/legend1001/1398158
详细步骤如下
挂镜像,查看包
[root@lzzh ~]# mount /dev/sr0 /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@lzzh ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 36G 28G 5.8G 83% /
tmpfs 2.0G 72K 2.0G 1% /dev/shm
/dev/sda1 190M 54M 126M 31% /boot
/dev/sdb1 79G 15G 60G 20% /data
/dev/sr0 3.7G 3.7G 0 100% /mnt
[root@lzzh ~]# cd /mnt/Packages/
[root@lzzh Packages]# ll readline*
-rw-r--r-- 1 root root 179804 May 15 2012 readline-6.0-4.el6.i686.rpm
-rw-r--r-- 1 root root 182124 May 15 2012 readline-6.0-4.el6.x86_64.rpm
-rw-r--r-- 1 root root 136912 May 15 2012 readline-devel-6.0-4.el6.i686.rpm
-rw-r--r-- 1 root root 136892 May 15 2012 readline-devel-6.0-4.el6.x86_64.rpm
安装相关的包
[root@lzzh Packages]# rpm -Uvh readline-6.0-4.el6.x86_64.rpm
warning: readline-6.0-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ########################################### [100%]
package readline-6.0-4.el6.x86_64 is already installed
[root@lzzh Packages]# rpm -Uvh readline-devel-6.0-4.el6.x86_64.rpm
warning: readline-devel-6.0-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
error: Failed dependencies:
ncurses-devel is needed by readline-devel-6.0-4.el6.x86_64
[root@lzzh Packages]# yum install -y readline-devel*
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Examining readline-devel-6.0-4.el6.i686.rpm: readline-devel-6.0-4.el6.i686
Marking readline-devel-6.0-4.el6.i686.rpm to be installed
Examining readline-devel-6.0-4.el6.x86_64.rpm: readline-devel-6.0-4.el6.x86_64
Marking readline-devel-6.0-4.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.i686 0:6.0-4.el6 will be installed
--> Processing Dependency: libhistory.so.6 for package: readline-devel-6.0-4.el6.i686
--> Processing Dependency: libreadline.so.6 for package: readline-devel-6.0-4.el6.i686
--> Processing Dependency: ncurses-devel for package: readline-devel-6.0-4.el6.i686
---> Package readline-devel.x86_64 0:6.0-4.el6 will be installed
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 will be installed
---> Package readline.i686 0:6.0-4.el6 will be installed
--> Processing Dependency: libc.so.6(GLIBC_2.3.4) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.4) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.1.3) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.1) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.0) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.11) for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6 for package: readline-6.0-4.el6.i686
--> Processing Dependency: libtinfo.so.5 for package: readline-6.0-4.el6.i686
--> Processing Dependency: libc.so.6(GLIBC_2.3) for package: readline-6.0-4.el6.i686
--> Running transaction check
---> Package glibc.i686 0:2.12-1.132.el6 will be installed
--> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.12-1.132.el6.i686
--> Processing Dependency: libfreebl3.so for package: glibc-2.12-1.132.el6.i686
---> Package ncurses-libs.i686 0:5.7-3.20090208.el6 will be installed
--> Running transaction check
---> Package nss-softokn-freebl.i686 0:3.14.3-9.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
readline-devel i686 6.0-4.el6 /readline-devel-6.0-4.el6.i686 255 k
readline-devel x86_64 6.0-4.el6 /readline-devel-6.0-4.el6.x86_64 255 k
Installing for dependencies:
glibc i686 2.12-1.132.el6 rhel-source 4.3 M
ncurses-devel x86_64 5.7-3.20090208.el6 rhel-source 643 k
ncurses-libs i686 5.7-3.20090208.el6 rhel-source 250 k
nss-softokn-freebl i686 3.14.3-9.el6 rhel-source 146 k
readline i686 6.0-4.el6 rhel-source 176 k
Transaction Summary
=======================================================================================
Install 7 Package(s)
Total size: 6.0 M
Total download size: 5.5 M
Installed size: 17 M
Is this ok [y/N]: y
Downloading Packages:
---------------------------------------------------------------------------------------
Total 33 MB/s | 5.5 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : nss-softokn-freebl-3.14.3-9.el6.i686 1/7
Installing : glibc-2.12-1.132.el6.i686 2/7
Installing : ncurses-libs-5.7-3.20090208.el6.i686 3/7
Installing : ncurses-devel-5.7-3.20090208.el6.x86_64 4/7
Installing : readline-6.0-4.el6.i686 5/7
Installing : readline-devel-6.0-4.el6.x86_64 6/7
Installing : readline-devel-6.0-4.el6.i686 7/7
Verifying : readline-devel-6.0-4.el6.x86_64 1/7
Verifying : ncurses-libs-5.7-3.20090208.el6.i686 2/7
Verifying : glibc-2.12-1.132.el6.i686 3/7
Verifying : readline-6.0-4.el6.i686 4/7
Verifying : readline-devel-6.0-4.el6.i686 5/7
Verifying : nss-softokn-freebl-3.14.3-9.el6.i686 6/7
Verifying : ncurses-devel-5.7-3.20090208.el6.x86_64 7/7
Installed:
readline-devel.i686 0:6.0-4.el6 readline-devel.x86_64 0:6.0-4.el6
Dependency Installed:
glibc.i686 0:2.12-1.132.el6 ncurses-devel.x86_64 0:5.7-3.20090208.el6
ncurses-libs.i686 0:5.7-3.20090208.el6 nss-softokn-freebl.i686 0:3.14.3-9.el6
readline.i686 0:6.0-4.el6
Complete!
[root@lzzh Packages]# rpm -Uvh readline-devel-6.0-4.el6.x86_64.rpm
warning: readline-devel-6.0-4.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ########################################### [100%]
package readline-devel-6.0-4.el6.x86_64 is already installed
上传并解压rlwrap-0.30.tar.tar
[root@lzzh Packages]#
[root@lzzh Packages]# cd /app/soft/
[root@lzzh soft]# ls
31720783 OPatch p31720783_112040_Linux-x86-64.zip p6880880_112000_Linux-x86-64.zip PatchSearch.xml rlwrap-0.30.tar.tar
[root@lzzh soft]#
[root@lzzh soft]# tar -zxvf rlwrap-0.30.tar.tar
rlwrap-0.30/
rlwrap-0.30/completions/
rlwrap-0.30/completions/ftp
rlwrap-0.30/completions/testclient
rlwrap-0.30/completions/coqtop
rlwrap-0.30/distribution/
rlwrap-0.30/distribution/rlwrap.spec.in
rlwrap-0.30/doc/
rlwrap-0.30/doc/rlwrap.man.in
rlwrap-0.30/doc/Makefile.am
rlwrap-0.30/doc/Makefile.in
rlwrap-0.30/src/
rlwrap-0.30/src/rlwrap.h
rlwrap-0.30/src/redblack.h
rlwrap-0.30/src/malloc_debug.h
rlwrap-0.30/src/completion.rb
rlwrap-0.30/src/Makefile.am
rlwrap-0.30/src/Makefile.in
rlwrap-0.30/src/main.c
rlwrap-0.30/src/signals.c
rlwrap-0.30/src/readline.c
rlwrap-0.30/src/pty.c
rlwrap-0.30/src/completion.c
rlwrap-0.30/src/term.c
rlwrap-0.30/src/ptytty.c
rlwrap-0.30/src/utils.c
rlwrap-0.30/src/string_utils.c
rlwrap-0.30/src/malloc_debug.c
rlwrap-0.30/test/
rlwrap-0.30/test/testclient
rlwrap-0.30/test/testit
rlwrap-0.30/tools/
rlwrap-0.30/tools/config.guess
rlwrap-0.30/tools/config.sub
rlwrap-0.30/tools/depcomp
rlwrap-0.30/tools/install-sh
rlwrap-0.30/tools/missing
rlwrap-0.30/tools/mkinstalldirs
rlwrap-0.30/README
rlwrap-0.30/configure.ac
rlwrap-0.30/aclocal.m4
rlwrap-0.30/Makefile.am
rlwrap-0.30/Makefile.in
rlwrap-0.30/config.h.in
rlwrap-0.30/configure
rlwrap-0.30/AUTHORS
rlwrap-0.30/COPYING
rlwrap-0.30/ChangeLog
rlwrap-0.30/INSTALL
rlwrap-0.30/NEWS
rlwrap-0.30/TODO
rlwrap-0.30/BUGS
开始配置并编译
[root@lzzh soft]# cd rlwrap-0.30
[root@lzzh rlwrap-0.30]# ll
total 380
-rw-rw-r-- 1 500 500 32266 Jan 8 2008 aclocal.m4
-rw-r--r-- 1 500 500 638 Aug 15 2006 AUTHORS
-rw-r--r-- 1 500 500 4740 Nov 10 2007 BUGS
-rw-r--r-- 1 500 500 105 Aug 10 2003 ChangeLog
drwxrwxrwx 2 500 500 4096 Jan 8 2008 completions
-rw-rw-r-- 1 500 500 5489 Jan 8 2008 config.h.in
-rwxr-xr-x 1 500 500 217282 Jan 8 2008 configure
-rw-r--r-- 1 500 500 9860 Jan 8 2008 configure.ac
-rw-r--r-- 1 500 500 17992 Aug 8 2006 COPYING
drwxrwxrwx 2 500 500 4096 Jan 8 2008 distribution
drwxrwxrwx 2 500 500 4096 Jan 8 2008 doc
-rw-r--r-- 1 500 500 1927 Nov 10 2007 INSTALL
-rw-r--r-- 1 500 500 436 Nov 10 2007 Makefile.am
-rw-rw-r-- 1 500 500 22987 Jan 8 2008 Makefile.in
-rw-r--r-- 1 500 500 11187 Jan 3 2008 NEWS
-rw-r--r-- 1 500 500 2745 Nov 10 2007 README
drwxrwxrwx 2 500 500 4096 Jan 8 2008 src
drwxrwxrwx 2 500 500 4096 Jan 8 2008 test
-rw-r--r-- 1 500 500 480 Nov 10 2007 TODO
drwxrwxrwx 2 500 500 4096 Jan 8 2008 tools
[root@lzzh rlwrap-0.30]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... (cached) yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /usr/bin/perl
checking for strip... strip
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for sys/wait.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses/term.h usability... yes
checking ncurses/term.h presence... yes
checking for ncurses/term.h... yes
checking whether term.h exists and compiles... yes
checking whether your getopt() correctly understands double colons in option string... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether gcc needs -traditional... no
checking return type of signal handlers... void
checking for getopt_long... yes
checking for select... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for sched_yield... yes
checking for getopt_long... (cached) yes
checking for setsid... yes
checking for isastream... yes
checking for mkstemp... yes
checking for system... yes
checking for readlink... yes
checking for setenv... yes
checking for putenv... yes
checking for openpty in -lutil... yes
checking for openpty... yes
checking for getpty... no
checking for grantpt... yes
checking for unlockpt... yes
checking for getpt... yes
checking for pty/tty type... checking pty.h usability... yes
checking pty.h presence... yes
checking for pty.h... yes
OPENPTY
configure: checking for pty ranges...
checking for tgetent... no
checking for tgetent in -lcurses... yes
checking for readline in -lreadline... yes
checking whether your readline knows about rl_set_screen_size... yes
checking whether your readline knows about rl_variable_value... yes
checking whether your readline knows about rl_readline_version... yes
Will rlwrap find command's working directory under /proc/<commands pid>/cwd? let's see...
checking for /proc/7011/cwd/configure.ac... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating distribution/rlwrap.spec
config.status: creating config.h
config.status: executing depfiles commands
Now do:
make (or gmake) to build rlwrap
make check for instructions how to test it
make install to install it
[root@lzzh rlwrap-0.30]# make
make all-recursive
make[1]: Entering directory `/app/soft/rlwrap-0.30'
Making all in doc
make[2]: Entering directory `/app/soft/rlwrap-0.30/doc'
sed -e 's#@DATADIR@#/usr/local/share#' rlwrap.man > rlwrap.1
make[2]: Leaving directory `/app/soft/rlwrap-0.30/doc'
Making all in src
make[2]: Entering directory `/app/soft/rlwrap-0.30/src'
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT signals.o -MD -MP -MF .deps/signals.Tpo -c -o signals.o signals.c
mv -f .deps/signals.Tpo .deps/signals.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT readline.o -MD -MP -MF .deps/readline.Tpo -c -o readline.o readline.c
mv -f .deps/readline.Tpo .deps/readline.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT pty.o -MD -MP -MF .deps/pty.Tpo -c -o pty.o pty.c
mv -f .deps/pty.Tpo .deps/pty.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT completion.o -MD -MP -MF .deps/completion.Tpo -c -o completion.o completion.c
mv -f .deps/completion.Tpo .deps/completion.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT term.o -MD -MP -MF .deps/term.Tpo -c -o term.o term.c
mv -f .deps/term.Tpo .deps/term.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT ptytty.o -MD -MP -MF .deps/ptytty.Tpo -c -o ptytty.o ptytty.c
mv -f .deps/ptytty.Tpo .deps/ptytty.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT utils.o -MD -MP -MF .deps/utils.Tpo -c -o utils.o utils.c
mv -f .deps/utils.Tpo .deps/utils.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c
mv -f .deps/string_utils.Tpo .deps/string_utils.Po
gcc -DHAVE_CONFIG_H -I. -I.. -DDATADIR=\"/usr/local/share\" -g -O2 -MT malloc_debug.o -MD -MP -MF .deps/malloc_debug.Tpo -c -o malloc_debug.o malloc_debug.c
mv -f .deps/malloc_debug.Tpo .deps/malloc_debug.Po
gcc -DDATADIR=\"/usr/local/share\" -g -O2 -o rlwrap main.o signals.o readline.o pty.o completion.o term.o ptytty.o utils.o string_utils.o malloc_debug.o -lutil -lreadline -lcurses
make[2]: Leaving directory `/app/soft/rlwrap-0.30/src'
make[2]: Entering directory `/app/soft/rlwrap-0.30'
make[2]: Leaving directory `/app/soft/rlwrap-0.30'
make[1]: Leaving directory `/app/soft/rlwrap-0.30'
[root@lzzh rlwrap-0.30]# make install
Making install in doc
make[1]: Entering directory `/app/soft/rlwrap-0.30/doc'
make[2]: Entering directory `/app/soft/rlwrap-0.30/doc'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/man/man1" || /bin/mkdir -p "/usr/local/share/man/man1"
/usr/bin/install -c -m 644 './rlwrap.1' '/usr/local/share/man/man1/rlwrap.1'
make[2]: Leaving directory `/app/soft/rlwrap-0.30/doc'
make[1]: Leaving directory `/app/soft/rlwrap-0.30/doc'
Making install in src
make[1]: Entering directory `/app/soft/rlwrap-0.30/src'
make[2]: Entering directory `/app/soft/rlwrap-0.30/src'
test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"
/usr/bin/install -c 'rlwrap' '/usr/local/bin/rlwrap'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/app/soft/rlwrap-0.30/src'
make[1]: Leaving directory `/app/soft/rlwrap-0.30/src'
make[1]: Entering directory `/app/soft/rlwrap-0.30'
make[2]: Entering directory `/app/soft/rlwrap-0.30'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/rlwrap" || /bin/mkdir -p "/usr/local/share/rlwrap"
/usr/bin/install -c -m 644 'completions/ftp' '/usr/local/share/rlwrap/ftp'
/usr/bin/install -c -m 644 'completions/testclient' '/usr/local/share/rlwrap/testclient'
/usr/bin/install -c -m 644 'completions/coqtop' '/usr/local/share/rlwrap/coqtop'
make[2]: Leaving directory `/app/soft/rlwrap-0.30'
make[1]: Leaving directory `/app/soft/rlwrap-0.30'
给sqlplus加上别名
[root@lzzh rlwrap-0.30]#
[root@lzzh rlwrap-0.30]# su - oracle
[oracle@lzzh ~]$ echo alias sqlplus=\'rlwrap sqlplus\' >> .bash_profile
[oracle@lzzh ~]$
[oracle@lzzh ~]$ echo alias rman=\'rlwrap rman\' >> .bash_profile
[oracle@lzzh ~]$
[oracle@lzzh ~]$
[oracle@lzzh ~]$ . .bash_profile
[oracle@lzzh ~]$ sqlplus / as sysdba
最后修改时间:2022-07-21 17:36:52
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
Oracle SQL 执行计划分析与优化指南
Digital Observer
446次阅读
2025-04-01 11:08:44
Oracle 加密不求人:一篇文章教你搞定 TDE
Digital Observer
276次阅读
2025-04-09 15:31:52
Oracle闪回时间旅行(Flashback Time Travel)详解
听见风的声音
204次阅读
2025-04-22 09:20:04
Oracle 10G DG 修复从库-磁盘空间爆满导致从库无法工作
Albert Tan DBA 之路
173次阅读
2025-03-27 16:52:57
Oracle 和 Google Cloud 深化合作伙伴关系
甲骨文中国
162次阅读
2025-04-22 10:12:21
Oracle 11g RAC手动打补丁详细步骤
Digital Observer
97次阅读
2025-04-20 21:12:42
Google Cloud 与 Oracle 合作推出数据库合作伙伴计划
通讯员
86次阅读
2025-04-10 10:22:20
记一次watchdog引起的Oracle数据库异常
Digital Observer
72次阅读
2025-04-01 09:59:38
赴瑞士参加数据库会议
oracleace
53次阅读
2025-04-01 18:30:32
使用zabbix监控oracle数据库
怀念和想念
49次阅读
2025-04-05 16:36:09