RHEL自动安装Zookeeper的shell脚本(2)

# output array to one line string: echo ${servers[@]}
    # get length of array
    len=${#servers[*]}
    i=0
    while [ $i -lt $len ]
    do
        let sid=i+1
        destip=${ipaddrs[$i]}
        destlogin=root@$destip
        echo -e "<INFO> configuring server.$sid: $destip ...\c"

ret=`ssh $destlogin "yum install -y zookeeper zookeeper-server && service zookeeper-server init --myid=$sid"`

ret=`ssh $destlogin "echo '#!{{install_zookeeper@hgdb.net==>' >> $ZOO_CFG"`

for s in ${servers[*]}
        do
            ret=`ssh $destlogin "echo '$s' >> $ZOO_CFG"`
        done

ret=`ssh $destlogin "echo '#!<==install_zookeeper@hgdb.net}}' >> $ZOO_CFG"`

echo -e "OK."

let i++
    done

echo "<INFO> zookeeper cluster installation completed successfully!"
}

#=======================================================================
install_zookeeper "2181" "192.168.122.201" "192.168.122.202" "192.168.122.203"

根据配置修改最后一行:

install_zookeeper "2181" "192.168.122.201" "192.168.122.202" "192.168.122.203"

注意:需要把zk-cluster的每台机器上的防火墙停掉,再启动zookeeper:

$ /usr/lib/zookeeper/bin/zkServer.sh start-foreground

--------------------------------------分割线 --------------------------------------

ZooKeeper集群配置

使用ZooKeeper实现分布式共享锁

分布式服务框架 ZooKeeper -- 管理分布式环境中的数据

ZooKeeper集群环境搭建实践

ZooKeeper服务器集群环境配置实测

ZooKeeper集群安装

--------------------------------------分割线 --------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/17096.html