rlwrap项目是一个“readline包装器”,它使用GNU readline库来编辑任何其他命令的键
盘输入。通过rlwrap可以进行命令的上下切换,类似历史命令。
1、下载rlwrap rpm
rlwrap rpm包可以通过:https://centos.pkgs.org/ 获取
安装这个包可以解决下面截图问题
rlwrap能解决方向键上下切换历史执行的sql,左右方向键乱码的问题可以通过shell终端解决,比如xshell方法如下:
2、安装rlwrap
[root@oracle ~]# rpm -ivh rlwrap-0.43-2.el7.x86_64.rpm
warning: rlwrap-0.43-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
error: Failed dependencies:
/usr/bin/python3.6 is needed by rlwrap-0.43-2.el7.x86_64
perl(Data::Dumper) is needed by rlwrap-0.43-2.el7.x86_64
[root@oracle ~]# yum install perl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 4:perl-5.16.3-291.el7.x86_64 already installed and latest version
Nothing to do
centos7对应的是0.43版本,但是安装时提示需要py3.6和perl两个依赖包,perl已经安装,py版本是2.7
先解决perl问题:
[root@oracle ~]# yum -y install autoconf Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.69-11.el7 will be installed --> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch --> Processing Dependency: perl(Data::Dumper) for package: autoconf-2.69-11.el7.noarch --> Running transaction check ---> Package m4.x86_64 0:1.4.16-10.el7 will be installed ---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================ Installing: autoconf noarch 2.69-11.el7 centos-source 701 k Installing for dependencies: m4 x86_64 1.4.16-10.el7 centos-source 256 k perl-Data-Dumper x86_64 2.145-3.el7 centos-source 47 k Transaction Summary ============================================================================================================================================================================================ Install 1 Package (+2 Dependent packages) Total download size: 1.0 M Installed size: 2.8 M Downloading packages: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 65 MB/s | 1.0 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. ** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows: ipa-client-4.4.0-12.el7.centos.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.centos.x86_64 ipa-client-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.centos.noarch ipa-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.centos.noarch Installing : m4-1.4.16-10.el7.x86_64 1/3 Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/3 Installing : autoconf-2.69-11.el7.noarch 3/3 Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 1/3 Verifying : m4-1.4.16-10.el7.x86_64 2/3 Verifying : autoconf-2.69-11.el7.noarch 3/3 Installed: autoconf.noarch 0:2.69-11.el7 Dependency Installed: m4.x86_64 0:1.4.16-10.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 Complete! [root@oracle ~]# rpm -ivh rlwrap-0.43-2.el7.x86_64.rpm warning: rlwrap-0.43-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: /usr/bin/python3.6 is needed by rlwrap-0.43-2.el7.x86_64 [root@oracle ~]#
在网上查资料,发现centos6用的0.42版本也能安装,测试下:
[root@oracle ~]# rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm warning: rlwrap-0.42-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ################################# [100%] Updating / installing... 1:rlwrap-0.42-1.el6 ################################# [100%] [root@oracle ~]#
OK了!
3、配置环境变量
切换到oracle用户,编辑.bash_profile增加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias lsnrctl='rlwrap lsnrctl'
[oracle@oracle ~]$ . .bash_profile
4、测试下