第2题,索引级别分片分配设置
Configure hamlet-1 to allocate both primary shards to node2, using the node name
通过配置节点名字,指定hamlet-1的俩主分片都放在node2上
Configure hamlet-2 so that no primary shard is allocated to node3
通过配置,避免hamlet-2的分片放置在node3
Remove any allocation filter setting associated with hamlet-1 and hamlet-2
取消所有针对hamlet-1和hamlet-2分片放置的设置
Verify the success of the last action by using the _cat API
通过_catAPI验证一下这些操作成功了没
第2题,题解
把hamlet-1的主分片都放node2上
PUT hamlet-1/_settings
{
"index.routing.allocation.require._name": "node2"
}
校验命令:GET /_cat/shards/hamlet-1?v&h=index,shard,prirep,state,docs,store,ip,node
把hamlet-2所有主分片都移出node3
PUT hamlet-2/_settings
{
"index.routing.allocation.exclude._name": "node3"
}
校验命令:
GET /_cat/shards/hamlet-2?v&h=index,shard,prirep,state,docs,store,ip,node
注意:设置是针对所有分片的,分配时不只参考预定策略,也会考虑内置限定 (临时,不彻底)
如果节点重启,replica shard 会出现未分配的现象 (彻底)