Zookeeper: Https://github.com/apache/zookeeper/archive/master.zip
Zkclient: Https://github.com/sgroschupf/zkclient
As for the role and principle of zookeeper I here will not be more than to repeat, we are interested to find out, here is mainly hands-on operation.
Build a cluster
First take a look at the ZK experiment server name and IP situation, here we chose three servers for Zkserver, because three are standard, a set of words only leader no follower, not very stable structure, of course, if your company local tyrants words can play 30 sets:
dvl-mrszk-001 |
10.117.0.125 |
dvl-mrszk-002 |
10.117.1.158 |
dvl-mrszk-003 |
10.168.152.227 |
The following steps are needed for each of these three servers:
1) First upload zookeeper.zip to Linux, and then extract to/usr folder;
2) Enter the/usr/zookeeper/conf folder,#vim zoo.cfg, add the above three zkserver at the bottom, see figure:
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/8C/87/wKioL1hvPw_jqddTAAEsCsJGnek721.png "title=" 1.png "alt=" Wkiol1hvpw_jqddtaaescsjgnek721.png "/>
3) again to/usr/zookeeper/data folder, if there are files on the empty all files, if it is 1th zkserver on the # echo 1 > myID, if the current machine is 2nd # zkserver # echo 2 > myID, and so on, it's important to note that you can't write the same.
4)#vim/etc/hosts, also write the IP address and name of the three machines, as follows:
127.0.0.1 localhost::1 localhost localhost.localdomain localhost6 localhost6.localdomain610.117.0.125 dvl-mrszk-00 110.117.1.158 dvl-mrszk-00210.168.152.227 dvl-mrszk-003
5) again to/usr/zookeeper/bin folder,#./zkserver.sh start to start ZK, and then again./zkserver.sh Status View process status, See the first and third Zkserver identity is follower, the second is leader:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8C/8A/wKiom1hvQTCA8ClKAABZK7CdVUM709.png "title=" 1.png "alt=" Wkiom1hvqtca8clkaabzk7cdvum709.png "/>
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/8C/8A/wKiom1hvQXWQsW7GAABVF8iSiXs863.png "title=" 1.png "alt=" Wkiom1hvqxwqsw7gaabvf8isixs863.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/8C/8A/wKiom1hvQcnyJRLvAABVaQSSoYI199.png "title=" 1.png "alt=" Wkiom1hvqcnyjrlvaabvaqssoyi199.png "/>
At this point the entire ZK cluster is built and started to complete.
Validation results
The configuration tool for zookeeper is called Zooinspector, which is:
Https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip, download the direct decompression can be used in Windows.
We experimented with the three servers only intranet, but if you want to connect zooinspector, or need to connect through the external network permissions, here can be equipped with a iptables forwarding rules, with iptables steps here:/HTTP chenx1242.blog.51cto.com/10430133/1875950, divert, but note that ZK's port is 2181.
Of course, if you do not want to bother, directly to zkserver with an external network IP, directly connected.
Successfully connected to Zooinspector, you will see this content, here Lcconfig is manually added, right click on the mouse, select Add node, and then directly write on the lcconfig on the line, the name is based on the actual need to fill in:
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8C/8B/wKiom1hvRZfwqGh5AABTbgg-CK0609.png "title=" 1.png "alt=" Wkiom1hvrzfwqgh5aabtbgg-ck0609.png "/>
Above we have configured the Zkserver cluster and also started the zkserver process, now also need to zkclient,zkclient is the requesting party, then we can deploy the Zkclient service on each module server, by starting the Zkclient service , so that these modules can be unified from the Zooinspector value, so that the batch configuration, while ensuring consistency of effect.
ZK template file is _tpl.properties for the end of the file, I here the module name is Mrs, then in the experiment this template file is Mrs_tpl.properties, this mrs_tpl.properties has such a field,
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/8C/8B/wKiom1hvTfXSvaAtAABQm_XNalo985.png "title=" 1.png "alt=" Wkiom1hvtfxsvaataabqm_xnalo985.png "/>
And we are in the zooinspector to fill in the corresponding:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/8C/88/wKioL1hvTjnx9a6eAAAeVS4GXp4605.png "title=" 1.png "alt=" Wkiol1hvtjnx9a6eaaaevs4gxp4605.png "/>
Save the Zooinspector, then return from Windows to Linux, start the Zkclient service and the corresponding module process, if the configuration is normal, then the program will start normally,# ps-ef|grep Java will see a call " Lczk. Appserverdaemon "process. This is the time to take a look at Mrs's configuration file:
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/8C/88/wKioL1hvTsqAlL33AAAgLK9xHvY968.png "title=" 1.png "alt=" Wkiol1hvtsqall33aaaglk9xhvy968.png "/>
Can see Areaak obtained value is ZK inside Data_center inside Access_key inside of the value of AK, the other several values also the same. It can be seen that the entire ZK has been configured successfully, the modules are all configured uniformly, and since these configurations are accepted by one, they are also accepted by the same module servers.
This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1889715
Construction and commissioning of zookeeper cluster