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

結束!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章