zookeeper集群的安装和配置

本文详细介绍了Zookeeper从单机模式到集群模式的安装和配置步骤,包括配置主机名和IP映射、设置myid、启动集群等。Zookeeper集群确保了服务的高可用性、稳定性和可靠性,适合在分布式环境中使用。
摘要由CSDN通过智能技术生成

Zookeeper的目的是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。Zookeeper有两种运行模式,单机模式(Standalone)和集群模式(Distributed),但是Zookeeper的长处在于可以搭建分布式的Zookeeper集群(一个Leader,多个Follower),从而可以保证集群的高可用性、高稳定性、高可靠性。

下面说明一下Zookeeper两种模式的配置:
在配置Zookeeper之前,下载Zookeeper的安装包:http://zookeeper.apache.org/releases.html#download,我使用的是zookeeper-3.3.6版本的。

Zookeeper的单机模式(standalone)


下载安装包之后,使用Winscp放到Linux的环境中,然后解压安装包:

tar zxvf zookeeper-3.3.6.tar.gz

解压后开始配置Zookeeper,进入到配置文件的目录:

cd  zookeeper-3.3.6/conf/

将目录下面的 zoo_sample.cfg修改为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=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
 

上面各个配置参数的含义:

tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。clientPortÿ

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值