Zookeeper安装

1、下载或上传zookeeper安装包

wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz

2、解压安装包

tar -zxvf zookeeper-3.4.13.tar.gz 

3、修改配置文件

进入conf目录,复制zoo_sample.cfg文件,并修改为zoo.cfg : cp zoo_sample.cfg zoo1.cfg
打开zoo.cfg配置文件,修改以下三处:

# The number of milliseconds of each tick.
#心跳
tickTime=2000
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 数据存放目录
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=2181

4、启动zookeeper

进入bin目录输入启动命令 ./zkServer.sh start
启动成功:

ZooKeeper JMX enabled by default
Using config: /usr/soft/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

参考文档zookeeper官方文档

5、集群部署

需准备至少3(奇数)台机器,部署方式与单例方式相似,配置有少许不同,每台机器zoo.cfg配置如下:

tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
#server.1=192.168.154.1:2888:3888
#server.2=192.168.154.2:2888:3888
#server.3=192.168.154.3:2888:3888
#maxClientCnxns=2048
#autopurge.snapRetainCount=3
#autopurge.purgeInterval=1
#4lw.commands.whitelist=stat, ruok, conf, isro, mntr
#authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
#requireClientAuthScheme=sasl
#quorum.cnxn.threads.size=20
#quorum.auth.enableSasl=true
#quorum.auth.kerberos.servicePrincipal= zookeeper/_HOST
#quorum.auth.learnerRequireSasl=true
#quorum.auth.learner.saslLoginContext=QuorumLearner
#quorum.auth.serverRequireSasl=true
#quorum.auth.server.saslLoginContext=QuorumServer

zoo1、zoo2、zoo3为每台机器的主机名,通过hostname命令查看本机主机名,在/etc/hostname文件中修改,也可使用ip地址。
分别启动三台机器即可。

配置说明

tickTime:心跳间隔时间(以毫秒为单位),用于管理会话超时。
dataDir:指定用于存储数据和状态的文件系统目录。
initLimit:限制从ZooKeeper集群中选择Leader的时间。
syncLimit:限制Leader与Follower之间进行同步的时间。
maxClientCnxns:限制到单个ZooKeeper节点的同时客户端连接数。
autopurge.snapRetainCount:指定要保留的自动快照数量。
autopurge.purgeInterval:指定两次自动清理之间的时间间隔。
4lw.commands.whitelist:指定允许使用的四字命令(用于监控和调试)。
authProvider.1和requireClientAuthScheme:用于启用SASL身份验证。
quorum.cnxn.threads.size:限制ZooKeeper服务器用于处理客户端连接的线程数。
quorum.auth.enableSasl:启用SASL身份验证以保护ZooKeeper Quorum。
quorum.auth.kerberos.servicePrincipal:指定Kerberos服务主体名称。
quorum.auth.learnerRequireSasl和quorum.auth.learner.saslLoginContext:将SASL身份验证强制应用于学习器(follower)。
quorum.auth.serverRequireSasl和quorum.auth.server.saslLoginContext:将SASL身份验证强制应用于服务器。
server.xx:指定ZooKeeper集群中的服务器信息,包括IP地址、端口和Leader选举端口。每个服务器后跟分号和ZooKeeper客户端端口。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值