• zookeeper分布式部署方案


    版本:http://apache.fayea.com/zookeeper/zookeeper-3.4.8/

    环境:debian 7/8

    说明:最低配置3台

    步骤:
    1.下载zookeeper-3.4.8并解压缩到合适的位置(本文地址为:/var/local/)

    2.配置zookeeper-3.4.8
    2.1单机伪分布式部署
    注意:部署在同一台电脑时,特别注意不能共用相同的端口号,包括clientPort,server.1-3的端口号

    (1)
    zookeeper-3.4.8-1
    位置:/var/local/zookeeper-3.4.8-1

    sudo mkdir -p /var/local/zookeeper-3.4.8-1/data
    sudo mkdir -p /var/local/zookeeper-3.4.8-1/data/log
    echo 1 > /var/local/zookeeper-3.4.8-1/data/myid
    (若无权限:sudo vi /var/local/zookeeper-3.4.8-1/data/myid {1},即值为1)
    cd /var/local/zookeeper-3.4.8-1/conf/ &&sudo mv zoo_sample.cfg zoo.cfg &&sudo vi zoo.cfg
    {
    clientPort=2181
    dataDir=/var/local/zookeeper-3.4.8-1/data
    dataLogDir=/var/local/zookeeper-3.4.8-1/data/log
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=1

    server.1=127.0.0.1:2888:3888
    server.2=127.0.0.1:2889:3889
    server.3=127.0.0.1:2890:3890
    }

    (2)
    zookeeper-3.4.8-2
    位置:/var/local/zookeeper-3.4.8-2

    sudo cp -p /var/local/zookeeper-3.4.8-1 /var/local/zookeeper-3.4.8-2
    sudo vi /var/local/zookeeper-3.4.8-2/data/myid {2}
    sudo vi /var/local/zookeeper-3.4.8-2/conf/zoo.cfg
    {
    clientPort=2182
    dataDir=/var/local/zookeeper-3.4.8-2/data
    dataLogDir=/var/local/zookeeper-3.4.8-2/data/log
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=1

    server.1=127.0.0.1:2888:3888
    server.2=127.0.0.1:2889:3889
    server.3=127.0.0.1:2890:3890
    }

    (3)
    zookeeper-3.4.8-3
    位置:/var/local/zookeeper-3.4.8-3
    sudo cp -p /var/local/zookeeper-3.4.8-1 /var/local/zookeeper-3.4.8-3
    sudo vi /var/local/zookeeper-3.4.8-3/data/myid {3}
    sudo vi /var/local/zookeeper-3.4.8-3/conf/zoo.cfg
    {
    clientPort=2183
    dataDir=/var/local/zookeeper-3.4.8-3/data
    dataLogDir=/var/local/zookeeper-3.4.8-3/data/log
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=1

    server.1=127.0.0.1:2888:3888
    server.2=127.0.0.1:2889:3889
    server.3=127.0.0.1:2890:3890
    }


    2.2分布式部署
    (1)
    zookeeper-3.4.8
    位置:node1:/var/local/zookeeper-3.4.8

    sudo mkdir -p /var/local/zookeeper-3.4.8/data
    sudo mkdir -p /var/local/zookeeper-3.4.8/data/log
    echo 1 > /var/local/zookeeper-3.4.8/data/myid
    (若无权限:sudo vi /var/local/zookeeper-3.4.8/data/myid {1},即值为1)
    cd /var/local/zookeeper-3.4.8/conf/ &&sudo mv zoo_sample.cfg zoo.cfg &&sudo vi zoo.cfg
    {
    dataDir=/var/local/zookeeper-3.4.8/data
    dataLogDir=/var/local/zookeeper-3.4.8/data/log
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=1

    server.1=node1:2888:3888
    server.2=node2:2888:3888
    server.3=node3:2888:3888
    }

    (2)
    位置:node2:/var/local/zookeeper-3.4.8
    scp -r node1:/var/local/zookeeper-3.4.8 node2:/var/local/zookeeper-3.4.8
    echo 1 > /var/local/zookeeper-3.4.8/data/myid
    (若无权限:sudo vi /var/local/zookeeper-3.4.8/data/myid {2},即值为2)

    (3)
    位置:node3:/var/local/zookeeper-3.4.8
    scp -r node1:/var/local/zookeeper-3.4.8 node2:/var/local/zookeeper-3.4.8
    echo 1 > /var/local/zookeeper-3.4.8/data/myid
    (若无权限:sudo vi /var/local/zookeeper-3.4.8/data/myid {3},即值为3)


    3.启动及监控
    分别启动每台zookeeper即可
    3.1单机伪分布式部署
    启动:
    sudo /var/local/zookeeper-3.4.8-1/bin/zkServer.sh start
    sudo /var/local/zookeeper-3.4.8-2/bin/zkServer.sh start
    sudo /var/local/zookeeper-3.4.8-3/bin/zkServer.sh start
    查看状态:
    sudo /var/local/zookeeper-3.4.8-1/bin/zkServer.sh status
    sudo /var/local/zookeeper-3.4.8-2/bin/zkServer.sh status
    sudo /var/local/zookeeper-3.4.8-3/bin/zkServer.sh status

    ZooKeeper JMX enabled by default
    Using config: /var/local/zookeeper-3.4.8-1/bin/../conf/zoo.cfg
    Mode: follower
    ZooKeeper JMX enabled by default
    Using config: /var/local/zookeeper-3.4.8-2/bin/../conf/zoo.cfg
    Mode: leader
    ZooKeeper JMX enabled by default
    Using config: /var/local/zookeeper-3.4.8-3/bin/../conf/zoo.cfg
    Mode: follower

    sudo jps
    16930 QuorumPeerMain
    16859 Bootstrap
    16898 Bootstrap
    16830 Bootstrap
    17010 QuorumPeerMain
    16963 QuorumPeerMain
    17260 Jps


    3.2分布式部署启动
    同上,不再赘述
  • 相关阅读:
    将数据库表直接导到Visio中!
    常用条形码
    Winfrom支持多语言解决方案!(总结)
    2011年工作总结
    根据当前时间计算周次!(每年的第一天属于第一周 C#实现)
    [NOI2012] 迷失游乐园 概率 期望 基环树DP
    codeforces CF36E Two Paths 欧拉回路
    POJ1201 Intervals & TYVJ 1589 西瓜种植 差分约束
    codeforces CF983E NN country 树上倍增
    codeforces CF402E Strictly Positive Matrix Tarjan强连通分量
  • 原文地址:https://www.cnblogs.com/wuyida/p/6300868.html
Copyright © 2020-2023  润新知