In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the configuration method of zookeeper cluster mode". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the configuration method of zookeeper cluster mode".
Configuration of cluster mode
In order to ensure the stability and reliability of ZooKeeper services, a ZK cluster is usually built to provide services. With regard to ZooKeeper, you need to be clear about a very important feature: as long as more than half of the machines in the cluster are working properly, then the whole cluster is externally available (this feature can be replaced by "half alive" at the end of this article). Based on this feature, it is recommended that the number of machines in the ZK cluster should be controlled to an odd number. Why choose odd-numbered machines? we can take a look. If it is a ZK cluster composed of four machines, then only one machine down in the cluster can be allowed to drop, because if down loses 2 machines, then there are only 2 machines left, obviously not more than half. If it is a cluster of five machines, then it will be able to withstand the disaster in the case of two machines losing down.
You can configure a ZK machine by following these steps. For more detailed steps, please see "ZooKeeper Quick build": 1. Install JDK. Related link: http://java.sun.com/javase/downloads/index.jsp
two。 Sets the Java heap size. Avoiding the exchange of memory and disk space can greatly improve the performance of ZK, and setting a reasonable heap size can effectively avoid the trigger of this kind of space exchange. Before the official launch, it is recommended to conduct some stress tests for usage scenarios to ensure that the use of memory does not trigger such swapping after normal operation. Usually on a machine with 4G physical memory, the maximum setting-Xmx is 3G.
3. Download and install ZooKeeper, related link: http://zookeeper.apache.org/releases.html
4. Configuration file zoo.cfg. To use zookeeper for the first time, you can simply configure it as follows:
1. TickTime=2000
2. DataDir=/var/lib/zookeeper/
3. ClientPort=2181
4. InitLimit=5
5. SyncLimit=2 server.1=zoo1:2888:3888 6. Server.2=zoo2:2888:3888 7. Server.3=zoo3:2888:3888
These parameters will be described in detail in the later chapters of this article, and here are just a few points:
a. Each machine in the cluster needs to be aware of which machines the whole cluster is made up of. In the configuration file, you can write one machine configuration per line in this format: server.id=host:port:port. For this id, we call it Server ID, which identifies the machine sequence number of the host machine in the cluster. On each ZK machine, we need to create a myid file under the data directory (the data directory is the directory specified by the dataDir parameter), which is the Server ID number in myid.
b. In the design of ZooKeeper, the contents of the zoo.cfg files on any machine in the cluster are consistent. So it's best to manage this file with SVN to ensure that every machine can share the same configuration.
5. About the myid file. There is only one number in the myid file, a Server ID. For example, the content of the myid file for server.1 is-1 percent. Note that make sure that the id number in the myid file of each server is different and consistent with the id in server.id=host:port:port. In addition, the range of id is 1x255. 6. At this point, the configuration file is basically ok, and you can try to start zookeeper with the following command:
1. $java-cp zookeeper.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4
J12-1.6.1.jar:lib/log4j-1.2.15.jar:conf\ org.apache.zookeeper.server.quorum.QuorumPeerMainzoo.cfg
Note that different ZK versions depend on different log4j and slf4j versions. Please read your own version carefully before executing the above command. The QuorumPeerMain class starts the ZooKeeper Server, and at the same time, the JMX MB is started, making it easy for the administrator to control the ZK on the JMX management console. Here is a detailed introduction to ZK JMX: http://zookeeper.apache.org/doc/r3.4.3/zookeeperJMX.html. In addition, there could be an easier way to start directly with the script in% ZK_HOME%/bin.
1.. / zkServer.sh start
7. Connect to the ZK host to verify that the deployment is successful.
A. Java language, you can run this command to detect:
1. $java-cp zookeeper.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4
J12-1.6.1.jar:lib/log4j-1.2.15.jar:conf:src/java/lib/jline-0.9.94.jar\ org.apache.zookeeper.ZooKeeperMain-server 127.0.0.1 purl 2181
b. If it is C language, the method is as follows:
1. $make cli_st 2. $make cli_mt
Then connect ZK:$ cli_mt 127.0.0.1purl 2181 in this way. No matter which client you run, it ends up being a command-line operation similar to a file system.
Note: in addition to the above detection method,% ZK_HOME%/bin also has other scripts. After the following command is executed, it enters the file system of the zookeeper tree structure.
1.. / zkCli.sh
In addition, there is another way to view the current status of the ZK server, as follows, which is a good way to see how the machine is running:
1. $echo stat | nc localhost 2181
2. Zookeeper version: 3.4.3-1240972, built on 02 built on 06 Universe 10:48 GMT
3. Clients:
4. / 127.0.0.1 40293 [0] (queued=0,recved=1,sent=0) 5.
6. Latency min/avg/max: 1-2-3 7. Received: 4 8. Sent: 3
9. Outstanding: 0 10. Zxid: 0 × 200000006 11. Mode: leader 12. Node count: 4
Thank you for reading, the above is the content of "the configuration method of zookeeper cluster mode". After the study of this article, I believe you have a deeper understanding of the configuration method of zookeeper cluster mode, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.