MAC安装单机zookeeper

下载

cd /usr/local/software
sudo wget https://downloads.apache.org/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz

解压

sudo tar -zxvf apache-zookeeper-3.7.0-bin.tar.gz
sudo mv apache-zookeeper-3.7.0-bin/ zookeeper

创建data和log文件

# 在 /usr/local/software/zookeeper 目录下新建两个文件夹 data 和 log,用于存储zookeeper的数据和日志。
sudo mkdir data
sudo mkdir log

改配置

# 将conf目录下的zoo_sample.cfg文件更名为zoo.cfg,简单修改配置文件,自定义设置数据文件目录和日志文件目录
sudo mv zoo_sample.cfg zoo.cfg
vi 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=/usr/local/software/zookeeper/data
dataLogDir=/usr/local/software/zookeeper/log
# the port at which the clients will connect
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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

启动server

cd /usr/local/software/zookeeper/bin
sudo ./zkServer.sh start

连接client

cd /usr/local/software/zookeeper/bin
./zkCli.sh -server 127.0.0.1:2181

结束!

原文地址:https://www.cnblogs.com/aaronthon/p/15602030.html