Zookeeper cluster Installation

Source: Internet
Author: User

Zookeeper is a distributed service coordination system provided by Apache and widely used.

Kafka MQ is used in the project, while Kafka fully uses zookeeper to implement service coordination between Kafka components, including broker and consumer.

The Linux commands in this document start with # As the root user and start with $ as the zk user.

Create ZK user

# Groupadd ZK

# Useradd-G ZK

# Passwd ZK

Prepare the installation directory
  • Create the zookeeper data storage directory:

# Mkdir-P/data/zookeeper

# Chown-r ZK: zk/data/zookeeper

  • Use ZK users to create data and log directories:

$ Mkdir/data/zookeeper/Data

$ Mkdir/data/zookeeper/log

Install zookeeper
  • Decompress the zookeeper Binary Package:

# Cd/usr/local/src

# Tar -zxvfzookeeper-3.4.6.tar.gz-C/usr/local/

# Chown-r ZK: zk/usr/local/zookeeper-3.4.6
  • Modify the zookeeper configuration file:

$ CD/usr/local/The zookeeper-3.4.6/Conf

$ CP zoo_sample.cfg zoo. cfg

$ VI zoo. CGF

For details about how to modify the configuration, see datadir, datalogdir, and the list of Three zookeeper servers.

$ VI log4j. Properties

Modify zookeeper. log. dir. For the configuration, see,

  • Create a zookeeperserverid File

Create a file named myid in the data directory of zookeeper with the content serverid number. In the preceding configuration file, the myid content of the three zookeeper files is distributed as 1, 2, and 3.

$ CD/data/zookeeper/Data

$ Cat> myid

Enter 1, press enter, and then press Ctrl + D.
  • Modify the zk user's environment variables:

$ VI ~ /. Bash_profile

Add the red box to the file:

$ Source ~ /. Bash_profile

Repeat the preceding steps to install zookeeper to the other two and build one or three zookeeper clusters.

Start zookeeper
  • Start

All zookeeper in the cluster can be started using the following command:

$ Zkserver. Sh start


JMX enabled by default

Using config:/usr/local/zookeeper-3.4.6/bin/../CONF/zoo. cfg

Starting zookeeper... started

Run the following command to check whether zookeeper is successfully started:

$ Zkserver. Sh status

If the startup is successful, it is displayed on the leader's machine:

On the follower machine, the following information is displayed:


$ Zkserver. Sh stop

Zookeeper cluster Installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.