1、xsync同步数据
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
if((pcount==$#)); then
echo 没有参数;
exit;
fi
#2 获取文件名称
p1=$1
file_name=`basename $p1`
echo file_name=$file_name
#3 获取上级目录到绝对路径
work_path=`cd -P $(dirname $p1); pwd`
echo work_path=$work_path
#4 获取当前用户名称
user=`whoami`
#5 获取自己的hostname
hostname=`hostname`
#6 设置网段
network_segment="192.168"
#7 遍历host文件,排除自己和不在指定网段的主机
while read -r line
do
if [[ $line != *$hostname* && $line == *$network_segment* ]]
then
array=(${line// / })
other_hostname=${array[1]}
echo --------------- $other_hostname ----------------
rsync -rvl $work_path/$file_name $user@$other_hostname:$work_path
fi
done < /etc/hosts
2、xcall分发命令
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
if((pcount==$#)); then
echo 没有参数;
exit;
fi
hostnames="linux101 linux102 linux103"
for hostname in hostnames
do
echo --------------- $hostname ----------------
ssh $hostname $@
done
测试xcall jps时会出现,jps命令-bash: jps: command not found情况,这是因为$PATH不一致导致。需要将在/etc/profile里面的环境变量追加到~/.bashrc中。
cat /etc/profile >> ~/.bashrc
3、zkServer
群起zookeeper集群,以及停止或者查询状态
#/bin/bash
case $1 in
"start"){
xcall "$ZOOKEEPER_HOME/bin/zkServer.sh start"
};;
"stop"){
xcall "$ZOOKEEPER_HOME/bin/zkServer.sh stop"
};;
"status"){
xcall "$ZOOKEEPER_HOME/bin/zkServer.sh status"
};;
esac
4、kafkaServer
#/bin/bash
case $1 in
"start"){
xcall "$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties"
};;
"stop"){
xcall "$KAFKA_HOME/bin/kafka-server-stop.sh stop"
};;
esac
5、spark
TODO