Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and configuration of zookeeper pseudo-cluster

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "zookeeper pseudo-cluster installation and configuration methods", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "zookeeper pseudo-cluster installation and configuration method"!

zookeeper installation configuration

mkdir -p /opt/zookeeper

If it is win, run the.cmd suffix startup file directly under bin. If it is linux and mac, run the.sh startup file directly under bin.

Centos7 installation has wget installation and download installation from the official website, wget is slow, it is recommended to download installation from the official website. Official website address https://zookeeper.apache.org/ Download Remember to choose http mirror Other mirrors do not come down, select mirror view-> https://jingyan.baidu.com/album/335530dafd4b3619cb41c3d8.html tutorial

Zookeeper installation does not distinguish between win, linux, mac direct decompression. Download with bin is only class file, without bin is java file all line recommendations with bin, file small.

zookeeper installation package decompression configuration can be used to start, create/opt/zookeeper to store the decompressed zookeeper

Configuring pseudo-clusters

cp -a zoo_sample.cfg zoo.cfg mkdir -p /root/kch/zkw/zookeeper/data mkdir -p /root/kch/zkw/zookeeper/logs # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/root/kch/zkw/zookeeper/data dataLogDir=/root/kch/zkw/zookeeper/logs # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # ▽ # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 tickTime=2000 dataDir=/root/kch/zkw/zookeeper/data dataLogDir=/root/kch/zkw/zookeeper/logs clientPort=2181

Parameter description:

bin/zkServer.sh start

After the Server starts, check zookeeper status:

bin/zkServer.sh status

Then you can start the client connection server and execute the script:

bin/zkCli.sh -server localhost:2181

Pseudo-cluster mode The so-called pseudo-cluster refers to the process of starting multiple zookeeper in a single machine and forming a cluster. For example, start three zookeeper processes.

Make 2 copies of zookeeper's catalog:

|--zookeeper0 |--zookeeper1 |--zookeeper2

Change the zookeeper 0/conf/zoo.cfg file to:

tickTime=2000 initLimit=10 syncLimit=5 dataDir=/root/kch/zkw/zookeeper0/data dataLogDir=/root/kch/zkw/zookeeper0/logs clientPort=2180 server.0=127.0.0.1:8880:7770 server.1=127.0.0.1:8881:7771 server.2=127.0.0.1:8882:7772

Several new parameters have been added with the following meanings:

Refer to zookeeper 0/conf/zoo.cfg, configure zookeeper 1/conf/zoo.cfg, and zookeeper 2/conf/zoo.cfg files. Just change the dataDir, dataLogDir, clientPort parameters.

Create a new myid file in the dataDir that was previously set, and write a number that indicates which server this is. This number must correspond to the X in server.X in zoo.cfg file. If it is windows, you can create myid.txt and then write numbers in it, and finally modify the file format to remove the suffix example:

echo 0 > /root/kch/zkw/zookeeper0/data/myid

Write 0 /root/kch/zkw/zookeeper0/data/myid file Write 1 /root/kch/zkw/zookeeper 2/data/myid file Write 2/myid file Enter/opt/zookeeper/zookeeper0/bin, /opt/zookeeper/zookeeper1/bin,/opt/zookeeper/zookeeper2/bin three directories respectively, start the server. Select any server directory and start the client:

bin/zkCli.sh -server localhost:2180

initLimit: zookeeper A cluster contains multiple servers, one of which is the leader, and the rest of the servers in the cluster are followers. The initLimit parameter configures the maximum heartbeat time between the follower and leader when initializing a connection. At this time, the parameter is set to 5, indicating that the time limit is 5 times tickTime, i.e. 5*2000=10000ms=10s.

syncLimit: This parameter configures the maximum length of time for messages, requests, and responses to be sent between leader and follower. At this time, the parameter is set to 2, indicating that the time limit is 2 times tickTime, i.e. 4000ms.

server.X=A:B:C where X is a number indicating which server. A is the IP address of the server. B Configure the ports used by the server to exchange messages with leaders in the cluster. C Configure the port used to elect the leader. Because the configuration is pseudo cluster mode, so each server B, C parameters must be different.

tickTime: The basic unit of time used in zookeeper, a millisecond value. dataDir: Data directory. It can be any directory. dataLogDir: log directory, which can also be any directory. If this parameter is not set, the same settings as dataDir will be used. clientPort: The port number on which to listen for client connections. At this point, zookeeper standalone mode has been configured. To start the server, simply run the script:

Configure zoo.cfg

zoo.cfg Content

Create zookeeper data storage directory and log directory

Unzip to the appropriate directory. Go to the conf subdirectory under the zookeeper directory and create zoo.cfg:

cluster mode

tickTime=2000 initLimit=5 syncLimit=2 dataDir=/root/kch/zkw/zookeeper/data dataLogDir=/root/kch/zkw/zookeeper/logs clientPort=2180 server.0=10.1.39.43:2888:3888 server.1=10.1.39.47:2888:3888 server.2=10.1.39.48:2888:388810.1.39.43 myid of server is 010.1.39.47 myid of server is 110.1.39.48 myid of server is 2

In the example, three zookeeper servers are deployed on 10.1.39.43, 10.1.39.47, and 10.1.39.48. Note that the numbers in the myid file under the dataDir directory of each server must be different.

Cluster mode configuration is basically the same as pseudo cluster. Since each server is deployed on a different machine in cluster mode, the conf/zoo.cfg file for each server can be exactly the same. Here is an example:

At this point, I believe that everyone has a deeper understanding of the "zookeeper pseudo-cluster installation and configuration method", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report