Title This article describes the installation and configuration process for zookeeper, which is very simple and the key is how to apply it (will be presented in the next section and related sections).
stand-alone installation, configuration:
The installation is very simple, as long as you get the zookeeper package and extract to a directory such as:/home/frank/zookeeperinstall/zookeeper-3.3.3.
The configuration file is stored in the/conf/directory, changing the ZOO_SAMPLE.CFD file name to Zoo.cfg, and the default configuration is as follows:
# The number of milliseconds of each tick
ticktime=2000
# The number of ticks that the initial
# Synchronization phase can take
initlimit=10
# The number of ticks that can pass between
# Sending a request and getting an acknowledgement
Synclimit=5
# The directory where the snapshot is stored.
Datadir=/home/frank/zookeeperinstall/data//This is my revised
# The port at which the clients'll connect
clientport=2181
Ticktime: This time is as zookeeper between the server or between the client and the server to maintain the heartbeat time interval, that is, each ticktime time will send a heartbeat. DataDir: As the name implies is zookeeper save the data directory, by default, zookeeper will write the data log file also saved in this directory. ClientPort: This port is the port where the client connects to the zookeeper server, and zookeeper listens to the port to accept the client's access request.
When these configuration items are configured, you can now start zookeeper: Into the/bin directory $ zkserver.sh Start
To check if zookeeper is already in service after startup, you can see whether there is a ClientPort port number in the listening service through the Netstat–ano command.
cluster installation, configuration:
The installation and configuration of the zookeeper cluster model is not very complex, and all you have to do is add a few configuration items. In addition to the default configuration items, cluster mode increases the machine IP, port, and so on in the cluster at the end of the Zoo.cfg file:
server.1=192.168.0.101:2888:3888
Where to use the Initlimit, synclimit in the default configuration |
Initlimit: This configuration entry is used to configure the Zookeeper accept client (where the client is not the client that connects to the zookeeper server, but the Leader that is connected to the Follower in the Zookeeper server cluster) Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. This client connection fails when the Zookeeper server has not received the return information of the client after the 5 heartbeat time (i.e. ticktime) length has expired. The total length of time is 5*2000=10 seconds Synclimit: This configuration item identifies Leader and Follower send messages between the length of request and response time, the longest can not exceed the length of the ticktime, the total length of time is 2*2000=4 seconds ser Ver. A=b:c:d: Where A is a number that indicates what the server is, B is the IP address of the server, and C is the port where the server exchanges information with the Leader server in the cluster; D means that if the Leader server in the cluster hangs, a port needs to be returned for the election. To elect a new Leader, which is the port that the server communicates with each other at the time of the election. If it is a pseudo cluster configuration, because B is the same, so the different zookeeper instance communication port number can not be the same, so to assign them different port number.
In addition to modifying the Zoo.cfg configuration file, the cluster mode also has to configure a file myID, This file in the DataDir directory, This file contains a data is a value,zookeeper start will read this file, Get the data inside and compare the configuration information inside the zoo.cfg to determine what the server is.
Above is the configuration of the Namenode, with the SCP command to copy the/home/frank/zookeeperinstall of the Namenode node to the/home/frank directory of all the remaining hosts.
Finally, execute $ zkserver.sh start under/bin on all nodes, starting separately. In the process of starting separately, the exception is reported: 2011-05-16 15:07:21,171-warn [workersender thread:quorumcnxmanager@384]-Cannot open channel to 1 At election address/192.168.0.103:3888 Java.net.ConnectException:Connection refused at Sun.nio.ch.SocketChannelImpl.checkConnect (Native method) at Sun.nio.ch.SocketChannelImpl.finishConnect ( socketchannelimpl.java:567) at Sun.nio.ch.SocketAdaptor.connect (socketadaptor.java:100) at Org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne (quorumcnxmanager.java:371) at Org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend (quorumcnxmanager.java:340) at Org.apache.zookeeper.server.quorum.fastleaderelection$messenger$workersender.process (FastLeaderElection.java : 360) at Org.apache.zookeeper.server.quorum.fastleaderelection$messenger$workersender.run ( fastleaderelection.java:333) at Java.lang.Thread.run (thread.java:662) can be ignored because there are nodes that do not start the zookeeper, and when all is started, there is no exception. The $ zkcli.sh-server xxx.xxx.xxx.xxx:2181 can then be executed, and the check refers toSet whether the server started successfully.