In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "what are the two solutions for achieving high availability in ZooKeeper", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article, "what are the two solutions for achieving high availability in ZooKeeper?"
Note: dual hot standby is used to achieve high availability. For convenience, the scheduling server debian1 is referred to as the host, and the standby debian1' of the scheduling server debian1 is referred to as the standby.
The client has perceived high availability
The client has perceived high availability, that is, it needs the cooperation of the client, and the client confirms the change of the server and switches the target of access. For example, our mainframe and slave are registered with ZooKeeper (or other similar registries such as redis). The client listens to the information of the server in ZooKeeper and switches to access the slave when the host is offline.
ZooKeeper pseudo-cluster building
First, set up a ZooKeeper pseudo-cluster with three nodes on the machine. Download the version of 3.5.4-beta on the official website, decompress it, and then make 3 copies, each of which must do the following:
Go to the conf folder to create a configuration file, zoo.cfg. The code is as follows:
Create the dataDir and dataLogDir above, and you must create a myid file in the dataDir directory and write a different integer ID, which is the x of the server.x above, such as 1
Enter the bin directory respectively, add set ZOOCFG=../conf/zoo.cfg before call in zkServer.cmd and start with it.
By the way, code development I used my previous project CHKV, because the NameNode or DataNode in this project can also use ZooKeeper to achieve high availability, welcome to improve this project with me.
Scheduling server development
The scheduling server mainly registers itself with ZooKeeper and provides services to the client. We use the curator framework to interact with ZooKeeper, paying special attention to version issues.
The main code is as follows:
Client development
The client mainly listens to the ZooKeeper monitoring and scheduling server for change events and initiates application requests to it. In fact, the application server can also use this part of the code to listen for changes in the scheduling server.
The main code is as follows:
High availability transparent to the client
Transparent to the client is highly available, that is, the client does not need to do any work, the server does not switch the client does not know and does not care. There are two main ways to implement this. One is that the client accesses the host through the domain name, then the monitoring host will reassign the domain name to the standby after it goes offline. Of course, this switch will have time costs, depending on the defined DNS cache time. The second is that the client accesses the host through IP, and after monitoring the host goes offline, it assigns the external IP (or virtual IP) to the standby machine through IP drift technology, so that it can be switched in time.
Keepalived is often used to realize IP drift in real environment.
The construction process refers to The keepalived solution for LVS and official website documents.
First, install keepalived for both the host and standby, and then configure the host / etc/keepalived/keepalived.conf:
Configure slave / etc/keepalived/keepalived.conf, which is similar to the host, but state is backup with low weight:
The above is the content of this article on "what are the two solutions for achieving high availability of ZooKeeper". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
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.