Wednesday, November 9, 2016

Zookeeper HA config

URL: http://jayatiatblogs.blogspot.in/2012/11/setting-up-zookeeper-cluster.html
1. Obtain the zookeeper setup at some location. Setup can be downloaded from :
http://hadoop.apache.org/zookeeper/releases.html

2. Create a file with any name (eg. zoo.cfg) in the /etc/zookeeper/conf folder of the copied setup and write in it
dataDir=/var/zookeeper/                                                                  
clientPort=2181
initLimit=5
syncLimit=2
server.server1=zoo1:2888:3888                              
server.server2=zoo2:2888:3888
server.server3=zoo3:2888:3888                                                      

Here 2888 and 3888 ports cannot be modified but the server.id(server.server1) and the zkServerName(zoo1) can be changed by the user. Using the above entries as sample entries, next it is required that a file named “myid” be created in the path specified in dataDir which contains just one entry which is of the server id. So the first system of the cluster would have a file named "myid" created at the path specified in dataDir containing server1 and so on i.e.
To make it more clear, if we are using 3 systems with IP 192.192.192.191, 192, 193
and zoo1 would designate 192.192.192.191, zoo2 would designate 192.192.192.192, zoo3 would designate 192.192.192.193
then
the machine 192.192.192.191 should contain a file called myid at /var/zookeeper/ (or the value of dataDir specified in zoo.cfg) containing the following entry
server1
Similarly machines 192.192.192.192 and 192.192.192.193 should have entries server2 and server3 respectively.

3. Update the /etc/hosts file on each machine to add the host names being used in the zookeeper configuration. This is needed so as to make it understandable that zoo1, zoo2 and zoo3 refer to which systems.
Post-updation the /etc/hosts file on each system in the cluster would have a similar set of entries like :
192.192.192.191   zoo1
192.192.192.192   zoo2                                                                    
192.192.192.193   zoo3

4. Add leaderServes=yes property in master node zoo.cfg file to tell which Zookeeper node is master
  maxClientCnxns=4000
        tickTime=2000
        initLimit=10
        syncLimit=5
        dataDir=/var/lib/zookeeper
        clientPort=2181
        minSessionTimeout=40000
        maxSessionTimeout=40000
        server.server1=192.192.192.191:3181:4181
        server.server2=192.192.192.192:3181:4181
        server.server3=192.192.192.193:3181:4181
        leaderServes=yes

5. This completes the configuration part, next cd to the zookeeper home and start the cluster by running
/usr/lib/zookeeper/bin/zkServer.sh start

No comments: