Elasticsearch 如何确定要查询集群中的哪个节点
How Elasticsearch determines which node in cluster to query
我在不同的位置有两个 ES 节点(在一个集群中),我想确定我的应用程序使用最近的一个来避免网络延迟。
我已经设置 Forced Shard Allocation Awareness 以使这些节点中的每一个 "independent"(包含主分片或另一个主分片的副本,但绝不会包含它们)像
cluster.routing.allocation.awareness.force.my_attr.values: my_attr_val1, my_attr_val2
cluster.routing.allocation.awareness.attributes: my_attr
现在我知道我可以通过添加到查询 Preference 来强制我的查询在特定节点上成为 运行,例如:
_only_nodes:my_attr:my_attr_val1
但据我所知,如果节点出现故障,它会失败 - 所以基本上我不想这样做。
我能做的就是设置
_prefer_nodes:my_attr:my_attr_val1
或者什么都不做,让 ES 来完成它的工作。问题是 - ES 是选择 "the best"(比如说最近的)节点来查询还是它只是随机选择一个 ? Elasticsearch 如何确定要询问的节点?[=15=]
我的ES版本是5.5.0
如果不设置首选项,5.5 中的行为是以循环方式将请求路由到分配的分片。 ES 没有 "nearest node" 系统。
我在不同的位置有两个 ES 节点(在一个集群中),我想确定我的应用程序使用最近的一个来避免网络延迟。
我已经设置 Forced Shard Allocation Awareness 以使这些节点中的每一个 "independent"(包含主分片或另一个主分片的副本,但绝不会包含它们)像
cluster.routing.allocation.awareness.force.my_attr.values: my_attr_val1, my_attr_val2
cluster.routing.allocation.awareness.attributes: my_attr
现在我知道我可以通过添加到查询 Preference 来强制我的查询在特定节点上成为 运行,例如:
_only_nodes:my_attr:my_attr_val1
但据我所知,如果节点出现故障,它会失败 - 所以基本上我不想这样做。
我能做的就是设置
_prefer_nodes:my_attr:my_attr_val1
或者什么都不做,让 ES 来完成它的工作。问题是 - ES 是选择 "the best"(比如说最近的)节点来查询还是它只是随机选择一个 ? Elasticsearch 如何确定要询问的节点?[=15=]
我的ES版本是5.5.0
如果不设置首选项,5.5 中的行为是以循环方式将请求路由到分配的分片。 ES 没有 "nearest node" 系统。