192.168.2.2
192.168.2.4
Lets assign a unique ID to each computer (ID taken from 1 to 255), said, we assign 192.168.2.2 with id = 1, and assign 192.168.2.4 with id = 2.
Firstly lets setup the Zookeeper on each machine. This can be done by following instructions in http://czcodezone.blogspot.sg/2014/11/setup-zookeeper-on-single-machine.html
Once the zookeeper is setup, log into the terminal of each computer, create a "zookeeper" folder under /var directory and create a myid file in it to contains the unique id assigned to the computer, by running the following commands:
> cd /var
> sudo mkdir zookeeper
> sudo chmod -R 777 zookeeper
> cd zookeeper
> sudo touch myid
> sudo gedit myid
In the myid opened, put the unique id and save the file. For example the content of myid file on 192.168.2.2 is
1
and the content of myid file on 192.168.2.4 is
2
Now navigate to the ZK_HOME directory on each computer and update the zoo.cfg in the conf sub-directory, by running the following commnads:
In the zoo.cfg file, write the following as its content:
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.2.2:2888:3888
server.2=192.168.2.4:2888:3888
Save and close the zoo.cfg file. Run start the zookeeper on each computer by running the following commands in their terminal:
To check the status of the zookeeper cluster, type the following command in each computers' terminal:
To stop a zookeeper on a computer, run the following command:
Common problems encountered will cause the zkServer.sh status command to display the following messages:
Error contacting service. It is probably not running.
When this message appeared, it may be because one of the computer is not connected to the network (e.g. the ethernet cable is loose). In this case, try to ping each computer to see if they are connected.
Another caution is to make sure the the /var/zookeeper folder on each computer has write permission (e.g. by running the "sudo chmod -R 777 /var/zookeeper" command in the terminal)
> cd $ZK_HOME
> cd conf
> gedit zoo.cfg
In the zoo.cfg file, write the following as its content:
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.2.2:2888:3888
server.2=192.168.2.4:2888:3888
Save and close the zoo.cfg file. Run start the zookeeper on each computer by running the following commands in their terminal:
> cd $ZK_HOME
> bin/zkServer.sh start
To check the status of the zookeeper cluster, type the following command in each computers' terminal:
> cd $ZK_HOME
> bin/zkServer.sh status
To stop a zookeeper on a computer, run the following command:
> cd $ZK_HOME
> bin/zkServer.sh stop
Common problems encountered will cause the zkServer.sh status command to display the following messages:
Error contacting service. It is probably not running.
When this message appeared, it may be because one of the computer is not connected to the network (e.g. the ethernet cable is loose). In this case, try to ping each computer to see if they are connected.
Another caution is to make sure the the /var/zookeeper folder on each computer has write permission (e.g. by running the "sudo chmod -R 777 /var/zookeeper" command in the terminal)
No comments:
Post a Comment