Zookeeper Ensemble of 3 Nodes On Mac

May 09, 2017

By Chakravarthy Yeleswarapu

Normally, each zk instance resides on separate machine to avoid SPoF

From zk admin guide
To create a deployment that can tolerate the failure of F machines, you should count on deploying 2xF+1 machines

For this reason, ZooKeeper deployments are usually made up of an odd number of machines. Often on employer issued MacBook Pro, users do not have root privileges.
Use sudo when creating directories and invoking scripts.
Ensure Java/jdk installed. I’ve used Jdk 1.8 with this install. I also have Jdk 1.7 and switch between them when I need.

In my home (~) directory I have.bash_profile and it has following contents.

Zookeeper-ensemble-of-3nodes-on-Mac

And when I need to switch to jdk 7, I’d simply type use-java 7 in command prompt.

Download Zookeeper tar to the directory of your choice, for example, ~/zookeeper-3.4.6.tar.gz Merely double clicking on this file will uncompress it. Rename folder as needed, in this case, ZK installed in ~/zookeeper-3.4.6

I’ve chosen /var/lib/zookeeper directory where ZK node’s config files reside. So, ZK node1

  • sudo mkdir /var/lib/zookeeper
  • Create zoo.cfg in ~/zookeeper-3.4.6/conf/
  • sudo mkdir /var/lib/zookeeper/1

For an ensemble, each ZK node needs to know and able to communicate with other nodes. The zoo.cfg enables this capability with the following config.
Zookeeper-ensemble-of-3-nodes-on-Mac
Similarly for ZK2 and ZK3create 3 following directories representing ‘dataDir’ for node2 and node3.

sudo mkdir /var/lib/zookeeper/2
sudo mkdir /var/lib/zookeeper/3

Create node1 myid file (with out file extension) and insert number 1 (nothing else in the file)
sudo vi /var/lib/zookeeper/1/myid
Create node2 myid file (with out file extension) and insert number 2 (nothing else in the file)
sudo vi /var/lib/zookeeper/2/myid
Create node3 myid file (with out file extension) and insert number 3 (nothing else in the file)
sudo vi /var/lib/zookeeper/3/myid

From Solr documentation the significance of myid file is

The id in the myid file on each machine must match the “server.X” definition. So, the ZooKeeper instance (or machine) named “server.1” in the above example must have a myid file containing the value “1”.

Create two more copies of zoo.cfg for node2 and node3 and update the dataDir and clientPort properties as follows.

cd ~/zookeeper-3.4.6/conf
cp zoo.cfg zoo2.cfg
cp zoo.cfg zoo3.cfg

Ensure zoo2.cfg & zoo2.cfg files have following properties set.

Zookeeper-ensemble-of-3-nodes-on-Mac
Zookeeper-ensemble-of-3-nodes-on-Mac

Now, start each zk instance (provide your mac password for sudo when asked)

cd ~/zookeeper-3.4.6/bin
sudo ./zkServer.sh start zoo.cfg
sudo ./zkServer.sh start zoo2.cfg
sudo ./zkServer.sh start zoo3.cfg

To stop each zk instance

sudo ./zkServer.sh start zoo.cfg
sudo ./zkServer.sh start zoo2.cfg
sudo ./zkServer.sh start zoo3.cfg

Check zk processes are running on your Mac
ps -ef | grep zoo

Explore Additional Resources

Learn how you can select the best Digital Experience platform for your business.

If you’d like to learn more about Adobe Experience Manager, visit our Adobe Practice.


GET HELP FROM OUR EXPERTS

Over the past 19 years, we have completed thousands of digital projects globally. We have one of the largest and deepest multi-solutions digital consulting teams in the world. Our proprietary processes and years of Digital Experience expertise have earned us a 97% customer satisfaction rating with our clients ranging from Global Fortune 1000 to Mid-Market Enterprises, leading educational institutions, and Non-Profits

About TA Digital

TA Digital is an innovative digital transformation agency, specializing in delivering the digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions.

Tags: