本文介绍了学习 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 是否负责启动另一个东西服务器?或者我是否订阅 Zookeeperstuff doer status"回调?如果我错误地启动了两个东西服务器,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.

使用master选举,你可以选择有两台(或更多)服务器,但只有其中一台可以拿master锁,所以只有那一台可以采取行动.一旦它消失,它就会失去对锁的所有权,而您的热备用设备将拿起锁并开始做您需要它做的工作.查看 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 - 帮我举例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 08:11