sqlplus rlwrap: error: Cannot execute sqlplus: Too many levels of symbolic lin

 循环查找变量,which sqlplus 看一下就好了

[20200309]rlwrap: error: Cannot execute sqlplus: Too many levels of symbolic links.txt

--//同事安装安装oracle以及rlwrap在centos 7时遇到的问题。再测试环境重复演示:
$ alias sql='rlwrap sqlplus'
$ sql
rlwrap: error: Cannot execute sqlplus: Too many levels of symbolic links

--//看了安装文档,不知道为什么要执行如下步骤:
cd ~
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

--//有两者可能:1.当时环境变量$ORACLE_HOME没有定义。 2.命令在root用户下执行,ORACLE_HOME环境变量不存在。实际上这步多余
--//的,只要定义环境变量PATH中包括$ORACLE_HOME/bin就ok了。

1.演示看看。
--//我以root执行:。
# echo $ORACLE_HOME
# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

--//这样实际上相当于执行:
ln -s /bin/sqlplus /usr/bin

# ls -l /usr/bin/sqlplus
lrwxrwxrwx. 1 root root 12 Mar  9 11:52 /usr/bin/sqlplus -> /bin/sqlplus

# ls -l /bin/sqlplus
lrwxrwxrwx. 1 root root 12 Mar  9 11:52 /bin/sqlplus -> /bin/sqlplus
--//经典的环,为什么会出现这样的情况呢?

--//而实际上centos的低版本rhel 5.9:
$ ls -l /
total 206
drwxr-xr-x    2 root   root      4096 2013-03-22 04:14:17 bin
drwxr-xr-x    4 root   root      1024 2007-07-06 15:37:45 boot
drwxrwxrwx   14 oracle oinstall  4096 2017-12-21 11:27:38 data
drwxr-xr-x    8 root   root      5420 2020-03-08 04:03:06 dev
drwxr-xr-x  106 root   root     12288 2020-03-06 04:03:45 etc
drwxr-xr-x    5 root   root      4096 2014-11-05 09:49:05 home
drwxr-xr-x    2 root   root      4096 2004-08-13 01:02:09 initrd
drwxr-xr-x   10 root   root      4096 2007-07-06 17:01:29 lib
drwxr-xr-x    7 root   root      4096 2013-03-22 04:10:12 lib64
drwx------    2 root   root     16384 2007-07-06 23:26:01 lost+found
drwxr-xr-x    4 root   root      4096 2018-01-05 16:29:27 media
drwxr-xr-x    2 root   root      4096 2005-12-02 23:40:17 misc
drwxr-xr-x   12 root   root      4096 2017-12-25 16:20:36 mnt
drwxr-xr-x    4 root   root      4096 2017-01-17 09:39:43 opt
dr-xr-xr-x  133 root   root         0 2018-01-06 00:26:17 proc
drwxr-x---   24 root   root      4096 2020-02-27 11:47:03 root
drwxr-xr-x    3 root   root     12288 2014-07-29 04:03:56 sbin
drwxr-xr-x    2 root   root      4096 2007-07-06 15:26:28 selinux
drwxr-xr-x    2 root   root      4096 2004-08-13 01:02:09 srv
drwxr-xr-x    9 root   root         0 2018-01-06 00:26:17 sys
drwxr-xr-x    3 root   root      4096 2014-07-14 11:28:17 tftpboot
drwxrwxrwt    8 root   root     20480 2020-03-09 15:43:54 tmp
drwxr-xr-x    5 root   root      4096 2017-02-07 15:33:55 u01
drwxr-xr-x   18 root   root      4096 2011-04-14 19:02:34 usr
drwxr-xr-x   26 root   root      4096 2012-03-15 14:53:16 var

--//而centos 7呢?
# ls -l /
total 32
lrwxrwxrwx.   1 root   root        7 Feb 25 07:20 bin -> usr/bin
dr-xr-xr-x.   5 root   root     4096 Feb 25 07:29 boot
drwxr-xr-x.  20 root   root     3260 Mar  2 05:43 dev
drwxr-xr-x.  92 root   root     8192 Mar  2 05:43 etc
drwxr-xr-x.   3 root   root       99 Feb 26 13:15 home
lrwxrwxrwx.   1 root   root        7 Feb 25 07:20 lib -> usr/lib
lrwxrwxrwx.   1 root   root        9 Feb 25 07:20 lib64 -> usr/lib64
drwxr-xr-x.   2 root   root        6 Jun  9  2014 media
drwxr-xr-x.   2 root   root        6 Jun  9  2014 mnt
drwxr-xr-x.   3 root   root       21 Feb 27 06:47 opt
dr-xr-xr-x. 412 root   root        0 Mar  2 05:43 proc
dr-xr-x---.   2 root   root     4096 Feb 27 05:43 root
drwxr-xr-x.  24 root   root      720 Mar  9 08:04 run
lrwxrwxrwx.   1 root   root        8 Feb 25 07:20 sbin -> usr/sbin
drwxr-xr-x.   2 root   root        6 Jun  9  2014 srv
dr-xr-xr-x.  13 root   root        0 Mar  2 05:43 sys
drwxrwxrwt.   9 root   root     4096 Mar  9 11:40 tmp
drwxr-xr-x.   3 oracle oinstall   16 Feb 26 13:16 u01
drwxr-xr-x.  13 root   root     4096 Feb 25 07:20 usr
drwxr-xr-x.  20 root   root     4096 Mar  2 05:43 var
--//注意看centos 7 根目录下的/bin ,/sbin, /lib /lib64目录都是软链接,注意看真实链接的目录。
--//而且定义PATH一般都是在后面追加。centos 7下PATH定义如下:
$ echo -e ${PATH//:/\\n}
/usr/local/bin
/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/home/oracle/.local/bin
/home/oracle/bin
/home/oracle/bin
/home/oracle/bin
/u01/app/oracle/product/11.2.0/db_1/bin

--//这样找到sqlplus在/bin目录,这样找到的sqlplus就形成一个环。
# ls -l /bin/sqlplus
lrwxrwxrwx. 1 root root 12 Mar  9 11:52 /bin/sqlplus -> /bin/sqlplus

--//也就是在低版本就算定义错误,也不可能报如上错误。而正是centos 7版本的这点点改进,导致问题暴露出来。
--//如果我手工定义PATH如下:
export PATH=/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/bin:/usr/bin:/usr/sbin:/home/oracle/bin

$ sqlplus / as sysdba
--//就可以正常使用。
--//总之,任何安装版本都会有一小小改进。

--//补充rhel 5.9的测试:

# echo $ORACLE_HOME

# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
# ls -l /usr/bin/sqlplus
lrwxrwxrwx 1 root root 12 2020-03-09 15:33:18 /usr/bin/sqlplus -> /bin/sqlplus
# ls -l /bin/sqlplus
ls: /bin/sqlplus: No such file or directory

--//看不到前面的环。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值