Starting / Stopping zookeeper and setting up a basic configuration is rather trivial, but there are a couple of gotcha’s that are worth documenting here.
I have setup a few OS environment variables:
ZOOCFGDIR="/Users/marco/.zoo"
ZOODATA="/Users/marco/.zoo/data"
ZOOKEEPER_HOME="/Users/marco/Dev/zookeeper"
In particular, the ZOOCFGDIR will direct ZooKeeper to look for a zoo.cfg file in that directory and use it for its configuration:
$ cat .zoo/zoo.cfg
# Zookeeper Configuration file
# Created MM 2013-10-08
tickTime=2000
dataDir=/Users/marco/.zoo/data
clientPort=2181
Note the absence of spaces around the `=`: this is particularly important for the `dataDir` property: adding a leading space after the equal sign will cause ZK to create an “almost invisible” directory named ‘ ‘ (one space) in your current directory (whichever one may happen to be when you run the `zkServer.sh start` command) and use that as the root of the subtreee defined as the data directory.
Leave a Reply