linux删除无效链接

2019-03-27  本文已影响0人  冰T弦

最近在安装CM和CDH的时候遇到了很多问题,因为之前安装了5.16.1版本,可能没有清理干净,这次重新安装了6.0.1,在主节点上发现很多命令不好用,但是从节点上可以;
于是在两个节点上对比发现主节点上有些连接已经过时了,指向的还是旧地址,于是想先把所有的失效连接删除掉,用root用户进入到/etc/alternatives下:

[root@node1 alternatives]# for a in `find . -type l`; do stat -L $a >/dev/null 2>/dev/null; if [ $? -gt 0 ]; then rm -rf $a; fi; done

然后在从节点上通过which命令进行查找,找到命令对应的链接,然后在主节点上建立。
主节点上使用yarn命令提示找不到yarn命令:

[puser@node1 ~]$ yarn application --list
-bash: yarn: command not found

在从节点上查看对应的链接信息:

[puser@node2 ~]$ which yarn
/usr/bin/yarn
[puser@node2 ~]$ ll /usr/bin/yarn
lrwxrwxrwx 1 root root 22 Mar 25 18:23 /usr/bin/yarn -> /etc/alternatives/yarn
[puser@node2 ~]$ ll /etc/alternatives/yarn
lrwxrwxrwx 1 root root 61 Mar 25 18:23 /etc/alternatives/yarn -> /opt/cloudera/parcels/CDH-6.0.1-1.cdh6.0.1.p0.590678/bin/yarn
[puser@node2 ~]$ ll /opt/cloudera/parcels/CDH-6.0.1-1.cdh6.0.1.p0.590678/bin/yarn
-rwxr-xr-x 1 root root 677 Sep 20  2018 /opt/cloudera/parcels/CDH-6.0.1-1.cdh6.0.1.p0.590678/bin/yarn

回到主节点上进行创建:

[root@node1 alternatives]# ln -s /opt/cloudera/parcels/CDH-6.0.1-1.cdh6.0.1.p0.590678/bin/yarn yarn
[root@node1 alternatives]# ll yarn
lrwxrwxrwx 1 root root 61 Mar 27 11:43 yarn -> /opt/cloudera/parcels/CDH-6.0.1-1.cdh6.0.1.p0.590678/bin/yarn
[root@node1 alternatives]# ll /usr/bin/yarn
lrwxrwxrwx 1 root root 22 Mar 25 18:23 /usr/bin/yarn -> /etc/alternatives/yarn
上一篇下一篇

猜你喜欢

热点阅读