首页 > 代码库 > 搭建zookeeper集群

搭建zookeeper集群

三台服务器:先设置hosts10.0.0.231  node110.0.0.232  node210.0.0.233  node3
1:解压 zookeeper-3.4.10.tar.gz 到/usr/local2:创建软链接 到/usr/local/zk3:复制zk/conf/zoo_sample.cfg 为zoo.cfg4:修改zoo.cfg内容为tickTime=2000initLimit=10syncLimit=5dataDir=/opt/zookeeperclientPort=2181server.1=node1:2888:3888server.2=node2:2888:3888server.3=node3:2888:3888

5:在/opt/下创建
zookeeper文件夹
6:在/opt/zookeeper下创建myid文件,内容为1

以上三台服务器的配制除了myid内容不一样其它全部相同

10.0.0.231  myid内容为110.0.0.232  myid内容为210.0.0.233  myid内容为3

最后分别到bin目录中启动zookeeper

zkServer.sh start

设置开机自动启动

1) 切换到/etc/rc.d/init.d/目录下2) 创建zookeeper文件:touch zookeeper3) 更新权限:chmod +x zookeeper4) 编辑文件,在zookeeper里面输入如下内容   #!/bin/bash   #chkconfig:2345 20 90   #description:zookeeper   #processname:zookeeper    export JAVA_HOME=/usr/local/jdk    export PATH=$JAVA_HOME/bin:$PATH    case $1 in          start) /usr/local/zk/bin/zkServer.sh start;;          stop) /usr/local/zk/bin/zkServer.sh stop;;          status) /usr/local/zk/bin/zkServer.sh status;;          restart) /usr/local/zk/bin/zkServer.sh restart;;          *)  echo "require start|stop|status|restart" ;;    esac5) chkconfig zookeeper on6) 验证chkconfig --add zookeeper  把zookeeper添加到开机启动里面chkconfig --list zookeeper 查看是否添加的zookeeper到开机启动

 

搭建zookeeper集群