zookeeper集群搭建

1.准备3台机器,安装相同的jdk,zookeeper 版本 


2.进入到zookeeper/conf 目录 修改 zoo_sample.cfg 文件命令为zoo.cfg 


3.修改zookeeper/conf/zoo.cfg 文件里的 dataDir 目录路径

我的配置如下,路径为:dataDir 参数路径 /usr/local/apache-zookeeper-3.6.1-bin/zookeeperData

# 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=/usr/local/apache-zookeeper-3.6.1-bin/zookeeperData
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

4.进入到  dataDir 配置的路径下创建myid 配置文件,linux 命令touch myid

前期规划的时候需要给对应的服务器分配唯一id 我的分配如下:

ipmyid
192.168.0.1451
192.168.0.1462
192.168.0.1473

那么在对应服务器下的myid 配置文件里就写入对应的id 如在192.168.0.145 那么myid 配置文件里就写1,

在192.168.0.146 那么myid 配置文件里就写2

在192.168.0.147 那么myid 配置文件里就写3

以此类推。。。


5.修改各节点zoo.cfg配置文件

末尾新增

server.1=192.168.0.145:2888:3888
server.2=192.168.0.146:2888:3888
server.3=192.168.0.147:2888:3888

格式说明

server.MYID=IP:2888:3888

MYID: 标识myid文件里配置的id 

IP:集群节点所对的IP

2888: 保持不变   内部通讯端口

3888:保持不变内部选举端口


注意:集权服务器应保持版本一直。

集群搭建时最少使用3台服务器,因为只有半数以上机器运行正常集群工作才会正常。

 

进入到zookeeper/bin 目录使用./zkServer.sh start 启动zookeer, ./zkServer.sh status 查看状态

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值