手把手教你Zookeeper集群搭建

部署前准备

本次部署为3台主机集群

  1. zookeeper官网下载,本次部署版本为zookeeper-3.4.9
  2. 主机jdk安装,本次部署版本为jdk1.8

部署过程

  1. 压缩包解压tar -zxvf zookeeper-3.4.9.tar.gz
  2. 修改zookeeper配置文件,在zookeeper-3.4.9/conf/文件夹下,将zoo_sample.cfg复制重命名为zoo.cfg,对应修改配置,主要是dataDir路径、集群配置

# 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=/home/emall/soft/zookeeper/zookeeper-3.4.9/data

# 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

#集群配置

server.1=136.64.50.223:2888:3888

server.2=136.64.50.224:2888:3888

server.3=136.64.50.225:2888:3888

 

    3.修改zkServer.sh,新增jdk配置

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/jre

export PATH=$JAVA_HOME/bin:$PATH

    4.zookeeper-3.4.9/路径下新增data文件夹,新建myid文件,内容和步骤2中集群配置server.x中的x相对于,比如:server.1=136.64.50.223:2888:3888,136.64.50.223主机的myid内容为1

部署验证

三台全部部署完成后,分别启动,执行 sh zookeeper-3.4.9/bin/zkServer.sh start,对应可以使用sh zookeeper-3.4.9/bin/zkServer.sh status来查看状态,三台全部启动完成后,分别查看每台status:

以上可看出有一台主节点,两台从节点

 

 

 

问题汇总

zookeeper启动现实成功,但是查看状态显示ZooKeeper JMX enabled by default,如下:

 

查看zookeeper日志(路径为../zookeeper-3.4.9/zookeeper.out),java.net.NoRouteToHostException: No route to host

解决:对应关闭防火墙即可

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值