DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • The Production-Ready Kubernetes Service Checklist
  • 10 Best Practices for Managing Kubernetes at Scale

Trending

  • Implementing Explainable AI in CRM Using Stream Processing
  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • AI Agents: A New Era for Integration Professionals
  • Securing the Future: Best Practices for Privacy and Data Governance in LLMOps
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How to Setup Zookeeper Cluster

How to Setup Zookeeper Cluster

In this article, a software engineer will discuss how to setup a Zookeeper cluster with 3 nodes, giving you the knowledge to create as many nodes as you need.

By 
Gaurav Garg user avatar
Gaurav Garg
·
May. 27, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
44.9K Views

Join the DZone community and get the full member experience.

Join For Free

In my previous article, I discussed how to set up Zookeeper with a single node. For better reliability and high availability of the Zookeeper service, we should set up Zookeeper in cluster mode. In this article, I will discuss how to setup a Zookeeper cluster with 3 nodes. Zookeeper clusters are also called Zookeeper ensembles. At the end of this article, you will be able to set up an ensemble with as many nodes as you desire. 

Download Zookeeper from here.

Extract the zip file. Make two extra copies of the extracted folder. Add the suffixes _1,_2,_3 to these folders' names. So if your extracted folder was zookeeper-3.4.12,now you will have three folders with the names zookeeper-3.4.12_1, zookeeper-3.4.12_2, zookeeper-3.4.12_3. 

  1. Go to the zookeeper-3.4.12_1 directory.  

  2. Create two folders with the names data and logs inside Zookeeper's home directory.

  3. Execute the command  echo "1" > data/myid. This is the server id in the ensemble. The id must be unique within the ensemble and should have a value between 1 and 255.

  4. Go to the conf folder and change the name of the zoo_sample.cfg file to zoo.cfg.

  5. Change dataDir with the full path of the data folder that we created in the above step.

  6. Set the clientPort to 2181.

  7. Paste the below lines into the zoo.cfg file.

server.1=localhost:2891:3881
#1 is the id that we put in myid file.
server.2=localhost:2892:3882
#2 is the id that we will put in myid file of second node.
server.3=localhost:2893:3883
#3 is the id that we will put in myid file of third node.

Zookeeper will use these ports (2891, etc.) to connect the individual follower nodes to the leader nodes. The other ports (3881, etc.) are used for leader election in the ensemble.

Our configuration is ready for the first node. For the other two folders or nodes, perform the same steps as mentioned above with the following changes.

  • In step 3, change the command to echo "2" > data/myid and echo "3" > data/myid respectively.

  • In step 6, change the port to 2182 and 2183, respectively.

Now our configuration is ready. Go to the home directory of each folder and the execute command:

 java -cp zookeeper-3.4.12.jar:lib/log4j-1.2.17.jar:lib/slf4j-log4j12-1.7.25.jar:lib/slf4j-api-1.7.25.jar:conf org.apache.zookeeper.server.quorum.QuorumPeerMain conf/zoo.cfg >> logs/zookeeper.log & 

Check the logs to see whether your cluster is ready or not.

Conclusion  

We discussed how to set up an ensemble with 3 nodes. Now you can create an ensemble with as many nodes as you want by making a few changes.

cluster

Opinions expressed by DZone contributors are their own.

Related

  • Can You Run a MariaDB Cluster on a $150 Kubernetes Lab? I Gave It a Shot
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • The Production-Ready Kubernetes Service Checklist
  • 10 Best Practices for Managing Kubernetes at Scale

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!