zoukankan      html  css  js  c++  java
  • CentOS7 Zookeeper安装

    cd /opt
    wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
    tar -xvf zookeeper-3.4.6.tar.gz -C /opt
    cd zookeeper-3.4.6/
    mkdir data
    echo "1" > data/myid
    #其它节点请修改1为其它值,集群内不重复
    
    cat > /opt/zookeeper-3.4.6/conf/zoo.cfg <<EOF
    tickTime=2000
    initLimit=10
    syncLimit=5
    dataDir=/opt/zookeeper-3.4.6/data
    dataLogDir=/opt/zookeeper-3.4.6/log
    clientPort=2181
    maxClientCnxns=3000
    
    #replace these with you real ip
    server.1=192.168.6.117:2888:3888
    server.2=192.168.6.118:2888:3888
    server.3=192.168.6.119:2888:3888
    EOF
    
    
    #设置日志
    sed -i 's/zookeeper.root.logger=INFO, CONSOLE/zookeeper.root.logger=INFO, CONSOLE, ROLLINGFILE/g' /opt/zookeeper-3.4.6/conf/log4j.properties
    sed -i 's$ZOO_LOG_DIR="."$ZOO_LOG_DIR="../log"$g' /opt/zookeeper-3.4.6/bin/zkEnv.sh
    sed -i 's$ZOO_LOG4J_PROP="INFO,CONSOLE"$ZOO_LOG4J_PROP="INFO,ROLLINGFILE"$g' /opt/zookeeper-3.4.6/bin/zkEnv.sh
    
    
    启动zookeeper:/opt/zookeeper-3.4.6/bin/zkServer.sh start
    停止zookeeper:/opt/zookeeper-3.4.6/bin/zkServer.sh stop
    检查集群状态 : /opt/zookeeper-3.4.6/bin/zkServer.sh status
    集群有应该有且只有1个leader,其它的都为follower
    
    
    #设置zookeeper自启动
    cat > /usr/lib/systemd/system/zookeeper.service <<EOF
    [Unit]
    Description=Zookeeper service
    After=network.target
    
    [Service]
    Type=simple
    PIDFile=/opt/zookeeper-3.4.6/data/zookeeper_server.pid
    ExecStart=/opt/zookeeper-3.4.6/bin/zkServer.sh start
    ExecStop=/opt/zookeeper-3.4.6/bin/zkServer.sh stop
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl enable zookeeper
  • 相关阅读:
    消息摘要技术(MD5)
    编写JsonResult封装JSON返回值(模板参阅)
    JS面向对象编程(进阶理解)
    markdown常用语法教程
    Spring-MVC请求参数值和向页面传值
    Spring-MVC开发步骤(入门配置)
    Live Templates快捷键模板
    压力测试中java.net.BindException: Address already in use: connect
    jmeter初始化工作
    xshell配色
  • 原文地址:https://www.cnblogs.com/xiaochangwei/p/zk-install.html
Copyright © 2011-2022 走看看