3. Deploying zookeeper clusters in a Linux centos6.8 environment

Source: Internet
Author: User
Tags zookeeper

Install 3 machines as zookeeper cluster, 3 machine IP is 192.168.174.7,192.168.174.8,192.168.174.9 respectively. Zookeeper is written by Java, so install the JDK environment before installing zookeeper.

  1. Create zookeeper installation directories on 3 machines, respectively
    mkdir -p /usr/local/software/zookeeper
  2. Download the TAR package on the official website and unzip each of the 3 machines separately.
    tar -xvf zookeeper-3.4.11.tar.gz -C /usr/local/software/zookeeper/
  3. 3 Machines Enter the installation directory, rename the zoo.sample.cfg to Zoo.cfg, and modify the DataDir configuration to Datadir=/opt/data/zookeeper/data
  4. Start the cluster configuration, modify the Zoo.cfg file under 3 machines and add the following:
    server.1=192.168.174.7:2888:3888server.2=192.168.174.8:2888:3888server.3=192.168.174.9:2888:3888

    There are n servers on the SERVER.N. The IP address and port are configured later. The 2888 port is the port where the server exchanges information with the leader in the cluster, and 3888 is the port that the server communicates with each other at the time of the election.

  5. The myID file is created under the ${datadir} path of the 3 machine, which is the DataDir directory specified in the third step above, and only the number of the corresponding server is written in the myID file (the fourth step above) n. In this configuration, the server with IP 174.7 writes 1 to the file, and the other server writes n values (2,3 ...).
    mkdir -p /opt/data/zookeeper/datavim /opt/data/zookeeper/data/myid
  6. In order to execute the Zookeeper command conveniently, configure the Zookeeper environment variable.
    vim /etc/profile

    Add the following content to the file:

    export ZOOKEEPER_HOME=/usr/local/software/zookeeper/zookeeper-3.4.11export PATH=$PATH:$ZOOKEEPER_HOME/bin
  7. Start each of the three zookeeper and see the roles of each machine, leader or follower
    Open Zookeeper Service
    zkServer.sh start

    View Zookeeper Status

    zkServer.sh status

    When the first set is turned on, the view status display is not running, and when at least two units are turned on, the cluster mode will be normal before the leader and follower are elected, and if an error is initiated, check the Zookeeper.out log file under ${datadir}.

3. Deploying zookeeper clusters in a Linux centos6.8 environment

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.