ZooKeeper configuration

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s