First install VMware, installed two virtual machines, the version is Centos6.5,ip, respectively, is
192.168.3.20
192.168.3.21
Then download the Zookeeper package: http://zookeeper.apache.org/, use the command TAR-ZXVF zookeeper.tar.gz to extract the extract to the/opt/soft directory
Modify the hostname vim/etc/hosts to add two entries in the Hosts file
192.168.1.20 Master
192.168.1.21 slave1
Enter zookeeper directory, create folder data, enter data, create file myid,20 and 21 myID write 1 and 2 respectively
Enter the Conf directory, there is a profile template, copy one, name Zoo.cfg, modify Zoo.cfg, the content is as follows
Datadir=/opt/soft/zookeeper-3.4.5/data (The Data directory you just created)
clientport=2181
initlimit=10
Synclimit=5
ticktime=2000
server.1=master:2888:3888 (Zookeeper will find IP based on host name)
server.2=slave1:2888:3888
Shut down the firewall (if the firewall is not turned off, after the boot, will always error);
Execute command: bin/zkserver.sh start conf/zoo.cfg, respectively zookeeper
Then: tail-300f zookeeper.out View the contents of the output, if no error, indicating the success of the start;
Next look at the cluster is the success of the build:
Execution: Bin/zkcli.sh-server master:2181 (Master and slave1, choose one)
Go to the Zookeeper Client command line below, execute LS/, will output [zookeeper], this time create a node create/test, and then view get/test, print the information
TestValue
Czxid = 0x200000005
CTime = Fri Mar 15:07:23 PST 2017
Mzxid = 0x200000005
Mtime = Fri Mar 15:07:23 PST 2017
Pzxid = 0x200000005
cversion = 0
dataversion = 0
aclversion = 0
Ephemeralowner = 0x0
Datalength = 9
Numchildren = 0
Then switch to another IP, perform execution: Bin/zkcli.sh-server master:2181, then LS/view, you can see the node that was just created on another machine test
Above all through, explain zookeeper cluster build success!
Zookeeper cluster construction under Linux