赞
踩
相关文章链接: 大数据基础知识点 文章汇总
在 /root/bin 目录下,执行 vim xcall.sh 命令,如下图所示:
脚本内容如下:
- #!/bin/bash
-
- # 获取控制台指令
-
- cmd=$*
-
- # 判断指令是否为空
- if [ ! -n "$cmd" ]
- then
- echo "command can not be null !"
- exit
- fi
-
- # 获取当前登录用户
- user=`whoami`
-
- # 在从机执行指令,这里需要根据你具体的集群情况配置,host与具体主机名一致,同上
- for (( host=1;host<=3;host++ ))
- do
- echo "================current host is bigdata$host================="
- echo "--> excute command \"$cmd\""
- ssh $user@bigdata$host $cmd
- done
-
- echo "excute successfully !"

给脚本授权:
chmod 777 xcall.sh
执行之后如下图所示:
注:其他相关文章链接由此进 -> 大数据基础知识点 文章汇总
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。