天天看點

在mac上安裝使用Zookeeper

安裝

1、下載下傳指定的tar.gz檔案

​​http://archive.apache.org/dist/zookeeper​​

​​http://archive.apache.org/dist/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz​​

在mac上安裝使用Zookeeper

2、解壓

檔案複制到 ​

​usr/local/​

​中解壓

sudo tar      

解壓結果

➜  local sudo tar      

配置

1、移除壓縮檔案并改名

sudo rm -rf apache-zookeeper-3.6.2-bin.tar.gz 
sudo mv      

執行結果

➜  local sudo rm -rf apache-zookeeper-3.6.2-bin.tar.gz 
➜  local sudo mv apache-zookeeper-3.6.2-bin zookeeper
➜  local ls      

2、建立資料檔案夾與日志檔案夾

進入zookeeper檔案夾

sudo mkdir data
sudo mkdir      

執行結果

➜  local cd zookeeper 
➜  zookeeper ls
LICENSE.txt         README.md           bin                 docs
NOTICE.txt          README_packaging.md conf                lib
➜  zookeeper sudo mkdir data
➜  zookeeper sudo mkdir log
➜  zookeeper ls -all
total 48
drwxr-xr-x  12 root  wheel    384  2 24 10:35 .
drwxr-xr-x  20 root  wheel    640  2 24 10:34 ..      

3、配置檔案修改

将zoo_sample.cfg改為zoo.cfg

檔案中添加如下内容

dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logo      

執行結果

➜  zookeeper cat conf/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=/tmp/zookeeper
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logo


# 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
      

運作

1、進入bin檔案夾中執行指令

sudo      

執行結果

sudo ./zkServer.sh start
Password:
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
➜  bin ps -ef | grep      
bin sudo      
➜  bin sudo ./zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone