02 | Zookeeper本地安装

第 2 章 Zookeeper 本地安装

2.1 本地模式安装

1)安装前准备

  1. 安装 JDK

  2. 解压改名

bash

# 解压到指定目录
$ tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /opt/module

# 修改名称
$ mv apache-zookeeper-3.5.7-bin zookeeper-3.5.7

2)配置修改

(1)将/opt/module/zookeeper-3.5.7/conf 这个路径下的 zoo_sample.cfg 修改为 zoo.cfg;

bash

$ mv zoo_sample.cfg zoo.cfg

(2)打开 zoo.cfg 文件,修改 dataDir 路径:

bash

$ vim zoo.cfg

修改如下内容:

bash

dataDir=/opt/module/zookeeper-3.5.7/zkData

(3)在/opt/module/zookeeper-3.5.7/这个目录上创建 zkData 文件夹

bash

$ mkdir zkData

3)操作 Zookeeper

(1)启动 Zookeeper

bash

$ bin/zkServer.sh start

(2)查看进程是否启动

bash

$ jps 4020 Jps
4001 QuorumPeerMain

(3)查看状态

bash

$ bin/zkServer.sh status 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Mode: standalone

(4)启动客户端

bash

$ bin/zkCli.sh

(5)退出客户端

bash

[zk: localhost:2181(CONNECTED) 0] quit

(6)停止 Zookeeper

bash

$ bin/zkServer.sh stop

2.2 配置参数解读

zoo_sample.cfg

bash

# 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.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=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

Zookeeper中的配置文件zoo.cfg中参数含义解读如下:

1)tickTime = 2000: 通信心跳时间,Zookeeper服务器与客户端心跳时间,单位毫秒

2)initLimit = 10: LF初始通信时限,Leader和Follower初始连接时能容忍的最多心跳数(tickTime的数量)

3)syncLimit = 5: LF同步通信时限,Leader和Follower之间通信时间如果超过syncLimit * tickTime,Leader认为Follwer死 掉,从服务器列表中删除Follwer。

4)dataDir: 保存Zookeeper中的数据,注意:默认的tmp目录,容易被Linux系统定期删除,所以一般不用默认的tmp目录。

5)clientPort = 2181: 客户端连接端口,通常不做修改。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

走过冬季

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值