Zookeeper cluster environment installation and configuration

Source: Internet
Author: User
Tags mkdir zookeeper iptables java web firewall

Original: From my Linux blog http://blog.csdn.net/unix21/

Zookeeper version: 3.4.5

Convention: 3 Virtual machines

Prerequisites: Need to install JDK, about Linux environment JDK installation configuration reference my other post Linux environment Security loading JDK and installing Tomcat and publishing Java Web programs


Zookeeper Official website: http://zookeeper.apache.org/

1. Download Unzip

# wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz

# tar ZXVF zookeeper-3.4.5.tar.gz

# CD zookeeper-3.4.5


2. Configuration

1). Create Data Catalog

# mkdir Data


2). Edit the configuration file

# cd/usr/zookeeper-3.4.5/conf

Conf directory change file name zoo_sample.cfg to Zoo.cfg

# MV Zoo_sample.cfg Zoo.cfg

# vim./conf/zoo.cfg

#dataDir =/tmp/zookeeper
datadir=/usr/zookeeper-3.4.5/data
clientport=2181
initlimit=10
Synclimit=5
ticktime=2000
server.1=192.168.1.1:2888:3888
server.2=192.168.1.2:2888:3888
server.3=192.168.1.3:2888:3888
Be careful not to write the IP wrong, otherwise it will be reported strange error after startup.


Snapshots are required #mkdir data
If a transaction is required #mkdir Datalog
Create a new profile zoo.cfg, save it in the Conf subdirectory, and write the following:

ticktime=# Zookeeper server heartbeat time, per millisecond
datadir= # Data Persistence path
clientport=# Connection Port
Initlimit=# voted to elect the initial time of the new leader.
synclimit=# The maximum response time unit between leader and follower, response more than Synclimit*ticktime,leader think Follwer hung off, remove from server list Follwer
datalogdir=# Log Save path this to build their own, the specific directory according to their actual circumstances prevail.

3). Add myID file

# Cd/usr/zookeeper-3.4.5/data

Create the file in the data directory, the file name is "myID", edit the "myID" file, and enter the corresponding number on the corresponding IP machine.

As in the 192.168.1.1, "myID" file content is 1, on the 192.168.1.2, the content is 2, on the 192.168.1.3, the content is 3


3. Modify the firewall

If you are using iptable, add the zookeeper port to the/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
To perform a firewall restart command:
# Service Iptables Restart


4. Start Zookeeper

Start
#/usr/zookeeper-3.4.5/bin/zkserver.sh Start
[Root@localhost conf]#/usr/zookeeper-3.4.5/bin/zkserver.sh start
JMX enabled by default
Using config:/usr/zookeeper-3.4.5/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED

Stop it
#/usr/zookeeper-3.4.5/bin/zkserver.sh Stop

Restart
#/usr/zookeeper-3.4.5/bin/zkserver.sh Restart


5. Check the status
#/usr/zookeeper-3.4.5/bin/zkserver.sh Status

You may need to install the NC package
# Yum Install NC


Zookeeper will automatically elect leader, once the leader is hung, a new leader will be chosen.

Leader/follower will choose through an electoral algorithm.

6. Client Login
#/usr/zookeeper-3.4.5/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.