三台服务器:先设置hosts 10.0.0.231 node1 10.0.0.232 node2 10.0.0.233 node3
1:解压 zookeeper-3.4.10.tar.gz 到/usr/local 2:创建软链接 到/usr/local/zk 3:复制zk/conf/zoo_sample.cfg 为zoo.cfg 4:修改zoo.cfg内容为 tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zookeeper clientPort=2181 server.1=node1:2888:3888 server.2=node2:2888:3888 server.3=node3:2888:3888
5:在/opt/下创建zookeeper文件夹
6:在/opt/zookeeper下创建myid文件,内容为1
以上三台服务器的配制除了myid内容不一样其它全部相同
10.0.0.231 myid内容为1 10.0.0.232 myid内容为2 10.0.0.233 myid内容为3
最后分别到bin目录中启动zookeeper
zkServer.sh start
设置开机自动启动
1) 切换到/etc/rc.d/init.d/目录下 2) 创建zookeeper文件:touch zookeeper 3) 更新权限:chmod +x zookeeper 4) 编辑文件,在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" ;; esac 5) chkconfig zookeeper on 6) 验证 chkconfig --add zookeeper 把zookeeper添加到开机启动里面 chkconfig --list zookeeper 查看是否添加的zookeeper到开机启动