本文介绍了学习Zookeeper-帮我举例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设法把头围在Zookeeper上以及它的作用.到目前为止,我在Zookeeper方面的经验是通过其他需要Zookeeper的库(Solr和Kafka)进行的,因此我的基本理解是非常模糊的最好使用Zookeeper保持配置正确".

I'm trying to wrap my head around Zookeeper and what it does. To this point, my experience with Zookeeper has been through other libraries that require Zookeeper (Solr and Kafka) and so my basic understand is the very vague "you better use Zookeeper to keep your configuration straight".

因此,请帮助我思考一个简单的示例问题.假设我建立了自己的服务,该服务可以执行工作".我要保护两件事:

So help me think through a simple example problem. Let's say that I build my own service that does "stuff". There are two things that I want to protect:

  1. 我希望尽可能减少停机时间(必须继续做事).
  2. 我不能只用一台服务器来做事,因为会发生坏事.

那么,我该如何在Zookeeper中进行设置?Zookeeper是否会负责在另一台东西服务器出现故障时启动它?还是我订阅了Zookeeper的人员状态"回调?如果我错误地启动了两台东西服务器,Zookeeper如何帮助我防止不良情况的发生?

So, how would I set this up in Zookeeper? Is Zookeeper responsible for starting another stuff server if one goes down? Or do I subscribe to a Zookeeper "stuff doer status" callback? If I erroneously start up two stuff servers, how does Zookeeper help me keep bad things from happening?

推荐答案

Zookeeper是分布式锁管理器.这些系统提供的功能类似于协调员选举(又称主要选举"或领导人选举")分布式系统,并提供对少量关键信息的一致,分布式访问,这些信息经常用于配置(即,不要将其视为数据库或通用文件系统).

Zookeeper is a distributed lock manager. These systems provide features like coordinator election (aka "master election" or "leader election") for a distributed system, as well as provide a consistent, distributed access to small amounts of critical information which is frequently used for configuration (i.e., don't treat it like a database or a general file system).

请注意,Zookeeper不会管理您的服务,但是您可以使用 Zookeeper来保留热备用(或多个),以便在一个主服务器发生故障的情况下,另一个主服务器将接管,因此您将运行服务器的N个副本,以便一个工作实例可以立即接管如果当前领导者由于任何原因而倒下或变得不可用.

Note that Zookeeper does not manage your service, but you can use Zookeeper to keep a hot standby (or several) such that in case of one master failing, another one will take over, so you would run N replicas of your servers, such that one of the working instances can take over immediately if the current leader goes down or becomes unavailable for any reason.

使用主选举,您可以选择拥有两台(或更多台)服务器,但是其中只有一台能够进行主锁操作,因此只有一台能够进行操作.一旦它消失了,它将失去对锁的所有权,而热备用将拿起锁并开始执行您需要做的工作.查看 Zookeeper食谱以获取代码示例.但是,正确地移交工作,检查点和一般服务的弹性仍然取决于您设计和实施.

Using master election, you can choose to have two (or more) servers, but only one of them will be able to take the master lock, so only that one will be able to take action. As soon as it goes away, it will lose its claim to the lock, and your hot standby will pick up the lock and start doing work that you need it to do. Look at Zookeeper recipes for code samples. However, properly handing off work, checkpointing, and general service resilience is still up to you to design and implement.

也就是说,Zookeeper和类似的系统为您构建健壮的分布式系统提供了坚实的基础.

That said, Zookeeper and similar systems provide a solid foundation to enable you to build robust distributed systems.

类似于Zookeeper的其他系统包括(按字母顺序):

Other systems similar to Zookeeper include (alphabetically):

其中一些在各自的网站上进行了详细的比较,以显示它们与列表中其他网站的区别.

Several of these have detailed comparisons written up on their respective websites to show how they differ from the others in the list.

这篇关于学习Zookeeper-帮我举例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 19:27