下載:zookeeper-3.3.6.tar.gznode
解壓扔到/opt目錄下sql
[~]$ cd /opt/zookeeper-3.3.6/conf [conf]$ mv zoo_sample.cfg zoo.cfg [conf]$ vi zoo.cfg
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. dataDir=/opt/zookeeper-3.3.6/tmp/data #日誌位置 dataLogDir=/opt/zookeeper-3.3.6/tmp/logs # the port at which the clients will connect clientPort=2181 # 從3.4.0開始,zookeeper提供了自動清理snapshot和事務日誌的功能 autopurge.purgeInterval=1 //頻率小時,默認爲0表示不清理 autopurge.snapRetainCount=1 //保留的文件數目,默認爲3 server.1=172-25-3-27:2888:3888
cd /opt/zookeeper-3.3.6/tmp/data vi myid 1
若是不加這一步,在分佈式的狀況下,斷網會致使zookepper服務異常退出。shell
QuorumPeerMain分佈式
啓動spa
cd ../bin ./zkServer.sh start
中止日誌
./zkServer.sh stop
查看zookeeper狀態code
./zkServer.sh status
zookeeper客戶端操做命令server
./zkCli.sh -server 192.168.0.102:2181 [zk: 192.168.0.102:2181(CONNECTED) 0] ls / create /zk "myData" get /zk set /zk "zsl" delete /zk create /zk/node1 "node1" ls /zk