1. 程式人生 > >linux centos7 安裝zookeeper

linux centos7 安裝zookeeper

isa http ror style for start export exe enter

linux 系統下 zookeeper 安裝教程

1.下載安裝包

  1)進入安裝目錄

  cd /home/install/

  2)下載

  wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.12.tar.gz

  技術分享圖片

2.安裝

  1)創建和解壓至安裝目錄

  mkdir /usr/local/zookeeper

  tar -zxcf /home/install/zookeeper-3.4.12.tar.gz -C /usr/local/zookeeper/

  2)拷貝樣本配置為主配置

    進入配置目錄,賦值拷貝樣本文件

    cd /usr/local/zookeeper/zookeeper-3.4.12/conf/

    cp zoo_sample.cfg zoo.cfg

    技術分享圖片

  3)簡單修改配置

    創建數據存儲目錄與日誌目錄

    mkdir /usr/local/zookeeper/zookeeper-3.4.12/dataDir

    mkdir /usr/local/zookeeper/zookeeper-3.4.12/dataLogDir

    修改數據存儲和日誌目錄

    vim /usr/local/zookeeper/zookeeper-3.4.12/conf/zoo.cfg

    技術分享圖片  

3.配置zookeeper環境變量

  1)依賴JVM環境,所以JVM與zookeeper環境變量都要配置

    vim /etc/profile

    在尾部加入或修改以下

JAVA_HOME=/usr/local/java/jdk1.8.0_181
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME PATH
ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.12
PATH=$PATH:$ZOOKEEPER_HOME/bin
export PATH ZOOKEEPER_HOME PATH

    技術分享圖片

  2)生效

    source /etc/profile

3.測試

  1)啟動

    /usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh start

  2)連接

    /usr/local/zookeeper/zookeeper-3.4.12/bin/zkCli.sh

  3)增刪改查

    技術分享圖片

  4)其他

    help查看指令幫助

    技術分享圖片

4.開機啟動

  (1)編輯redis.service文件

    vim /usr/lib/systemd/system/zookeeper.service

    加入如下內容

[Unit]
Description=redis
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh start
ExecReload=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh restart
ExecStop=/usr/local/zookeeper/zookeeper-3.4.12/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target

  (2)生效

    systemctl daemon-reload

  (3)改變文件權限

    chmod 777 /usr/lib/systemd/system/zookeeper.service

  (4)systemctl開機啟動redis

    systemctl enable /usr/lib/systemd/system/zookeeper.service

    或

    systemctl enable /usr/lib/systemd/system/zookeeper

  (5)查看是否開機啟動

    systemctl is-enabled zookeeper.service

  (6)systemctl取消開機啟動redis

    systemctl disablezookeeper.service

本章只講安裝,關於配置屬性與操作指令,先參考度娘

linux centos7 安裝zookeeper