Zookper is a distributed, open-source collaborative service that is applied to distributed applications. It provides some simple operations so that distributed applications can implement services such as synchronization, configuration maintenance, and sharding or naming based on these interfaces. There are a lot of installation tutorials on the Internet, some of which are really good, but there are always some pitfalls that mislead everyone about installation. This time I personally experienced it, the installation steps and problems encountered during installation are released for everyone to learn.
First, download the zookeeper installation package. : Http://apache.claz.org/zookeeper/zookeeper-3.4.5/ through the following command: wget http://apache.claz.org/zookeeper/zookeeper-3.4.5/
Then go to the directory and decompress: tar zxvf zookeeper-3.4.5.tar.gz
Modify zoo_sample.cfg under the zookeeper-3.4.5/conf directory to zoo. cfg. Run the following command: mv zoo_sample.cfg zoo. cfg.
The content of the configuration file is as follows:
TickTime = 2000
DataDir =/home/Hadoop/zookeeper/data
ClientPort = 2181
InitLimit = 10
SyncLimit = 5
Server.1 = Master. Hadoop: 2888: 3888
Server.2 = Slave1.Hadoop: 2888: 3888
Server.3 = Slave2.Hadoop: 2888: 3888
Each field has its own meaning. If you are interested, you can view the meaning of relevant fields on your own. The following server.1, server.2, and server.3 labels indicate three zookeeper nodes, all of which share the same status. At work, they use an algorithm to recommend a leader and all others are follower, you can see in the subsequent verification. Shows his service:
Publish to the other two nodes (note your directory before running ):
Scp-r zookeeper-3.4.5/hadoop@Slave1.Hadoop :~ /Zookeeper/
Scp-r zookeeper-3.4.5/hadoop@Slave2.Hadoop :~ /Zookeeper/
Set myid to create a myid file under the directory specified by dataDir, which contains a number to identify the current host, conf/zoo. the server configured in the cfg file. why is the number of X in X entered in the myid file? For example:
Hadoop @ Master :~ /Zookeeper $ echo "1">/home/hadoop/zookeeper/myid
Hadoop @ Slave1 :~ /Zookeeper $ echo "2">/home/hadoop/zookeeper/myid
Hadoop @ Slave2 :~ /Zookeeper $ echo "3">/home/hadoop/zookeeper/myid
Start zookeeper
Hadoop @ Master :~ // Zookeeper/zookeeper-3.3.4 $ bin/zkServer. sh start
Hadoop @ Slave1 :~ // Zookeeper/zookeeper-3.3.4 $ bin/zkServer. sh start
Hadoop @ Slave2 :~ // Zookeeper/zookeeper-3.3.4 $ bin/zkServer. sh start
Because the three nodes are started sequentially, when the three nodes are started one after another, some errors will be reported when the node that is started first connects to the node that is not started. Can be ignored.
A problem occurs. The following shows how to view logs:
Check and find that there is a problem with the directory written in the configuration file zoo. cfg. The directory configured is different from the directory created for myid. It is easy to find problems in step 1. Modify the directory of myid.
Check whether the operation is successful.
The status of the following three nodes is detected:
ZooKeeper details: click here
ZooKeeper: click here
ZooKeeper cluster configuration
Use ZooKeeper to implement distributed shared locks
Distributed service framework ZooKeeper-manage data in a distributed environment
Build a ZooKeeper Cluster Environment
Test Environment configuration of ZooKeeper server cluster
ZooKeeper cluster Installation