在bin目录下创建集群命令批量执行脚本xcall:
#! /bin/bash
for i in hadoop102 hadoop103 hadoop104
do
echo --------- $i ----------
ssh $i "$*"
done
修改命令权限:
chmod 777 xcall
在执行xcall jps命令时报错:
zs@hadoop102:~$ xcall jps
--------- hadoop102 ----------
bash: line 1: jps: command not found
--------- hadoop103 ----------
bash: line 1: jps: command not found
--------- hadoop104 ----------
bash: line 1: jps: command not found
解决方案(需要在3台虚拟机上都执行一次):
1.切换root用户
su root
2.创建符号链接‘
ln -s jps的路径 链接目标存放位置
ln -s /opt/module/jdk-1.8.0/bin/jps /usr/local/bin/jps
解决!
zs@hadoop102:~$ xcall jps
--------- hadoop102 ----------
7902 Jps
--------- hadoop103 ----------
7197 Jps
--------- hadoop104 ----------
6780 Jps
参考:报错“bash: jps: command not found” - Lucas_zhao - 博客园 (cnblogs.com)