Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

starts a ZooKeeper server running on port 2181. It is storing its data in /tmp, so this is obviously not a way you want to run in production.

Lets start up a ZooKeeper server cluster, so that we can experiment If you want to startup a cluster of server, you must do a bit more. To do this we need to create a configuration file for each server. Generally, we can share a configuration file across server, but since we are starting all three on the same machine, we need to have a configuration for each server:

...

Code Block
java -jar zookeeper-3.3.3-fatjar.jar client -server 127.0.0.1:2181

_if you started up a cluster of servers, you would use 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183

...

instead of just 127.0.0.1:2181.

Now lets create the znodes. We have to supply initial data for them even though it isn't used:

Code Block
[zk: 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183(CONNECTED) 0] create /assign ""
Created /assign
[zk: 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183(CONNECTED) 1] create /tasks ""
Created /tasks
[zk: 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183(CONNECTED) 2] ls /
[assign, tasks, zookeeper]