Zookeeper Installation Learning (ZOO.CFG configuration details)

Source: Internet
Author: User
1.1 Preparation before installation

1.JAVA6 Environment Requirements Installation
If you are running under windows conditions with zookeeper, you should install Cygwin.
2. Download the stable release zookeeper in hhtp://hadoop.apache.org/zookeeper/releases.html and unzip it in the right place.

% tar xzf zookeeper-x.y.z.tar.gz


3. Placing the following in the command-line path will facilitate subsequent work:
% export zookeeper_install=/home/tom/zookeeper-x.y.z
% export path= $PATH: $ZOOKEEPER _install/bin


4. Before running ZOOKEEPR, a configuration file should be established, named Zoo.cfg by convention, and placed under the Conf subdirectory, or it can be placed under/etc/zookeeper.
ticktime=2000 (is zookeeper independent working time unit)
Datadir=/users/tom/zookeeper (address of the stored data)
clientport=2181 (2181 is a regular choice, Here is the place where users and zookeeper are connected)

After you have completed the above process, you are ready to deploy zookeeper.

1.2 Standalone Mode
1 Configuring the Conf/zoo.conf file
ticktime=2000
datadir=/usr/zdatadir
datalogdir=/usr/zlogdir
clientport=2181
initlimit=5
synclimit=2

Ticktime
The base unit of events, in milliseconds. It is used to control the heartbeat and timeout, by default the minimum session time-out is twice times the ticktime.
DataDir is the location where the memory database snapshot is stored;
Datalogdir is the transaction log directory;
ClientPort is the port that the client connects to.
2 Starting the server
Execute command
bin/zkserver.sh Start
bin/zkcli.sh–server 127.0.0.1:2181


1.3 Copy Mode
Zookeeper run in standalone mode can be easily tested, evaluated, developed, but in practical applications zookeeper run in the so-called replication mode, we have the same configuration file for all machines in a quorum,quorum that provide the same application server group ., here we take the five machine quorum as an example, the specific configuration is as follows.
1. Configuring the Conf/zoo.conf File
ticktime=2000
datadir=/usr/zdatadir
datalogdir=/usr/zlogdir
clientport=2181
initlimit=5
synclimit=2
server.1=cloud:2888:3888
server.2=cloud02:2888:3888
server.3=cloud03:2888:3888
server.4=cloud04:2888:3888
server.5=cloud05:2888:3888

where Server. X represents the machine that makes up the entire service, and when the service starts, it finds the file myID in the data directory, which contains the server's number.

Initlimit:This configuration item is used to configure the Zookeeper accept client (the client here is not the client that connects the Zookeeper server, but the Zookeeper server cluster that is connected to the Leader Follower Serverthe maximum number of heartbeat intervals that can be tolerated when initializing a connection. The client connection failed when the zookeeper server has not received the return information of the client after 5 heartbeats (that is, ticktime) length. The total length of time is 5*2000=10 seconds.
Synclimit:This configuration entry identifies the length of time that a message is sent between Leader and Follower, the duration of the request and the response, and the maximum number of ticktime, the total length of time is 2*2000=4 seconds
server. A=B:C:D:Where A is a number, indicating this is the first server; B is the IP address of this server, and C is the port that the server exchanges information with the Leader server in the cluster, and D means that in case the Leader server in the cluster is hung up, a port is needed to re-elect the new Leader This port is the port that the server communicates with each other when the election is performed. If it is a pseudo-cluster configuration, because B is the same, so different Zookeeper instance communication port numbers can not be the same, so they should be assigned a different port number.

In addition to modifying the Zoo.cfg configuration file, in the cluster mode also configure a file myID, this file in the DataDir directory, the file has a data is a value, Zookeeper will read this file when it starts, and get the data inside to compare with the configuration information inside the ZOO.CFG to determine the server.

2 myID Configuration
Create a new myID file in a directory defined by DataDir, this example creates a new myID file [/b][/color] under/usr/zdatadir and fills in the IDs of each host. such as the Cloud machine's myID file content is 1.

3 Configuring the/etc/sysconfig/iptables file
Add in/etc/sysconfig/iptables:
-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 2181–j ACCEPT
 -A rh-firewall-1-input-m State--sta Te new-m tcp-p tcp--dport 2888–j ACCEPT
 -A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 3888–j ACCEPT

Execute command:
Service iptables Stop
       service iptables start

4 starting the server
Execute command
bin/zkserver.sh Start
           bin/zkcli.sh–server 127.0.0.1:2181


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.