站内搜索

workerdance.com — Trusted craft, unfailing commitment
返回文章列表
后端开发

Windows/Mac安装zookeeper

本文写于 2017 年,文中涉及的软件版本可能已有变化,核心排查思路仍可参考。

1. 下载页面: http://www.apache.org/dyn/closer.cgi/zookeeper/

2. 解压下载的压缩包:  zookeeper-3.4.10.tar (或zookeeper-3.4.10.tar.gz), 放置在期望的目录, 譬如: C:\Coding\zookeeper-3.4.10

3. 修改配置

进入conf目录, 将zoo_sample.cfg复制一份, 起名为: 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=D:\\data\\zookeeper
dataLogDir=D:\\logs\\zookeeper

# 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
  1. 启动

使用cd命令到bin目录下, 执行以下命令启动

.\zkServer.cmd

Mac系统下:

如果系统已安装brew,这步忽略:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

使用brew安装zookeeper:

$ brew install zookeeper

在 /usr/local/etc/zookeeper/ 路径下配置zoo.cfg,内容和windows类似

安装路径: /usr/local/Cellar/zookeeper/3.4.10

启动

$ zkServer
JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

$ zkServer  status
JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.

$ zkServer  start
JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Starting zookeeper ... STARTED

$ zkServer status
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Mode: standalone

参考: 

enjoy it !

workerdance
workerdance

记录开发与运维中的实践和踩坑。