Zookeeper(二) 安装及配置

1.安装Zookeeper

(1)安装包下载地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

(2)确保安装了jdk

(3)将下载后的安装包拷贝到想安装的目录下,解压 tar -zxvf zookeeper-3.4.14.tar.gz

(4)复制并重命名配置文件:cp conf/zoo_sample.cfg conf/zoo.cfg

(5)启动服务器:bin/zkServer.sh start(注意启动服务端需要加start)

(6)启动客户端:bin/zkCli.sh

(7)查看节点:ls /

(8)退出客户端:quit

(9)关闭服务器:bin/zkServer.sh stop

2.zoo.cfg配置文件

# The number of milliseconds of each tick
tickTime=2000  #通信心跳数,ZooKeeper服务器与客户端心跳时间,即每隔tickTime时间发生一次心跳,单位毫秒
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10  #Leader和Follower初始通信时限.Follower在启动过程中,会从Leader同步所有最新数据。Leader允许Follower在initLimit*tickTime时间内完成这个工作。
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5 #leader和follower同步通信时限,集群正常启动后,如果Leader发出心跳包在syncLimit*tickTime时间之后,Follower还没响应,则认为这个Follower下线了。
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/home/Test/ZooKeeper/zookeeper-3.4.14/zkData  #数据文件目录+数据持久化路径
# the port at which the clients will connect
clientPort=2181  #客户端连接server的端口,对外服务端口,默认2181
# 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

 

posted @ 2020-05-06 15:18  千堆雪  阅读(128)  评论(0编辑  收藏  举报