"Linux" zookeeper constructs pseudo-cluster

Source: Internet
Author: User
Tags zookeeper

1. Install 3 ZK server in one machine, build pseudo-cluster mode
The installation steps are as follows:
1. Download zookeeper,:http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/
2, extract to three directories, such as
/data/zookeeper/zserver1,/data/zookeeper/zserver2,/data/zookeeper/zserver3
3. Create a conf/zoo.cfg configuration file under each directory
Such as
/data/zookeeper/zserver1/confzoo.cfg content is as follows:
ticktime=2000
initlimit=10
Synclimit=5
Datadir=/data/zookeeper/zserver1/tmp/data
Datalogdir=/data/zookeeper/zserver1/tmp/log
clientport=2181
server.1=127.0.0.1:2287:3387
server.2=127.0.0.1:2288:3388
server.3=127.0.0.1:2289:3389
The other/data/zookeeper/zserver2/conf/zoo.cfg/data/zookeeper/zserver3/conf/zoo.cfg, the same as the ZServer1

Attention:
Because the cluster is simulated on a single machine, the ports cannot be duplicated, and the 2181~2183,2287~2289 and 3387~3389 are staggered. In addition, each ZK instance, need to set up a separate data storage directory, log storage directory, so DataDir, datalogdir these two nodes corresponding directories, need to be created manually first.
4, there is also a gray key setting, in each ZK server configuration file corresponding to the DataDir directory, you must create a file named myID, where the content must be the same as the X in Server.x in Zoo.cfg, namely:

The content in/data/zookeeper/zserver1/data/myid is 1, corresponding to 1 in Server.1

The content in/data/zookeeper/zserver2/data/myid is 2, corresponding to 2 in Server.2
The content in/data/zookeeper/zserver3/data/myid is 3, corresponding to 3 in SERVER.3

In a production environment, the steps for distributed cluster deployment are basically the same as above, except that because each ZK server is distributed on different machines, localhost in the above configuration file is replaced with the real IP of each server. Distributed in different machines, there is no port conflict problem, you can make each server ZK use the same port, so it is easier to manage.
5. Start verification
Enter the bin/directory for each zserver to execute zserver.sh start, and if it is started, kill the process and start.
After successful startup, perform JPS viewing process, or view status with zserver.sh status

PS: If the Cluster service is not required, simply comment out the server.x in the Zookeeper/zserver3/conf/zoo.cfg file below.

"Linux" zookeeper constructs pseudo-cluster

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.