elasticsearch常用命令总结

发布时间 2023-06-01 20:01:33作者: Bingmous

目录

    # 查看集群状态
    curl http://*:9200/_cluster/health?pretty
    
    # 查看所有索引状态
    curl "http://*:9200/_cat/indices?pretty"
    
    # 查看异常索引状态
    curl "http://*:9200/_cat/indices?v&health=red"
    
    # 查看异常索引分片分配状态
    curl "http://*:9200/_cat/shards/your_index_name?v"
    
    # 查看分片分配不成功的原因
    curl "http://*:9200/_cat/shards/ your _index_name?v&h=n,index,shard,prirep,state,sto,sc,unassigned.reason,unassigned.details"
    
    # 重新分配失败的分片
    curl -XPOST "http://*:9200/_cluster/reroute?retry_failed=true"
    
    # 修改副本数
    curl -XPUT http://*:9200/*/_settings -H 'Content-Type:application/json'  -d '{"index":{"numer_of_replicas":0}}'
    ## *表示所有索引
    
    # 设置scroll上限
    curl -X PUT http://*:9200/_cluster/settings -H 'Content-Type:application/json' -d '{"persistent":{"search.max_open_scroll_context":5000},"transient":{"search.max_open_scroll_context":5000}}'
    
    # 取消索引只读
    curl -XPUT -H "Content-Type: application/json" http://*:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": false}'