Catalog
The goal is
- understand ZooKeeper essential information ;
- Be familiar with the configuration ZooKeeper colony .
brief introduction
ZooKeeper Is used to maintain configuration information , name , A centralized service that provides distributed synchronization and group services .ZooKeeper The goal is to refine the nature of these different services into a very simple interface , To achieve centralized coordination services .
To configure ZooKeeper colony
Environmental preparation
Three stations Linux virtual machine , And they all have JDK Environmental Science .
Configuration steps
First step : Click to enter ZooKeeper Official website , download Linux Version of ZooKeeper Installation package ( This article takes apache-zookeeper-3.6.2-bin.tar.gz Version as an example .);
The second step : Upload apache-zookeeper-3.6.2-bin.tar.gz To /opt Catalog ( A little );
The third step : Unzip the file :
tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz
Step four : stay /opt/apache-zookeeper-3.6.2-bin/conf Create under directory zoo.cfg file , Configure related parameters :
# With zoo_sample.cfg As a template , establish zoo.cfg file .
cp /opt/apache-zookeeper-3.6.2-bin/conf/zoo_sample.cfg /opt/apache-zookeeper-3.6.2-bin/conf/zoo.cfg
#################zoo.cfg The contents of the configuration file are as follows :#################
#ZooKeeper The basic unit of time used ( millisecond ). It's used for heart beating , And the minimum session timeout will be tickTime Twice as many .
tickTime=2000
# The location where the in memory database snapshot is stored , Unless otherwise stated , Otherwise, it stores the transaction log updated by the database .
dataDir=/opt/apache-zookeeper-3.6.2-bin/data
# Port used to listen for client connections .
clientPort=2181
#ZooKeeper The server must be connected to leader Length of time . The length of time set here is 10 second (initLimit*tickTime).
initLimit=5
# Limit the timeout range between the server and the host . The time range set here is 4 second (syncLimit*tickTime).
syncLimit=2
#server.1 Medium 1 Show custom ZooKeeper Service for ID yes 1.
#192.168.120.xxx Express ZooKeeper Of the host server IP.
#2888 Indicates the use of machine communication within the cluster 2888 port .
#3888 To represent an election leader Use 3888 port .
server.1=192.168.120.100:2888:3888
server.2=192.168.120.101:2888:3888
server.3=192.168.120.102:2888:3888
Step five : According to the configuration dataDir、server.ID、IP Create a new catalog and define a service number ;
# new directory
mkdir /opt/apache-zookeeper-3.6.2-bin/data
# establish myid File and write the content as 1, It's actually configuration server.ID by 1.
echo 1 > /opt/apache-zookeeper-3.6.2-bin/data/myid
Step six : Repeat the above steps for the other two virtual machines , Be careful : The fifth step is to zoo.cfg The content is the standard of operation ( A little ).
start-up ZooKeeper colony
############# stay /opt/apache-zookeeper-3.6.2-bin/bin Execute under directory :#############
# start-up
./zkServer.sh start
# Check the status
./zkServer.sh status
# restart
./zkServer.sh restart
# stop it
./zkServer.sh stop