Elasticsearch Upgrade
为了降低影响,确保集群所有的 index 至少都有一个备份,采用滚动升级的方式。
1. Disable shard allocation.
因为是升级,所有没有必要让 节点上的 shard 进行 reallocation,避免 IO。设置只允许 新 index 的主分片分配。
all - 默认的,允许所有shards分配
primaries - 只允许主分片分配
new_primaries - 只允许新index的主分片分配
none - 所有的都不允许根据集群的备份情况选择。
console
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "new_primaries"
}
}2. Stop non-essential indexing and perform a synced flush. (Optional)
此步骤可选, 停止非必要的索引并执行同步刷新
POST _flush/synced3. Stop Node
4. Start the upgraded node
使用以下命令查看集群节点,等节点加入集群后,执行第 5 步。
GET _cat/nodes5. Reenable shard allocation
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": null
}
}6. Wait for the node to recover
console
GET _cat/health?v=true等集群恢复正常后,重复执行以上步骤。