Installation and deployment of Zookeeper clusters

Source: Internet
Author: User
Tags zookeeper


One: Cluster environment

To simulate three zookeeper cluster environments,IP planning is as follows:

server1:192.168.189.129

server2:192.168.189.131

server3:192.168.189.132

II: Installation Environment preparation

The Zookeeper needs to be run in a Java environment, so the JDK needs to be installed before deploying the Zookeeper environment:

# TAR-ZVXF jdk-7u11-linux-x64.gz# mv jdk1.7.0_11//usr/local/java# Cd/usr/local/java/bin

set the Java environment variable and add the following information in the/etc/profile file:

# Export java_home=/usr/local/java# export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/ lib/tools.jar# export path= $PATH: $JAVA _home/bin make environment variable effective # Source/etc/profile

Three: Deploy the installation zookeeper ( For example , zookeeper-3.4.5 version)

Server1 on Deployment (the Zookeeper directory can be copied directly to Server2,server3 after deployment is complete )

Download zookeeper installation package, Unzip, configure:

# TAR-ZXVF zookeeper-3.4.5.tar.gz# MV Zookeeper-3.4.5.tar.gz/usr/local/zookeeper # cd/usr/local/zookeeper/conf# CP Zoo _sample.cfg zoo.cfg

Configure zoo.cfg, configure cluster options:

# Cat zoo.cfgticktime=2000 (Heartbeat time of server and client) Initlimit=10synclimit=5datadir=/zkdata/zookeeper (save data Directory, custom) Clientpor t=2181 (Client connection port, can change) server.1=192.168.189.129:2888:3888 (cluster configuration) server.2=192.168.189.131:2888:3888server.3=192.168. 189.132:2888:3888

Finished configuring Server1, copy the Zookeeper directory to Server2,server3:

# scp-rp/usr/local/zookeeper 192.168.189.131:/usr/local/# Scp-rp/usr/local/zookeeper 192.168.189.132:/usr/local/

in each Create the myID file under the DataDir directory of the Server :

Server1: #echo "1" >/zkdata/zookeeper/myidserver2: #echo "2" >/zkdata/zookeeper/myidserver3: #echo "3" >/zkdat A/zookeeper/myid


Four: Enable zookeeper

in each on the Server, turn on the Zookeeper service:

#/usr/local/zookeeper/bin/zkserver.sh Start

View Zookeeper Status:

#/usr/local/zookeeper/bin/zkserver.sh STATUSJMX enabled by Defaultusing config:/home/usr/local/zookeeper-3.4.5/bin/ .. /conf/zoo.cfgmode:follower (or leader)

The above information indicates that the Zookeeper service was successfully enabled and the cluster relationship between leader and follower was elected .

V: Test zookeeper cluster

Connect the leader server using client software ( assuming the leader is Server1)

#/usr/local/zookeeper/bin/zkcli.sh-server 192.168.189.129

Create a znode on the leaderand exit

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/86/DB/wKiom1fNOSGjHxVPAABNS4EHXZk713.png "title=" 1.png " alt= "Wkiom1fnosgjhxvpaabns4ehxzk713.png"/>

Connect The follower server to see if there is a previously created Znode

#/usr/local/zookeeper/bin/zkcli.sh-server 192.168.189.131

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/DA/wKioL1fNOUawKfTeAAASPB8yAB0639.png "title=" 2.png " alt= "Wkiol1fnouawkfteaaaspb8yab0639.png"/>

Discover that the follower server already has a znode created on the leader server stating that the cluster is in effect


This article from the "Play God Clown" blog, reproduced please contact the author!

Installation and deployment of Zookeeper clusters

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.