ES集群檢查常用命令

一、集群檢查常用命令

  1. 查詢集群狀態命令:
curl -XGET "http://ip:port/_cluster/health?pretty"
  1. 查詢Es全局狀態:
curl -XGET "http://ip:port/_cluster/stats?pretty"
  1. 查詢集群設置
curl -XGET "http://ip:port/_cluster/settings?pretty"
  1. 查看集群文檔總數
curl -XGET "http://ip:port/_cat/count?v"
  1. 查看集群文檔總數
curl -XGET "http://ip:port/_cat/count?v"
  1. 查看集群別名組
curl -XGET "http://ip:port/_cat/aliases"6.查看當前集群索引分片信息
curl -XGET "http://ip:port/_cat/shards?v"注:查看某一個索引可用shards/索引名?v7.查看集群實例存儲詳細信息
curl -XGET "http://ip:port/_cat/allocation?v"8.查看當前集群的所有實例
curl -XGET "http://ip:port/_cat/nodes?v"9.查看某索引分片轉移進度
curl -XGET "http://ip:port/_cat/recovery/索引名?v"10.查看當前集群等待任務
curl -XGET "http://ip:port/_cat/pending_tasks?v"11.查看集群寫入線程池任務
curl -XGET "http://ip:port/_cat/thread_pool/bulk?v"12.查看集群查詢線程池任務
curl -XGET "http://ip:port/_cat/thread_pool/search?v"13.查看分片未分配的原因
curl -XGET "http://127.0.0.1:24100/_cat/shards?v&h=index,shard,prirep,state,node,unassigned.reason" | grep UNASSIGNED二、集群設置常用命令
  1. 設置集群分片恢復參數
curl -XPUT"http://ip:httpport/_cluster/settings"-H'Content-Type: application/json' -d' { "transient": {"cluster.routing.allocation.node_initial_primaries_recoveries":60,"cluster.routing.allocation.node_concurrent_recoveries":30,"cluster.routing.allocation.cluster_concurrent_rebalance":30} }'
  1. 根據實例名稱使EsNodeX實例下線:
curl -XPUT"http://ip:httpport/_cluster/settings" -H 'Content-Type: application/json' -d' {"transient": {"cluster.routing.allocation.exclude._name": "EsNode2@ip"} }'
  1. 根據ip使ES數據節點下線:
curl -XPUT"http://ip:httpport/_cluster/settings" -H 'Content-Type: application/json' -d' {"transient": {"cluster.routing.allocation.exclude._ip": "ip1,ip2,ip3"} }'
  1. 設置分片恢復過程中的最大帶寬速度:
curl -XPUT "http://127.0.0.1:24100/_cluster/settings" -H 'Content-Type: application/json' -d'{ "transient":{"indices.recovery.max_bytes_per_sec":"500mb"}}'
  1. 重新分片為空的主分片
curl -XPOST"http://127.0.0.1:24100/_cluster/reroute?pretty" -H 'Content-Type:application/json' -d '{"commands": [{"allocate_empty_primary": {"index": "indexname","shard": 2,"node": "EsNode1@81.20.5.24","accept_data_loss":true}}]}'
  1. 重新分配主分片,會嘗試將過期副本分片分片為主 。
curl -XPOST "http://127.0.0.1:24100/_cluster/reroute?pretty" -H 'Content-Type:application/json' -d '{"commands": [{"allocate_stale_primary": {"index": "index1","shard": 2,"node": "EsNode1@189.39.172.103","accept_data_loss":true}}]}'
  1. 清理ES所有緩存
curl -XPOST "http://ip:port/_cache/clear"8.關閉分片自動平衡
curl -XPUT "http://ip:port/_cluster/settings" -H 'Content-Type:application/json' -d '{"transient":{"cluster.routing.rebalance.enable":"none" }}'9.手動刷新未分配的分片
curl -XPOST "http://127.0.0.1:24100/_cluster/reroute?retry_failed=true"三、索引查看常用命令
  1. 查詢索引mapping和settings
curl -XGET --tlsv1.2--negotiate -k -u : 'https://ip:port/my_index_name?pretty'
  1. 查詢索引settings
curl -XGET--tlsv1.2--negotiate -k -u : 'https://ip:port/my_index_name/_settings?pretty'3.查看分片未分配詳細命令
【ES集群檢查常用命令】curl -XGET "http://127.0.0.1:24100/_cluster/allocation/explain?pretty" -H 'Content-Type:application/json' -d '{"index": "indexname","shard": 17,"primary": true}'4.修改索引只讀字段屬性為null,放開寫入
curl -XPUT"http://127.0.0.1:24100/*/_settings" -H 'Content-Type: application/json' -d '{"index.blocks.read_only_allow_delete": null}'四、索引設置常用命令1.關閉索引
curl -XPOST 'http://ip:port/my_index/_close?pretty'2.打開索引
curl -XPOST 'http://ip:port/my_index/_open?pretty'3.修改索引刷新時間:
curl -XPUT 'http://ip:port/my_index/_settings?pretty' -H 'Content-Type: application/json' -d'{"refresh_interval" : "60s"}'4.修改translog文件保留時長 , 默認為12小時
curl -XPUT 'http://ip:port/my_index/_settings?pretty' -H 'Content-Type: application/json' -d'{"index.translog.retention.age" : "30m"}'

推薦閱讀