参数 $* : 表示把输入的所有当成参数
1)在/usr/local/bin目录下创建脚本xcall [sea@hadoop102 bin]$ vim xcall 2)在脚本中编写如下内容:
#!/bin/bash
for i in hadoop001 hadoop002 hadoop003
do
echo --------- $i ----------
ssh hadoop@$i "source /etc/profile;$*"
done
3)修改脚本执行权限 [sea@hadoop102 bin]$ chmod 777 xcall 4)启动脚本 [sea@hadoop102 bin]$ xcall.sh jps
hadoop@hadoop001:/soft/softinstall/hbase-1.3.6/bin$ xcall jps
--------- hadoop001 ----------
15456 Jps
2880 JobHistoryServer
2242 NameNode
14472 HRegionServer
1977 QuorumPeerMain
18457 Kafka
2699 NodeManager
14285 HMaster
--------- hadoop002 ----------
30933 Kafka
18325 HRegionServer
5657 QuorumPeerMain
6062 NodeManager
26254 Jps
5935 ResourceManager
--------- hadoop003 ----------
21094 NodeManager
18056 Kafka
1736 Jps
20554 QuorumPeerMain
20715 DataNode
829 HRegionServer
20830 SecondaryNameNode