Zookerper Cluster Build (version: zookeeper-3.4.4)
3 Machines deployed zookeeper cluster, IP and hostname correspondence are as follows:
| Ip |
Host Name |
| Main control node: 192.168.1.147 |
Zoo1 |
| Working node 1:192.168.1.142 |
Zoo2 |
| Working node 2:192.168.1.143 |
Zoo3 |
First, on the main control node
1. Install Java environment variable (version: Java version "1.6.0_31") Note: Three nodes require installation configuration
# chmod O+x Jdk-6u31-linux-x64-rpm.bin Authorized
#./jdk-6u31-linux-x64-rpm.bin follow the prompts to press ENTER once the installation succeeds
Make a soft connection:
#ln-S/usr/java/jdk1.6.0_31//usr/java/jdk
To configure a Java environment variable:
Export Java_home=/usr/java/jdkexport java_bin=/usr/java/jdk/binexport path= $PATH: $JAVA _home/binexport CLASSPATH=$ Java_home/lib/dt.jar: $JAVA _home/lib/tools.jarexport java_home java_bin PATH classpat#set ZooKeeper enviromentexport Zookeeper_home=/usr/local/src/zookeeper-3.4.4export path= $PATH: $ZOOKEEPER _home/bin: $ZOOKEEPER _home/conf
To make a variable effective:
# Source/etc/profile
2. Change the host name, turn off the firewall and SELinux (each host is executed)
# Service Iptables Stop
# Setenforce 0
3. Change the Hosts file:
# vim/etc/hosts
192.168.1.147 zoo1
192.168.1.142 Zoo2
192.168.1.143 Zoo3
4, Decompression zookeeper to/usr/local/src/configuration Zookeeper master configuration file:
Rename/usr/local/src/zookeeper-3.4.4/conf/zoo_sample.cfg to Zoo.cfg
#mv zoo_sample.cfg zoo.cfg
To configure the master configuration file:
Vim/usr/local/src/zookeeper-3.4.4/conf/zoo.cfg
ticktime=2000
initlimit=10
Synclimit=5
datadir=/var/zookeeper/
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
Save exit
Create a myID file in the DataDir directory that contains only one row and the content is the ID number in the server.id that corresponds to that node.
# mkdir/var/zookeeper/
# echo "1" >/var/zookeeper/myid (the work node also needs to create the corresponding ID number)
4. Copy the main control node zookeeper-3.4.4 to the two working nodes respectively
# SCP-RP zookeeper-3.4.4/ [email protected]:/usr/local/src/
# SCP-RP zookeeper-3.4.4/ [email protected]:/usr/local/src/
Second, the Working node 1
1. Configure the Java environment variable: Same as the main working node
2. Configuring the Hosts File
3, create the myID file in the DataDir directory, the file contains only one row, and the contents of the node corresponding to the ID number in the server.id.
# mkdir/var/zookeeper/
# echo "2" >/var/zookeeper/myid (the work node also needs to create the corresponding ID number)
Three, working node 2
1. Configure the Java environment variable: Same as the main working node
2. Configuring the Hosts File
3, create the myID file in the DataDir directory, the file contains only one row, and the contents of the node corresponding to the ID number in the server.id.
# mkdir/var/zookeeper/
# echo "3" >/var/zookeeper/myid (the work node also needs to create the corresponding ID number)
Four: Start zookeeper cluster
Execute on the master node:
# cd/usr/local/src/zookeeper-3.4.4/
#./bin/zkserver.sh Start
Execute on Work Node 1:
# cd/usr/local/src/zookeeper-3.4.4/
#./bin/zkserver.sh Start
Execute on Work Node 2:
# cd/usr/local/src/zookeeper-3.4.4/
#./bin/zkserver.sh Start
Then look at the working status of each node:
Execute on the master node:
# cd/usr/local/src/zookeeper-3.4.4/
#./BIN/ZKSERVER.SH Status
JMX enabled by default
Using config:/usr/local/src/zookeeper-3.4.4/bin/. /conf/zoo.cfg
Mode:follower
#./BIN/ZKSERVER.SH Status
JMX enabled by default
Using config:/usr/local/src/zookeeper-3.4.4/bin/. /conf/zoo.cfg
Mode:leader
#./BIN/ZKSERVER.SH Status
JMX enabled by default
Using config:/usr/local/src/zookeeper-3.4.4/bin/. /conf/zoo.cfg
Mode:follower
OK zookeeper cluster installed successfully
This article is from the "david0512" blog, make sure to keep this source http://gjr0512.blog.51cto.com/6518687/1590168
Zookerper Cluster Construction