zookeeper:集群搭建操作步骤

  1. 3台Linux,这里使用虚拟机搭建能够互连的3个centos系统
  2. 分别在3台Linux上安装jdk1.8
  3. 分别在3台Linux上创建zookeeper目录,用于存放zookeeper的安装目录和数据,目录下创建以下目录:在这里插入图片描述
  4. 下载zookeeper-3.4.14.tar.gz,分别放到3台Linux并解压,效果如上图
  5. 3台Linux分别操作:把/opt/zookeeper/zookeeper-3.4.14/conf下的zoo_sample.cfg复制成zoo.cfg,修改内容为:
# 每次心跳间隔,毫秒
tickTime=2000
# 初始化时在多少次心跳内必须完成
# synchronization phase can take
initLimit=10
# 多少次心跳无响应就判断为宕机
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/zookeeper/zkdata
dataLogDir=/opt/zookeeper/zkdataLog
# the port at which the clients will connect
clientPort=12181
# 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
#改为3台Linux的ip
server.1=192.168.1.103:12888:13888
server.2=192.168.1.113:12888:13888
server.3=192.168.1.114:12888:13888
  1. 对应上面的zoo.cfg配置文件,在/zkdata目录下echo "1" > myid生成一个包含对应server标识的myid文件(比如192.168.1.113的myid的内容是2,192.168.1.114的myid的内容是3)
  2. 确认防火墙没有拦截
  3. 进入/opt/zookeeper/zookeeper-3.4.14/bin,运行./zkServer.sh start,3台Linux都启动后,通过./zkServer.sh status查看是否有leader和follower节点
    9.注意: zookeeper不会自动清理日志和快照,可以通过crontab定时任务调用./bin/zkCleanup.sh命令来清理(写个脚本)

关闭zookeeper:cd /opt/zookeeper/zookeeper-3.4.14/ && bin/zkServer.sh stop

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值