zoukankan      html  css  js  c++  java
  • zookeeper集群配置

    前言:zookeeper支持本机多个进程之间的集群,本文描述的是多个独立主机的分布式集群。

    一、前提条件

    至少需要3台独立主机(不管是虚拟机还是独立硬件)

    因为zookeeper支持“大多数节点可用时的服务保障”,而1台和2台是无法满足“大多数节点可用”的条件的。

    二、N(N>=3)台主机的配置

    它们的配置文件是一样的,例如:

    # 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=/tmp/zookeeper
    # 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=192.168.25.128:2888:3888
    server.2=192.168.25.129:2888:3888
    server.3=192.168.25.130:2888:3888

    三、不一样的配置

    1. 步骤二中的server.1中1指的是zookeeper的编号,需要根据配置定义每台机器编号。

    2. 编号配置文件名称为myid,路径为步骤二中的配置项dataDir=/tmp/zookeeper指示的路径。

    配置实例,在IP地址为192.168.25.128的主机上执行如下命令:

     echo "1" >/tmp/zookeeper/myid

    类似的配置其它主机。

    四、启动服务

    /usr/local/zookeeper-3.4.9/bin/zkServer.sh start

    五、查看节点状态

    ./zkServer.sh status

    能看到Mode: leader或者Mode: follower

    顾名思义,就是主节点和从节点了。

    做个测试,down掉主节点的机器,你会发现剩下的两个follower会有一个变成leader。

  • 相关阅读:
    字符串实现变量映射
    纯css实现无限嵌套菜单
    flex布局嵌套之高度自适应
    easy ui 零散技巧
    js高级应用
    前端利器
    css高级应用及问题记录(持续更新)
    兼容性验证方案
    原生js判断元素是否可见
    vue-cli webpack躺坑之旅
  • 原文地址:https://www.cnblogs.com/yoyotl/p/6593871.html
Copyright © 2011-2022 走看看