Zookeeper Installation and Configuration

Source: Internet
Author: User

the installation and configuration of the zookeeper is simple and can be configured as a stand-alone mode or as a cluster mode. The following will be described separately. Stand-alone mode

Click here to download the Zookeeper installation package and unzip to the appropriate directory. Enter the Conf subdirectory under the Zookeeper directory to create the ZOO.CFG:

Bash code
    1. ticktime=
    2. Datadir=/users/apple/zookeeper/data
    3. Datalogdir=/users/apple/zookeeper/logs
    4. clientport=4180

Parameter description:

    • The base time unit, millisecond value, used in Ticktime:zookeeper.
    • DataDir: Data directory. can be any directory.
    • The Datalogdir:log directory can also be any directory. If this parameter is not set, the same settings are used and DataDir.
    • ClientPort: Listens for the port number of the client connection.

So far, zookeeper's stand-alone mode has been configured. To start the server, simply run the script:

Bash code
    1. bin/zkserver.sh Start
After the server is started, you can start the Client connection server, execute the script: Bash code
    1. bin/zkcli.sh-server localhost:4180
Pseudo-Cluster mode

The so-called pseudo-cluster, is to start multiple zookeeper processes in a single machine, and form a cluster. Take the example of starting 3 zookeeper processes.

Copy 2 copies of the Zookeeper directory:

Bash code
    1. |--zookeeper0
    2. |--zookeeper1
    3. |--zookeeper2

Change the zookeeper0/conf/zoo.cfg file to:

Bash code
  1. ticktime=
  2. initlimit=5
  3. synclimit=2
  4. Datadir=/users/apple/zookeeper0/data
  5. Datalogdir=/users/apple/zookeeper0/logs
  6. clientport=4180
  7. server. 0=127.0. 0.1:8880:7770
  8. server. 1=127.0. 0.1:8881:7771
  9. server. 2=127.0. 0.1:8882:7772

Several new parameters have been added, meaning the following:

    • The Initlimit:zookeeper cluster contains more than one server, one of which is leader and the rest of the servers in the cluster are follower. The Initlimit parameter configures the maximum heartbeat time between follower and leader when the connection is initialized. At this point the parameter is set to 5, stating that the time limit is 5 times times ticktime, or 5*2000=10000ms=10s.
    • Synclimit: This parameter configures the maximum length of time to send messages, requests, and responses between leader and follower. At this point the parameter is set to 2, stating that the time limit is twice times ticktime, or 4000ms.
    • Server. X=A:B:C where x is a number that indicates which is the first server. A is the IP address where the server resides. b Configure the port used by the server and the leader in the cluster to exchange messages. C Configure the port to use when electing leader. Because the pseudo-cluster mode is configured, the B and C parameters of each server must be different.

Refer to Zookeeper0/conf/zoo.cfg, configure Zookeeper1/conf/zoo.cfg, and zookeeper2/conf/zoo.cfg files. Just change the DataDir, Datalogdir, clientport parameters.

Create a new myID file in the previously set DataDir, write a number that indicates the number of server. The number must correspond to x one by one in the server.x in the Zoo.cfg file.
Write 0 in the/users/apple/zookeeper0/data/myid file, write 1 in/users/apple/zookeeper1/data/myid file,/users/apple/zookeeper2/data/ Write 2 in the myID file.

Enter/users/apple/zookeeper0/bin,/users/apple/zookeeper1/bin,/users/apple/zookeeper2/bin three directories, and start the server respectively.
Select one of the server directories to start the client:

Bash code
    1. bin/zkcli.sh-server localhost:4180
Cluster mode

Cluster mode configuration and pseudo-cluster are basically consistent.
Because the server is deployed on different machines in cluster mode, the CONF/ZOO.CFG files for each server can be identical.
Here is an example:

Bash code
  1. ticktime=
  2. initlimit=5
  3. synclimit=2
  4. Datadir=/home/zookeeper/data
  5. Datalogdir=/home/zookeeper/logs
  6. clientport=4180
  7. server. =10.1. 39.43:2888:3888
  8. server. =10.1. 39.47:2888:3888
  9. server. =10.1. 39.48:2888:3888

The example deploys 3 zookeeper servers, each deployed on 10.1.39.43, 10.1.39.47, 10.1.39.48. It is important to note that the numbers in the myID file in the DataDir directory of each server must be different.

10.1.39.43 server myID, 10.1.39.47 server myID is a, 10.1.39.48 server of myID is 48.

Zookeeper Installation and Configuration

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.