Zookeeper cluster Construction

Source: Internet
Author: User

Introduction: zookeeper is a registration center that currently uses a large number of registrars. in Dubbo systems, it is in a critical stage. Therefore, it is generally set up in the form of a cluster, this article briefly introduces the process of building.


1. download it from the official zookeeper website.

Wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz

2. decompress it.

3. Enter the decompressed directory, enter Conf, and copy zoo_sample.cfg as zoo. cfg.

4. Add the following information to zoo. cfg:

Modify datadir as the directory of the zookeeper Data File

     dataDir=D:/devtools/zookeeper-3.2.2/build 
  • Ticktime: This time is used as the interval between the zookeeper server or between the client and the server to maintain the heartbeat, that is, each ticktime will send a heartbeat.
  • Datadir: As the name implies, it is the directory where zookeeper saves data. By default, Zookeeper also stores log files that write data in this directory.
  • Clientport: the port connecting the client to the zookeeper server. zookeeper listens to the port and accepts access requests from the client.

5. after these configuration items are configured, you can start zookeeper now. After starting zookeeper, check whether zookeeper is in the service, you can run the netstat-ano command to check whether the clientport you configured is in the listening service.

6. Configure the cluster and add the following configuration items to zoo. cfg:

 initLimit=5  syncLimit=2  server.1=192.168.211.1:2888:3888  server.2=192.168.211.2:2888:3888 server.3=192.168.211.3:2888:3888

  • Nitlimit: This configuration item is used to configure zookeeper to accept the client (the client mentioned here is not the client that the user connects to the zookeeper server, but the follower server connected to the leader in the zookeeper server cluster) the maximum heartbeat interval that can be tolerated during connection initialization. When the length of the heartbeat exceeds 10 (ticktime), the zookeeper server does not receive the response from the client, which indicates that the connection to the client fails. The total length is 5*2000 = 10 seconds.
  • Synclimit: This configuration item identifies the length of time for sending messages, requests, and responses between the leader and Follower. the maximum length of time is 2*2000 = 4 seconds.
  • Server. A = B: C: D: where A is a number, indicating the number of the server. B is the IP address of the server; c Indicates the port on which the server exchanges information with the leader server in the cluster. D indicates that if the leader server in the cluster fails, a port is required for re-election, select a new leader, which is the port used for communication between servers during the election. For the pseudo cluster configuration method, because B is the same, different zookeeper instance communication port numbers cannot be the same, so you need to assign them different port numbers.

7. there are currently three machines in total, machine1, machine2, and machine3, corresponding to server1, server2, and server3. at this time, you need to go to the zookeeper/datadir directory under server1, create a new file named myid. In this file, you only need to enter the current machine ID, for example, enter 1 in server1, and so on.

8. Start each node in sequence. In each node, information about other related nodes appears. You only need to start the node. After all the nodes are started, they will elect a leader and the entire zookeeper cluster is started.

In this case, the open channel to/192.168.1.1: 3888 cannot be opened. Generally, it is caused by the port or the machine cannot start normally. In centos, how does one open the port?

Switch to the root permission, VI/etc/sysconfig/iptables

vi /etc/sysconfig/iptables
Add the following information in it:-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 3001-J accept

> Service iptables restart: restart iptables.

> Disable service iptables stop


References:

1. http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/

2. http://myjeeva.com/zookeeper-cluster-setup.html#deploying-zookeeper-cluster-multi-server

3. http://zdeyuan.blog.163.com/blog/static/42263655201072524055404/

4. http://blog.csdn.net/jemlee2002/article/details/7042991 [How to manage iptables]


Zookeeper cluster Construction

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.