压缩包下载 http://zookeeper.apache.org/releases.html
安装使用 https://zookeeper.apache.org/doc/r3.7.0/zookeeperStarted.html
Docker安装zookeeper
一键安装
mkdir -p /home/docker/zookeeper/data/ |
执行命令mkdir -p /home/docker/zookeeper/data/
mkdir -p /home/docker/zookeeper/logs/
将以下内容保存到 /home/docker/zookeeper/docker-compose.yml
version: "3"
services:
zk:
container_name: zk
image: zookeeper:latest
ports:
- 2181:2181
restart: always
volumes:
- ./zoo.cfg:/conf/zoo.cfg
- ./data:/data/zookeeper/data
- ./logs:/data/zookeeper/logs
- ./healthcheck.sh:/home/healthcheck.sh
healthcheck:
test: ["CMD", "/bin/bash", "/home/healthcheck.sh"]
interval: 1m30s
timeout: 30s
retries: 3
将以下内容保存到 /home/docker/zookeeper/zoo.cfg
dataLogDir=/data/zookeeper/logs
dataDir=/data/zookeeper/data
tickTime=2000
initLimit=10
syncLimit=5
clientPort=2181
standaloneEnabled=true
将以下内容保存到 /home/docker/zookeeper/healthcheck.sh
!/bin/bash
result="$(zkServer.sh status | grep 2181)"
if [ "$result" ]; then
exit 0;
else
exit 1
fi
执行命令安装zookeepercd /home/docker/zookeeper
确保docker已经启动,若已经启动则忽略这条命令
systemctl restart docker
docker-compose up -d