es集群快速恢复(优化方案)_大数据_ClearloveXXX的博客-CSDN博客
1、停止数据写入
2、关闭allocate,禁止shard做allocate
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"cluster.routing.allocation.enable" : "none"
}
}'
3、执行synced操作
curl -XPOST 'localhost:9200/_flush/synced?pretty'
4、重启es服务
5、等级集群变成yellow后开启allocate,允许shard做allocate
curl -XPUT localhost:9200/_cluster/settings -d '{
"persistent" : {
"cluster.routing.allocation.enable" : "all"
}
}'
调整集群恢复时的带宽,-1是指无限制
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.max_bytes_per_sec" : "-1"
}
}
'
调整集群恢复时的单机并发度,最好是和磁盘块数一致
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"cluster.routing.allocation.node_concurrent_recoveries" : "24"
}
}
'
调整集群恢复时单个shard中同时恢复的小文件的个数
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.concurrent_small_file_streams" : "24"
}
}
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.concurrent_streams" : "24"
}
}
6、等待recovery完成,集群变成green
7、恢复完成后:
curl -XPUT bapc007:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.max_bytes_per_sec" : "100m"
}
}
'
curl -XPUT bapc007:9200/_cluster/settings -d '
{
"transient" : {
"cluster.routing.allocation.node_concurrent_recoveries" : "12"
}
}
'
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.concurrent_small_file_streams" : "6"
}
}
curl -XPUT localhost:9200/_cluster/settings -d '
{
"transient" : {
"indices.recovery.concurrent_streams" : "6"
}
}