zookeeper官网 下载地址 ssh登录node01
cd /data/soft wget https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz mv apache-zookeeper-3.6.2-bin ../zookeeper-3.6.2zoo.cfg
#zookeeper集群中各个节点间心跳的间隔时间 # The number of milliseconds of each tick tickTime=2000 #zookeeper集群中follower与leader之间能够容忍丢失的心跳次数 # The number of ticks that the initial # synchronization phase can take initLimit=10 #集群中follower 与leader之间最多能容忍的同步数据心跳失败次数 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 #zk集群数据持久化目录 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/data/zk #zk对外提供服务的端口 # the port at which the clients will connect clientPort=2181 #默认最大的客户端连接zk的数量 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpPort=7000 #metricsProvider.exportJvmInfo=true #server.A=B:C:D #A:其中 A 是一个数字,表示这个是服务器的编号; #B:是这个服务器的 ip 地址; #C:Leader选举的端口; #D:Zookeeper服务器之间的通信端口。 server.1=192.168.235.132:2888:3888 server.2=192.168.235.129:2888:3888 server.3=192.168.235.130:2888:3888还需要做两件事 1. 在/data/zk/myid 修改为对应的值 node02为2 node03为3
/etc/profile增加ZOOKEEPER_HOME环境变量同node01一样,,并使之生效
分别在node01—node03上启动zk
zkServer.shb start查看zk状态
# node02为leader zkServer.sh status