Zookeeper cluster (2), zookeeper Cluster

Source: Internet
Author: User

Zookeeper cluster (2), zookeeper Cluster

After reading the previous article "zookeeper pseudo cluster 1", I believe you have some knowledge about zookeeper clusters. Next, let's talk about zookeeper real clusters. In fact, the real cluster and pseudo cluster still have many similar parts. I will simulate three cluster services and explain the configuration of one of the cluster services. The next two operations are basically the same.

Foreshadowing:

   1. I have created three virtual machines. The Linux version is CentOS7 and the tool is vmware12.

2. The tool for external connection to virtual machines is small xmanager5, which is just a little more convenient, you can also not use

3. Install jdk 1.7 and later on the Virtual Machine in advance. I use version 1.8. If jdk is not installed, refer to my other article jdk installation under Linux.

4. I have created three VMS and obtained the Internet addresses192.168.0.124,192.168.0.129,192.168.0.127, I use the alias CentOS1,CentOS3,CentOS4

5,In the following description, if there is an association, I Will bold it and mark it with the same color.

  Build:

   1. Modify the zoo. cfg file under zookeeper as follows:

TickTime = 2000
SyncLimit = 10
InitLimit = 5
DataDir=/Home/d5000/zk/data
ClientPort = 3001
DataLogDir =/home/d5000/zk/log
Server.1= 192.168.0.124: 2887: 3887
Server.2= 192.168.0.129: 2887: 3887
Server.3= 192.168.0.127: 2887: 3887

Because it is a cluster, the port numbers of the three machines can be completely consistent, and a zoo. cfg file can be shared.

2. Create the/home/d5000/zk directory on the three virtual machines respectively, and create the data directory under zk for storage.DataDirConfigure the ing file. Then, upload zookeeper to the zk Directory, which is consistent with that of the pseudo cluster.

3.CentOS1Create a myid file under/home/d5000/zk/data on the machine. The content is1;

InCentOS3Create a myid file under/home/d5000/zk/data on the machine. The content is2;

InCentOS4Create a myid file under/home/d5000/zk/data on the machine. The content is3;

4. Assign the zookeeper permission to the three machines respectively. Otherwise, how can I start it? You can give zookeeper a start permission, enter/home/d5000/zk/zookeeper/bin, and execute chmod 777 zkServer. sh

 

At this point, the cluster has been created. It's really easy to test and start it separately ,. /zkServer. sh start, the first server reports an error, the second server reports an error, and the third server still reports an error, and the error information is consistent, all of which are zookeeper no route to host. Check the Internet and find that, two of them may cause this problem. One is the firewall and the other is the hostname.

 Troubleshooting:

1. Check whether the firewalls of the three machines are closed: firewall-cmd -- state. If the firewall is not closed, run the command to disable systemctl stop firewalld. service.

2. ModifyCentOS1Machine, run the hostname server.1 command

    ModifyCentOS3Machine, run the hostname server.2 command

ModifyCentOS4Machine, run the hostname server.3 command

3. Restart the VM, init 6, and then restart the service.

4. The error zookeeper no route to host is returned.

    

                                                    

------------------------------------------------------------------------- The following are all heartbroken, with 10 thousand words omitted -------------------------------------------------------------------------

After a lot of efforts, we finally found out that systemctl stop firewalld. the firewall shut down by the service is temporary. As long as the firewall immediately takes effect after the service is restarted, the hostname is also the same:

Final Modification

1. Completely disable the firewall: systemctl disable firewalld. service

2. ModifyCentOS1Host/etc/hostname file, content: server.1

ModifyCentOS3Machine/etc/hostname file, content: server.2

ModifyCentOS4Machine/etc/hostname file with the content server.3 (Permanent modification)

3. Start the first server and the second server and check whether there is an error message. However, the current error message is changed to connect refuesd (the link is denied). Continue to start the third server and no error message is reported, after the test, the cluster service is normal. The first server reports an error because the second and third servers are not started. The second server reports an error because the third server does not start. These errors do not affect the cluster.

The following provides the simplest test: Execute telent 192.168.0.127 3001 telent 192.168.0.129 3001 on 192.168.0.124. If the connection is successful, it means that the respective services can run normally and can communicate with each other, next we can perform a more complete test through the code.

Effect

 

                                   Finished

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.