如何将某些索引限制为 Elasticsearch 集群中的一组机器
How to restrict certain indices to a set of machines in an Elasticsearch cluster
我们在一个集群中有 2x64GB 机器和 2x16GB 机器,我们每天创建一个索引。要求是将新索引移动到 64 GB 机器,将旧索引移动到 16GB 机器。如何使用 elasticsearch 做到这一点?
您需要 "tag" 您的节点并使用 node.tag
属性 指定哪个节点:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-allocation.html#shard-allocation-filtering.
并且您为每个 64GB 节点指定 node.tag: large1
和 node.tag: large2
(每个节点一个)。
然后,当您创建索引时,您可以使用 "index.routing.allocation.include.tag" : "large1,large2"
指定您希望如何分配它(这些是 64GB 节点)。当您决定将索引从两个节点移动到另外两个节点时,您更新上面的 属性 并指定 "small1,small2"
例如(较小的 16GB 节点)。
我建议您也看看 Curator,它可以帮助您更改这些设置。
这是一个 2 步过程
- 使用键值对标记您的节点。例如:对于较小的机器,将它们标记为 boxType:small,对于更好的机器,将它们标记为 boxType:big。
- 接下来使用设置 API 应用 index filter rule,如下所示 -
curl -XPUT localhost:9200/index-name/_settings -d '{
"index.routing.allocation.include.tag" : "big"
}'
我们在一个集群中有 2x64GB 机器和 2x16GB 机器,我们每天创建一个索引。要求是将新索引移动到 64 GB 机器,将旧索引移动到 16GB 机器。如何使用 elasticsearch 做到这一点?
您需要 "tag" 您的节点并使用 node.tag
属性 指定哪个节点:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-allocation.html#shard-allocation-filtering.
并且您为每个 64GB 节点指定 node.tag: large1
和 node.tag: large2
(每个节点一个)。
然后,当您创建索引时,您可以使用 "index.routing.allocation.include.tag" : "large1,large2"
指定您希望如何分配它(这些是 64GB 节点)。当您决定将索引从两个节点移动到另外两个节点时,您更新上面的 属性 并指定 "small1,small2"
例如(较小的 16GB 节点)。
我建议您也看看 Curator,它可以帮助您更改这些设置。
这是一个 2 步过程
- 使用键值对标记您的节点。例如:对于较小的机器,将它们标记为 boxType:small,对于更好的机器,将它们标记为 boxType:big。
- 接下来使用设置 API 应用 index filter rule,如下所示 -
curl -XPUT localhost:9200/index-name/_settings -d '{ "index.routing.allocation.include.tag" : "big" }'