安装版本:3.4.11

部署方式:单机版

安装方式:磁盘安装

  1. 下载安装包

    wget https://obs-mirror-ftp4.obs.cn-north-4.myhuaweicloud.com/middleware/zookeeper-3.4.11.tar.gz
    
  2. 解压

    tar -zxvf zookeeper-3.4.11.tar.gz
    cd zookeeper-3.4.11
    mkdir data log
    mv zookeeper-3.4.11 /opt/ && mv /opt/zookeeper-3.4.11 /opt/zookeeper
    
  3. 修改配置

    cd conf cp zoo_sample.cfg zoo.cfg cat 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=../data
    # the port at which the clients will connect
    dataLogDir=../logs
    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
    
  4. 环境变量

    /etc/profile

    export ZOOKEEPER_HOME=/opt/zookeeper
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
    
  5. 启动与验证

    ./zkServer.sh start 
    ./zkServer.sh start 
    curl 127.0.0.1:2181