Elasticsearch的一些api随记:修订间差异
来自三线的随记
小无编辑摘要 |
小无编辑摘要 |
||
第14行: | 第14行: | ||
/_cat/nodes?v | /_cat/nodes?v | ||
=== Get master node === | ===Get master node=== | ||
/_cat/master?v | /_cat/master?v | ||
第87行: | 第87行: | ||
====get indices and order by number of replicas==== | ====get indices and order by number of replicas==== | ||
/_cat/indices?health=green&v&s=rep:asc,store.size:desc,index | /_cat/indices?health=green&v&s=rep:asc,store.size:desc,index | ||
[[分类:Elasticsearch]] | |||
=== Demo === | |||
==== 对于有大量索引的刚重启的es集群 ==== | |||
(主分片在1w-2w) | |||
如果需要加快集群恢复速度,可以结合es节点资源监控图,观测节点cpu压力,以及cpu IO wait | |||
适当通过update cluster settings接口动态增加node_initial_primaries_recoveries (Defaults to <code>4</code>) | |||
和 node_concurrent_recoveries | |||
(A shortcut to set both <code>cluster.routing.allocation.node_concurrent_incoming_recoveries</code> and <code>cluster.routing.allocation.node_concurrent_outgoing_recoveries</code> | |||
Defaults to <code>2</code>)数值 | |||
通过使用 cluster settings + include_defaults=true 筛选查到当前配置值 | |||
减少集群从red状态到yellow状态的耗时:增加索引副本数量,增加node_initial_primaries_recoveries值 | |||
减少集群从yellow状态到green状态的耗时:增加 node_concurrent_recoveries 值 | |||
可以通过访问 <code>/_cluster/allocation/explain</code> 接口查到阻碍集群 to green(yellow)的原因 | |||
[[分类:Elasticsearch]] | |||
{{DEFAULTSORT:api随记}} | {{DEFAULTSORT:api随记}} |
2021年4月15日 (四) 02:18的版本
Health
/_cat/health
/_cluster/health
Indices health
/_cat/indices?health=red&v&s=store.size:desc,index
/_cat/indices?health=yellow&v&s=store.size:desc,index
/_cat/indices?health=green&v&s=store.size:desc,index
Nodes
/_cat/nodes?v
Get master node
/_cat/master?v
/_cat/shards/index_name-*?v&s=state,index&h=index,shard,prirep,state,docs,store,ip,node,unassigned.reason
/_cluster/allocation/explain
Shards
/_cat/shards
/_cat/shards?index=index_name
https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html
/_cluster/settings?pretty&include_defaults=true | grep processors
get maximum number of threads info
curl "127.1:9200/_cat/thread_pool?v&h=ip,node_name,id,name,max,size,queue_size,queue,active,rejected&pretty"
Cluster settings
/_cluster/settings?include_defaults=true&pretty
/_cluster/settings?include_defaults=true
primaries recovery settings
{ "transient": { "cluster": { "routing": { "allocation": { "node_initial_primaries_recoveries": 10, "node_concurrent_incoming_recoveries": null, "node_concurrent_outgoing_recoveries": null, "node_concurrent_recoveries": 20 } } } } }
- - new version shard allocation config
- cluster.routing.allocation.node_concurrent_recoveries
# es 6.8.2 # PUT /_cluster/settings { "persistent": { "cluster": { "routing": { "allocation": { "node_initial_primaries_recoveries": 8 } } } } }
Index settings
modify the number of replicas in bulk
{ "index" : { "number_of_replicas" : 1 } }
get indices and order by number of replicas
/_cat/indices?health=green&v&s=rep:asc,store.size:desc,index
Demo
对于有大量索引的刚重启的es集群
(主分片在1w-2w)
如果需要加快集群恢复速度,可以结合es节点资源监控图,观测节点cpu压力,以及cpu IO wait
适当通过update cluster settings接口动态增加node_initial_primaries_recoveries (Defaults to 4
)
和 node_concurrent_recoveries
(A shortcut to set both cluster.routing.allocation.node_concurrent_incoming_recoveries
and cluster.routing.allocation.node_concurrent_outgoing_recoveries
Defaults to 2
)数值
通过使用 cluster settings + include_defaults=true 筛选查到当前配置值
减少集群从red状态到yellow状态的耗时:增加索引副本数量,增加node_initial_primaries_recoveries值
减少集群从yellow状态到green状态的耗时:增加 node_concurrent_recoveries 值
可以通过访问 /_cluster/allocation/explain
接口查到阻碍集群 to green(yellow)的原因