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
   }
}

命令行

#GET
curl -s -X GET  http://elastic:neN93mK@xxxx:9201/_cluster/health|jq
#PUT
curl -X PUT "http://elastic:neN93mK@xxxx:9201/_cluster/settings" -H "Content-Type: application/json" -d '{
  "persistent": {
    "cluster.some_setting": "new_value"
  }
}'
#DELETE
curl -X DELETE "http://elastic:neN93mK@xxxx:9201/your_index_name"
posted @ 2022-09-04 15:17  西门运维  阅读(240)  评论(0编辑  收藏  举报