前言

项目需要,所以,在mac OSX中安装了一下zookeeper。

安装

  1. 查看brew info zookeeper

$ brew info zookeeper
zookeeper: stable 3.4.12 (bottled), HEAD
Centralized server for distributed coordination of services
https://zookeeper.apache.org/
  1. 安装brew install zookeeper
$ brew install zookeeper
==> Downloading https://homebrew.bintray.com/bottles/zookeeper-3.4.12.high_sierr
######################################################################## 100.0%
==> Pouring zookeeper-3.4.12.high_sierra.bottle.tar.gz
==> Caveats
To have launchd start zookeeper now and restart at login:
  brew services start zookeeper
Or, if you don't want/need a background service you can just run:
  zkServer start
  1. 安装后,在/usr/local/etc/zookeeper/ 已经有了缺省配置
$ ls /usr/local/etc/zookeeper/
  1. 查看缺省配置文件
$ less -N /usr/local/etc/zookeeper/zoo.cfg

缺省内容如下:

 $less -N /usr/local/etc/zookeeper/zoo.cfg 

      1 # The number of milliseconds of each tick
      2 tickTime=2000
      3 # The number of ticks that the initial 
      4 # synchronization phase can take
      5 initLimit=10
      6 # The number of ticks that can pass between 
      7 # sending a request and getting an acknowledgement
      8 syncLimit=5
      9 # the directory where the snapshot is stored.
     10 # do not use /tmp for storage, /tmp here is just 
     11 # example sakes.
     12 dataDir=/usr/local/var/run/zookeeper/data
     13 # the port at which the clients will connect
     14 clientPort=2181
     15 # the maximum number of client connections.
     16 # increase this if you need to handle more clients
     17 #maxClientCnxns=60
     18 #
     19 # Be sure to read the maintenance section of the 
     20 # administrator guide before turning on autopurge.
     21 #
     22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
     23 #
     24 # The number of snapshots to retain in dataDir
     25 #autopurge.snapRetainCount=3
     26 # Purge task interval in hours
     27 # Set to "0" to disable auto purge feature
     28 #autopurge.purgeInterval=1

启动服务

执行命令zkServer

$ zkServer
ZooKeeper 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
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.
$ zkServer start
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Starting zookeeper ... STARTED

查看zookeeper运行及状态

安装后,可以看到zookeeper提供了zkCli等工具进行.

$ zkServer status
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.
192:~ maerfeifei$ zkServer start
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Starting zookeeper ... STARTED
192:~ maerfeifei$ zkCli
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] 
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐