其他分享
首页 > 其他分享> > ES常用维护命令

ES常用维护命令

作者:互联网

1、查看分片分布
GET _cat/shards?v

2、设置集群节点允许分片数
GET /_cluster/settings
{
  "index.routing.allocation.total_shards_per_node":2
}

3、解除索引只读
PUT /_all/_settings
{
  "index.blocks.read_only_allow_delete": null
}

4、查看索引状态
GET _cat/indices\?v

5、查看集群健康状态
GET _cluster/health

6、查看集群运行事件
GET /_cluster/allocation/explain

7、设置索引副本数为0
 PUT /comunication-iot-2022.09.02/_settings
{
    "number_of_replicas": 0
}

8、手动迁移副本
POST /_cluster/reroute
{
    "commands" : [
        {
            "move" : {
                "index" : "micro-service-income-statistics-2022.06.19", "shard" : 0,
                "from_node" : "es_node7", "to_node" : "es_node2"
            }
        }
    ]
}

9、设置节点存储水平
PUT /_cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.disk.watermark.low": "90%",
    "cluster.routing.allocation.disk.watermark.high": "95%",
    "cluster.info.update.interval": "1m",
    "cluster.routing.allocation.disk.threshold_enabled": true
  }
}

10、排除节点并迁移索引
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._ip" : "10.5.232.248"
  },
      "transient" :{
      "cluster.routing.allocation.exclude._ip" : "10.5.232.248"
   }
}

11、取消排除的节点
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._ip" : null
  },
      "transient" :{
      "cluster.routing.allocation.exclude._ip" : null
   }
}

标签:常用,settings,GET,allocation,cluster,routing,PUT,维护,ES
来源: https://www.cnblogs.com/Dev0ps/p/16655182.html