echo "#######请输入操作命令:########"
echo "###输入start是开启|stop 关闭###"
echo "################################"
read -p "请输入redis进程选项:" input
 
if [ $input == start ];then
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7000/redis.conf
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7001/redis.conf
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7002/redis.conf
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7003/redis.conf
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7004/redis.conf
    /data/redis-5.0.3/src/redis-server /data/redis-5.0.3/redis_cluster/7005/redis.conf
#    red=`ps -ef | grep redis| grep  cluster] | awk '{print $2}' | wc -l`
    if [ `ps -ef | grep redis| grep  cluster] | awk '{print $2}' | wc -l` -eq 6 ];then
        echo "开启成功,进入创建集群。。。"
        sleep 5
        redis-cli --cluster create 192.168.1.4:7000 192.168.1.4:7001 192.168.1.4:7002  192.168.1.4:7003 192.168.1.4:7004 192.168.1.4:7005 --cluster-replicas 1
    else
        echo "开启redis服务有问题请检测"
    fi
elif [ $input == stop ];then
   for i in `ps -ef | grep redis| grep  cluster] | awk '{print $2}'`
     do
        echo "$i 被kill掉"
        kill -9 $i
        re=`ps -ef | grep redis| grep  cluster] | awk '{print $2}' | wc -l`
        echo "$re"
     done
    ps -ef | grep redis| grep  cluster]
    red=`echo $?`
    if [ $red !=  0 ];then
       echo "redis 停用了---ok"
 
    else
        echo "not ok"
    fi
else
   echo "输入错误退出!"
   exit
 
fi