1. Download and unzip
zookeeper:http://www.apache.org/dyn/closer.cgi/zookeeper/
Unzip to a specific directory when the download is complete
2. Zooker Configuration
Zookeeper cluster mode requires at least 3 hosts to be built, ready for three hosts Serve1, Server2, Server3
» Create a myID file in the Conf directory of zookeeper, the contents of the Server1 machine are: 1,server2 the contents of the machine are: 3
» Create a profile in the Conf directory Zoo.cfg (the most important of the red):
ticktime=2000datadir=/users/zdandljb/zookeeper/datadatalogdir=/users/zdandljb/zookeeper/ Datalogclientport=2181initlimit=5synclimit=2server.1=server1:2888:3888server.2=server2 : 2888:3888server.3=server3:2888:3888
After the configuration is completed, distribute the configuration files to other hosts;
Parameter explanation:
ticktime: Heartbeat interval, Unit: milliseconds
datadir:zookeeper The directory where the data is stored.
ClientPort: The client connects to the port of the Zookeeper server, Zookeeper listens to the port and accepts the client's access request.
Initlimit: This configuration item is used to configure Zookeeper Accept client (the client is not the client that is connected to the Zookeeper server,
Instead, the Zookeeper server cluster is connected to the Leader follower server) The maximum number of heartbeat intervals that can be tolerated when the connection is initialized.
The client connection failed when the Zookeeper server has not received the return information of the client after 5 heartbeats (that is, ticktime) length.
The total length of time is 5*2000=10 seconds.
Synclimit: This configuration item identifies the length of time that a message, request and response is sent between Leader and Follower, and the maximum number of ticktime is not exceeded.
The total length of time is 2*2000=4 seconds.
server. A=B:C:D: where
A is a number that indicates this is the first server;
B is the IP address of this server;
C represents the port where the server exchanges information with the Leader server in the cluster;
D means that in case the Leader server in the cluster is hung up, a port is required to re-elect, a new Leader is selected,
This port 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 cannot be the same, so assign them different port numbers.
3. Configuring Zookeeper Environment variables
$ vim/root/.bash_profile# Write path= $PATH:/usr/local/zookeeper-3.4.6/bin
4. Start zookeeper (all nodes are started)
$ cd/usr/local/zookeeper$ bin/zkserver.sh start# show: Starting zookeeper ... STARTED indicates successful start
Zookeeper 2, Zookeeper Installation and configuration (cluster mode)