Zookeeper 集群搭建

30 篇文章 0 订阅
26 篇文章 0 订阅
      分布式Zookeeper安装步骤:

1. 安装准备
     1.1 下载Zookeeper。下载链接:http://mirrors.hust.edu.cn/apache/zookeeper/

     1.2 解压缩到指定的目录下,比如:/opt/zookeeper下。
     1.3 修改系统的hosts文件,指定域名映射。例如:
192.168.177.167 machine-1
192.168.177.168 machine-2
192.168.177.158 machine-0





      三台机器中都安装Zookeeper服务。

2. 配置zookeeper
       进入配置目录下,具体的命令如下:
[app@machine-1 conf]$ cd /opt/zookeeper/conf




       复制模板配置文件:
[app@machine-1 conf]$ cp zoo_sample.cfg zoo.cfg


      编辑文件:
[app@machine-1 conf]$ vim zoo.cfg 

<span style="font-size:18px;">     
 # 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=/opt/zookeeper/data
# the directory where transaction log is stored.
# this parameter provides dedicated log device for ZooKeeper
 dataLogDir=/opt/zookeeper/logs
# the port at which the clients will connect
clientPort=2222
server.1=machine-0:2888:3888
server.2=machine-1:2888:3888
server.3=machine-2:2888:3888
#
# 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</span>




     创建data和logs目录:
    mkdir -p /opt/zookeeper/data
    mkdir -p /opt/zookeeper/logs




3. 将zookeeper实例复制到集群
   #机器machine-1上
     scp  -r /opt/zookeeper machine-0:/opt/
     scp  -r /opt/zookeeper machine-2:/opt/






    添加myid文件到各台机器上,标示序列值不能够重复
    #一次输入1到225间的某个数,具体操作如下:
   #machine-0
   vim /opt/zookeeper/data/myid
   1
  #machine-1
   vim /opt/zookeeper/data/myid
   2
  #machine-2
   vim /opt/zookeeper/data/myid
  3




      启动各台机器的zookeeper。当然,可以将脚步添加到系统环境下,
直接执行sh脚步更方便,这里就不给出步骤了。
  
 /opt/zookeeper/bin/zkServer.sh start


    上实践本人已经运行成功了,有错误或者不足之处,请指出。
     转载,请写明出处。乐意分享!

欢迎关注我的微信公众号



  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值