1 Download Zookeeper installation package
http://apache.fayea.com/zookeeper/
I downloaded the zookeeper-3.4.6.tar.gz.
2 Decompression
Copy the zookeeper-3.4.6.tar.gz to the/usr/local directory
Execute command TAR-ZXVF zookeeper-3.4.6.tar.gz
After extracting the directory for zookeeper-3.4.6, for convenience, change the directory to ZOOKEEPER,MV zookeeper-3.4.6 zookeeper
3 Configuration
To simulate 3 distributed nodes, you need to create three-node configuration files zoo1.cfg, zoo2.cfg, zoo3.cfg
Cd/usr/local/zookeeper/conf
Rename Zoo_sample.cfg to Zoo1.cfg
MV Zoo_sample.cfg Zoo1.cfg
CP Zoo1.cfg Zoo2.cfg
CP Zoo1.cfg Zoo3.cfg
The ZOO1.CFG is configured as follows (note the Red Spot below)
Note: The above hadoop3 is my machine name, can be written 127.0.0.1
The ZOO2.CFG is configured as follows
The ZOO3.CFG is configured as follows
Create a directory that zookeeper save data
Mkdir-p/USR/LOCAL/ZOOKEEPER/DATA/ZK1
Mkdir-p/USR/LOCAL/ZOOKEEPER/DATA/ZK2
Mkdir-p/USR/LOCAL/ZOOKEEPER/DATA/ZK3
4 Configuration Instructions
- Ticktime: This time is the time interval between the Zookeeper server or between the client and the server to maintain the heartbeat, that is, each ticktime time sends a heartbeat.
- 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 Leader that is connected to Follower in the Zookeeper server cluster) Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. The client connection failed when the Zookeeper server has not received the return information of the client after 10 heartbeats (that is, ticktime) length. The total length of time is 10*2000=20 seconds.
- Synclimit: This configuration item identifies the length of time that a message, request and response is sent between Leader and Follower, the maximum number of ticktime, and the total length of time is 5*2000=10 seconds
- DataDir: As the name implies is Zookeeper to save the data directory, by default, Zookeeper will write the data log file is also stored in this directory.
- ClientPort: This port is the port that the client connects to the Zookeeper server, Zookeeper listens to the port and accepts the client's access request.
- Server. A=b:c:d: Where A is a number, indicating this is the first server, B is the IP address of this server, C is the server and the Leader server in the cluster to exchange information on the port; D means that in case the Leader server in the cluster hangs, a port is needed to re-elect , select a new Leader, which 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.
5 Creating node Identities in/usr/local/zookeeper/data/zk1,/usr/local/zookeeper/data/zk3,/USR/LOCAL/ZOOKEEPER/DATA/ZK3 Three directories to create the myID file, respectively, write 1, 2, 3 to identify the number of serverVi/usr/local/zookeeper/data/zk11
Vi/usr/local/zookeeper/data/zk12
Vi/usr/local/zookeeper/data/zk13
6 Start zookeepercd/usr/local/zookeeper/
7 Viewing the Startup status
You can see the Management node on server # 3rd
8 If you want to stop the server, use the following command./bin/zkserver.sh stop conf/zoo1.cfg
./bin/zkserver.sh Stop Conf/zoo2.cfg
./bin/zkserver.sh Stop Conf/zoo3.cfg
9 Verifying the correctness of the zookeeper installation
./bin/zkcli.sh-server 127.0.0.1:2183
Note: Due to the above leader on server 3rd, the client connection port of server 3rd is 2183
After successful execution:
Watcher::
Watchedevent state:syncconnected Type:none Path:null
[zk:127.0.0.1:2183 (CONNECTED) 0]
View Help:
Test
At this point, the Zookeeper installation is complete.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Zookeeper Pseudo-distributed installation