• zookeeper集群搭建


    1上传三个zookeeper到三个服务器,服务器ip分别为192.168.199.71,192.168.199.72,192.168.199.73,因为zookeeper会实行投票选举机制,所以集群数最好为奇数

    2zookeeper分别解压到/usr/local/zookeeper目录下

    3在zookeeper/conf下,复制zoo_sample.cfg为zoo.cfg,并修改zoo.cfg配置文件

    tickTime=2000
    dataDir=/usr/local/zookeeper/data
    dataLogDir=/usr/local/zookeeper/logs
    server.0=192.168.199.71:2888:3888    
    server.1=192.168.199.72:2888:3888     
    server.2=192.168.199.73:2888:3888
    

    4在zookeeper下,分别建立文件夹data和logs

    5 192.168.199.71,192.168.199.72,192.168.199.73三个服务器,在data目录分别建立文件myid,并且里面内容分别为0,1,2,和配置文件的配置对应

    6分别启动三个zookeeper bin/zkServer.sh start

    7查看三个状态 bin/zkServer.sh status,会看其实一台服务器mode为leader,另外两台为follower

    [root@localhost zookeeper]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
    Mode: leader
    
    [root@localhost zookeeper]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
    Mode: follower
    
    
    [root@localhost zookeeper]# bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
    Mode: follower
    

    8关闭leader服务器,另外两台会有一台变为leader,而关闭的这台重新启动,会变成follower模式  

  • 相关阅读:
    UU跑腿
    Java基础之接口与抽象类的区别
    经典面试题:Redis为什么这么快?
    isBlank与isEmpty
    阅读联机API文档
    从文本中取出链接地址 并检测链接地址能否打开
    2019-01-19=树莓派学习总结
    单片机知识点
    Linux 编程题
    嵌入式基础知识
  • 原文地址:https://www.cnblogs.com/ystq/p/6617596.html
Copyright © 2020-2023  润新知