# curl http://localhost:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 37,
"active_shards" : 37,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 26,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 58.730158730158735
}
# curl -X GET 'http://localhost:9200/_cat/indices'?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open logstash-2020.09.10 jlCbWlHySveGntTs-DG2eA 1 1 179057269 0 35.1gb 35.1gb
yellow open logstash-2020.09.11 rty9vwTBS3OxH1evu1Kc9g 1 1 172997561 0 32.5gb 32.5gb
......
# curl -X GET 'http://localhost:9200/_settings'?pretty=true
{
"logstash-2020.09.07" : {
"settings" : {
"index" : {
"refresh_interval" : "5s",
"number_of_shards" : "1",
"provided_name" : "logstash-2020.09.07",
"creation_date" : "1599436800757",
"number_of_replicas" : "1",
"uuid" : "W-7zp7R8Q7OF78pezzFpig",
"version" : {
"created" : "7080099"
}
}
}
},
"logstash-2020.09.12" : {
"settings" : {
"index" : {
"refresh_interval" : "5s",
"number_of_shards" : "1",
"provided_name" : "logstash-2020.09.12",
"creation_date" : "1599869321680",
"number_of_replicas" : "1",
"uuid" : "OjwNHjCZSp6a-2vmNkDl3g",
"version" : {
"created" : "7080099"
}
}
}
},
......
curl -XPUT --header 'Content-Type: application/json' http://localhost:9200/_settings -d '{"number_of_replicas" : "0"}'
# curl http://localhost:9200/_cluster/health?pretty
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 37,
"active_shards" : 37,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
# curl -X GET 'http://localhost:9200/_cat/indices'?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open logstash-2020.09.10 jlCbWlHySveGntTs-DG2eA 1 0 179057269 0 35.1gb 35.1gb
green open logstash-2020.09.11 rty9vwTBS3OxH1evu1Kc9g 1 0 172997561 0 32.5gb 32.5gb
本文展示了如何通过curl命令检查Elasticsearch集群的健康状态,从黄色状态到绿色状态的过程,调整副本 shards 数量以优化性能。过程中涉及到了索引的设置、shards 的分配与健康状况,以及最终达到的全绿状态。

16万+

被折叠的 条评论
为什么被折叠?



