验证版本 # java -version java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)
1、三台服务器下载并安装zookeeper # tar xvf zookeeper-3.4.14.tar.gz # ln -sv /usr/local/src/zookeeper-3.4.14 /usr/local/zookeeper
# cd /usr/local/zookeeper # cp conf/zoo_sample.cfg conf/zoo.cfg #mkdir /usr/local/zookeeper/data 创建数据目录
# vim conf/zoo.cfg 三台服务器配置相同 # The number of milliseconds of each tick tickTime=2000 #服务器与服务器之间和客户端与服务器之间的单次心跳检测时间间隔,单位为毫秒 # The number of ticks that the initial # synchronization phase can take initLimit=10 #集群中leader服务器与follower服务器初始连接心跳次数,即多少个2000毫秒 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # leader与follower之间连接完成之后,后期检测发送和应答的心跳次数,如果该follower 在设置的时间内(5*2000)不能与leader 进行通信,那么此 follower 将被视为不可用 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/usr/local/zookeeper/data #自定义的zookeeper保存数据的目录 # the port at which the clients will connect clientPort=2181 #客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求 # the maximum number of client connections. # increase this if you need to handle more clients maxClientCnxns=4096 # # 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=512 #设置zookeeper保存保留多少次客户端连接的数据 # Purge task interval in hours # Set to "0" to disable auto purge feature autopurge.purgeInterval=1 #设置zookeeper间隔多少小时清理一次保存的客户端数据
3、启动zookeeper服务(三台服务器要同时启动,期间不要超过上面设置的20s) # /usr/local/zookeeper/bin/zkServer.sh --help # /usr/local/zookeeper/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
4、验证集群状态(2个follower、1个leader) # /usr/local/zookeeper/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Mode: follower
# /usr/local/zookeeper/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Mode: follower
# /usr/local/zookeeper/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Mode: leader
删除topic # /usr/local/kafka/bin/kafka-topics.sh --delete --zookeeper 192.168.7.10:2181,192.168.7.20:2181,192.168.7.30:2181 --topic logstashtest Topic logstashtest is marked for deletion. Note: This will have no impact if delete.topic.enable is not set to true.