安裝包apache
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.6.0/apache-zookeeper-3.6.0-bin.tar.gz
解壓bash
tar -xcf aparche-zookeeper-3.6.0-bin.tar.gz
/etc/hosts配置修改spa
192.168.159.3 dev1.xiayu.com 192.168.159.3 dev2.xiayu.com 192.168.159.3 dev3.xiayu.com
zookeeper配置文件修改命令行
首先複製一份原來的配置文件 cp zoo_sample.cfg zoo.cfg # The number of milliseconds of each tick tickTime=2000 #心跳的單元時間 2s # The number of ticks that the initial # synchronization phase can take initLimit=10 #follower和leader開始鏈接的最長時間 20s # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 #follower和leader同步的最長時間 10s # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/data/zookeeper/zk1 #myid所在目錄,數據目錄 # the port at which the clients will connect clientPort=2181 #服務端口 server.1=dev1.xiayu.com:2881:3881 server.2=dev2.xiayu.com:2882:3882 server.3=dev3.xiayu.com:2883:3883 #server.1 server.2 server.3表明有3臺機器 123要同myid文件對應; #2881,2882,2883是數據同步端口; #3881,3882,3883是選舉端口
修改三份配置code
建立myid文件server
分別執行blog
./bin/zkServer.sh start
查看狀態get
./bin/zkServer.sh status
./bin/zkCli.sh -server dev1.xiayu.com:2181,dev2.xiayu.com:2182,dev3.xiayu.com:2183
簡單腳本同步
#/usr/bin/bash ./zookeeper1/bin/zkServer.sh status ./zookeeper2/bin/zkServer.sh status ./zookeeper3/bin/zkServer.sh status