看输出可以发现,我在ilm配置索引min_age超过31天就执行so1n_index_policy中的一个cold phase,而在执行其中allocate的check-allocation步骤时报错Waiting for [2] shards to be allocated to nodes matching the given filters,也就是ilm执行到so1n_index节点分配时就已经出问题了,而且还是在check-allocation阶段.所以我们只要查明为什么check-allocation不通过就好了.
3.查看索引allocation情况
直接使用explain查看allocation的错误原因
1 2 3 4 5 6
GET /_cluster/allocation/explain { "index": "so1n_index", "shard": 0, "primary": true }
PUT */_settings { "index.routing.allocation.require._id": null }
修改完成后再调用explain查看:
1 2 3 4 5 6
GET /_cluster/allocation/explain { "index": "so1n_index", "shard": 0, "primary": true }
通过响应可以发现Es已经在后台执行索引迁移了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ "index" : "so1n_index", "shard" : 0, "primary" : true, "current_state" : "relocating", "current_node" : { "id" : "so1n_id_1", "name" : "so1n-elastic-node-1", "transport_address" : "10.142.0.1:9300", "attributes" : { "ml.machine_memory" : "7839637504", "xpack.installed" : "true", "box_type" : "hot", "ml.max_open_jobs" : "20" } }, "explanation" : "the shard is in the process of relocating from node [so1n-elastic-node-1] to node [so1n-elastic-node-4], wait until relocation has completed" }
迁移完成后再去查看可以发现字段rebalance_explanation会显示:cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance 则此,索引冷热分离规则全部适配运行完成.