recovery是一个索引的分片分配到另外一个节点的过程,一般发生在快照恢复,索引复制分片的变更,节点故障或者重启节点时候发生。recovery的过程消耗额外的资源cpu 内存 节点点的网络带宽等等。
1.在集群启动的过程中,一旦有了多少启动成功再执行恢复的过程 master节点和data节点都算在其中
1 gateway.expected_nodes: 3
2.有几个master节点启动成功,就执行恢复的过程
1 gateway.expected_master_nodes: 3
3.有几个data节点启动成功,就执行恢复的过程
1 gateway.expected_data_nodes: 3
在上述条件满足之前,恢复的过程会等待指定的事件,一旦超时,则会根据下面的条件判断
1 gateway.recover_after_nodes: 3 # 3个节点(master和data节点都算)启动成功 2 gateway.recover_after_master_nodes: 3 # 3个有master资格的节点启动成功 3 gateway.recover_after_data_nodes: 3 # 3个有data资格的节点启动成功
上述过程满足其中一个条件就会执行
1 gateway.expected_data_nodes: 10 2 gateway.recover_after_time: 5m 3 gateway.recover_after_data_nodes: 8
表示:此时的集群在5分钟内,有10个data节点都加入集群,或者5分钟后有8个以上的data节点加入集群,都会启动recovery的过程。
减少主副本之间的数据的拷贝
重启单个节点,也会带来不同节点之间来回复制,避免这种情况,可以在重启之前,关闭集群的shard allocation
PUT _cluster/settings { "transient": { "cluster.routing.allocation.enable":"none" } }
在节点重启后再执行
PUT _cluster/settings { "transient": { "cluster.routing.allocation.enable":"all" } }
原文:https://www.cnblogs.com/Alexephor/p/11411820.html