hadoop - hadoop上的读操作和一致性级别

标签 hadoop hbase consistency

我正在 HDFS 上设置分布式 HBase,并尝试了解系统在读取操作期间的行为。

这就是我理解读取操作的高级步骤的方式。

  1. 客户端连接到NameNode以获取DataNode列表,其中包含他感兴趣的行的副本。
  2. 从这里开始,客户端缓存 DataNode 列表,并开始直接与选定的 DataNode 通信,直到它需要来自其他 DataNode 的其他行,在这种情况下,它会再次询问 NameNode。

我的问题如下:

  1. 谁选择最好的副本 DataNode 进行联系?客户端如何选择“最近”的副本? NameNode 是否按排序顺序返回相对 DataNode 的列表?
  2. 当客户端切换到另一个已请求行的 DataNode 时,会出现什么情况(如果有)?例如,如果其中一个 DataNode 变得过载/缓慢,客户端库是否可以从 NameNode 返回的列表中找出联系另一个 DataNode?
  3. 是否有可能从其中一个副本获取过时的数据?例如,客户端获取了 DataNode 列表并开始从其中之一读取。与此同时,另一个客户端向 NameNode 发出写入请求。我们有 dfs.replication == 3 和 dfs.replication.min = 2。NameNode 在 3 个节点中的 2 个上刷新到磁盘后认为写入成功,而第一个客户端正在从第三个节点读取并且不知道(尚)还有另一个写入已提交吗?
  4. Hadoop 在支持 HBase 时保持相同的读取策略吗?

谢谢

最佳答案

Who chooses the best replica DataNode to contact? How Client chooses "closest" replica? Does NameNode return list of relative DataNodes in a sorted order ?

客户是决定最好联系谁的人。它按以下顺序选择它们:

  1. 该文件位于同一台计算机上。在这种情况下(如果配置正确)它将短路 DataNode 并直接进入文件作为优化。
  2. 文件位于同一机架中(如果配置了机架感知)。
  3. 该文件位于其他位置。

What are the scenarios(if any) when Client switches to another DataNode that has requested rows? For example if one of the DataNode becomes overloaded/slow can the client library figure out to contact another DataNode from the list returned by the NameNode?

没那么聪明。如果它认为 DataNode 已关闭(意味着超时),它就会切换,但据我所知,没有其他情况。我相信它只会转到列表中的下一个,但它可能会再次联系 NameNode——我不能 100% 确定。

Is there a possibility of getting stale data from one of the replicas? For example client acquired list of DataNodes and starts reading from one of them. In the mean time there is a write request coming from another client to NameNode. We have dfs.replication == 3 and dfs.replication.min = 2. NameNode consider write successful after flushing to disk on 2 out of 3 nodes, while first client is reading from the 3rd node and doesn't know (yet) that there is another write that has been committed ?

过时的数据是可能的,但不是在您描述的情况下。文件是一次写入且不可变的(除了附加之外,但如果不需要,请不要附加)。在文件完全写入之前,NameNode 不会告诉您该文件在那里。在追加的情况下,你会感到羞愧。从本地文件系统上主动附加到的文件中读取的行为也是不可预测的。您应该对 HDFS 抱有同样的期望。

可能发生过时数据的一种方式是,如果您检索 block 位置列表,并且 NameNode 决定在您访问它之前立即迁移所有三个 block 位置。我不知道那里会发生什么。在使用 Hadoop 的 5 年里,我从来没有遇到过这个问题。即使在做事情的同时运行平衡器也是如此。

Hadoop maintains the same reading policy when supporting HBase?

HDFS 并没有对 HBase 进行特殊对待。有一些关于你的讨论sing a custom block placement strategy with HBase以获得更好的数据局部性,但这只是杂草。

关于hadoop - hadoop上的读操作和一致性级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24931429/

相关文章:

hadoop - 如何将值放入 hbase 中的多个列族中

node.js - 如何使用nodejs、express和mongoose在一个函数中保持两个操作的一致性

hadoop - 针对 cassandra 使用 hadoop mapreduce 的示例代码

hadoop - 有什么方法可以限制Hbase中的列数

sbt - Hortonworks shc Unresolved 依赖项

mongodb - MongoDB 可以成为一致的事件存储吗?

scala - redis ZADD <keys>在redis集群环境下是否一致?

hadoop - 在 Amazon EMR 上使用来自 java 的 hbase 时遇到问题

java - Hadoop Mapreduce 字数统计

hadoop - 为什么 JPS 显示没有进程在运行?