Ubuntu_安裝Zookeeper

Crazy_Coder發表於2015-11-03
  1. 下載zookeeper,http://archive.apache.org/dist/zookeeper/

  2. 解壓到: /opt/zookeeper-3.4.6下載

  3. 把conf下的zoo_sample.cfg copy一份後重新命名為: zoo.cfg.檔案中內容如下:
    syncLimit=5
    initLimit=10
    tickTime=2000
    clientPort=2181
    dataDir=/opt/zookeeper-3.4.6/data
    dataLogDir=/opt/zookeeper-3.4.6/logs

  4. 新建zookeeper-3.4.6下的data,log目錄,然後
    chmod u+x /opt/zookeeper-3.4.6/bin/*

  5. 新建shell指令碼startZookeeper.sh在/opt/shell資料夾下,

    內容:
    #!/bin/sh
    #to start zookeeper
    #set environment
    export ZOOKEEPER_INSTALL=/opt/zookeeper-3.4.6
    export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
    PID_FILE=$ZOOKEEPER_INSTALL/data/zookeeper_server.pid
    FLAG=$1

    if [ “$FLAG” = “os_start” ] && [ -f “$PID_FILE” ]
    then

           rm $PID_FILE

    fi

    chmod u+x /opt/shell/startZookeeper.sh

    #start zookeeper
    $ZOOKEEPER_INSTALL/bin/zkServer.sh start

  6. 設定zookeeper開機啟動
    vim /etc/rc.local
    在最後一行新增如下兩句話
    #start zookeeper
    /opt/shell/startZookeeper.sh

相關文章