ZooKeeper cluster Installation

Source: Internet
Author: User

ZooKeeper cluster Installation

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 to 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 to 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 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. prZ runtime? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcGVydGllczwvcD4KPHA + forward + CjxwPjxpbWcgc3JjPQ =" http://www.2cto.com/uploadfile/Collfiles/20140724/2014072413344752.png "alt =" \ ">

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

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

$ ZkServer. sh start

Normally:

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:

Stop

$ ZkServer. sh stop

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.