• centos7上搭建zookeeper集群


    1.下载zookeeper

    http://www.apache.org/dyn/closer.cgi/zookeeper/  可以登录这个网站下载,然后上传到 centos上

       修改成自己需要的版本 ,建议登录上上面的网站看看选择合适的版本

    此处,我构建根目录下一个专门放安装软件的目录 /software 

    cd /software 
    sudo wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

    2.  解压 

    tar -zxvf  zookeeper-3.4.14.tar.gz

    3.复制配置文件名称

    cd zookeeper-3.4.14/conf/
    cp  zoo_sample.cfg   zoo.cfg

    4.修改配置文件

    vi zoo.cfg
    # 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=/sortware/data/zookeeper #修改数据存放位置
    # the port at which the clients will connect
    dataLogDir=/sortware/log/zookeeper #修改日志存放位置
    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=node1:2888:3888
    server.2=node2:2888:3888
    server.3=node3:2888:3888

    wq! 保存退出

    5.设置每个节点的id

    在zoo.cfg中对应的   dataDir 目录下执行

    echo 1 > myid    注意myid要一摸一样  1这个对应  zoo.cfg 中 集群信息  server.1

    6.复制整个software目录到其他节点上

    scp -r /software node2:/

    scp -r /software node3:/

    然后分别修改node2上的  echo 2 > myid,node3上的  echo 3 > myid

    备注:我事先在/etc/hosts 里增加每个节点映射到域名,node1,node2,node3,如果你没有设置,所有主机名要改成ip地址。

    7.关闭防火墙

    systemctl stop firewalld.service #停止firewall
    
    systemctl disable firewalld.service #禁止firewall开机启动
    
    firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

    8.把zk目录添加到环境变量

    export ZOOKEEPER_HOME=//software/zookeeper-3.4.14/
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
    export PATH

    8.启动zk集群,

    zookeeper-3.4.14至少启动3台节点,集群才能正常运行,一般zk集群搭建奇数节点数
    zkServer.sh start

    9.查看zk运行状态

    [root@node2 zookeeper]# zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: //software/zookeeper-3.4.14/bin/../conf/zoo.cfg
    Mode: leader

    end

  • 相关阅读:
    我与酷派手机N900+的艰难之旅
    从ASPNET1.1迁移到了ASPNET2.0遇到ORA01000: 超出打开游标的最大数
    彩铃平台接口独立取得阶段性胜利
    中央音乐平台的MD5算法问题
    彩铃接口独立完毕
    'OraOLEDB.Oracle.1' provider is not registered on the local machine.错误的解决
    程序员的陷阱
    ASP NET页面下载程序
    从aspnet1.1升级到aspnet2.0的小问题
    彩铃平台接口的计费服务问题解决
  • 原文地址:https://www.cnblogs.com/xinyumuhe/p/11275304.html
Copyright © 2020-2023  润新知