下载: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