查看系统基本信息:
curl http://127.0.0.1:9200/ curl -XGET 'http://127.0.0.1:9200/?pretty'
节点(Node)相关:
查看节点信息:
curl -XGET 'http://127.0.0.1:9200/_cat/nodes?v'
查看所有节点信息:
curl -XGET 'http://127.0.0.1:9200/_nodes?pretty=true'
查看指定节点(node-es-03)的信息:
curl -XGET 'http://127.0.0.1:9200/_nodes/node-es-03?pretty=true'
索引(Indices)相关:
列出集群中所有的索引:
curl -XGET 'http://127.0.0.1:9200/_nodes/node-es-03?pretty=true'
查看指定索引(date.searchlog)的状态:
curl -XGET 'http://127.0.0.1:9200/logstash-bbl/_stats?pretty'
查看指定索引(date.searchlog)的结构:
curl -XGET 'http://127.0.0.1:9200/logstash-bbl?pretty'
查看指定索引(date.searchlog)的映射结构:
curl -XGET 'http://127.0.0.1:9200/logstash-bbl/_mapping?pretty'
创建新的索引:
curl -XPUT "http://127.0.0.1:9200/logstash-bbl?pretty" -d ' { "settings" : { "index" : { "refresh_interval" : "5s", "number_of_shards" : "1", "number_of_replicas" : "1" } } }'
删除指定的索引:
curl -XDELETE 'http://127.0.0.1:9200/logstash-bbl'
删除指定索引的副本分片(es5):
curl -XPUT "http://127.0.0.1:9200/logstash-bbl/_settings?pretty=1" -d '{ "index" :{ "number_of_replicas" : 1 } }'
删除指定索引的副本分片(es7):
curl -u es-user:es-password -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9210/user-access-2000.01.01/_settings?pretty=true' -d '{ "index" :{ "number_of_replicas" : 0 } }'
分片(Shards)相关:
查各节点中分片的分布情况:
curl -XGET 'http://127.0.0.1:9200/_cat/allocation?v'
查看集群中所有分片信息:
curl -XGET 'http://127.0.0.1:9200/_cat/shards?v'
查看指定分片信息:
curl -XGET 'http://127.0.0.1:9200/_cat/shards/statistics?v'
迁移分片(es5):node-es-04 --> storage.track(0) --> node-es-01
curl -XPOST 'http://127.0.0.1:9200/_cluster/reroute' -d '{ "commands":[{ "move":{ "index":"storage.track", "shard":0, "from_node":"node-es-04", "to_node":"node-es-01" }}]}'
迁移分片(es7):node-es-04 --> storage.track(0) --> node-es-01
curl -u es-user:es-password -H "Content-Type: application/json" -XPOST 'http://127.0.0.1:9210/_cluster/reroute' -d '{ "commands":[{ "move":{ "index":"storage.track", "shard":0, "from_node":"node-es-04", "to_node":"node-es-01" }}]}'
集群(Cluster)相关:
查看集群概要信息:
curl -XGET 'http://127.0.0.1:9200/_cluster/stats?pretty'
查看集群健康状态信息:
curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty'
查看集群设置信息:
curl -XGET 'http://127.0.0.1:9200/_cluster/settings?pretty'
允许集群生成新的分片:
curl -XPUT http://127.0.0.1:9200/_cluster/settings?pretty=1 -d '{ "persistent":{ "cluster.routing.allocation.enable": "all" } }'
禁止集群生成新的分片:
curl -XPUT http://127.0.0.1:9200/_cluster/settings?pretty=1 -d '{ "persistent":{ "cluster.routing.allocation.enable": "none" } }'
允许集群中所有分片自动均衡:
curl -XPUT http://127.0.0.1:9200/_cluster/settings?pretty=1 -d '{ "persistent":{ "cluster.routing.rebalance.enable": "all" } }'
只允许集群中的副本分片自动均衡:
curl -XPUT http://127.0.0.1:9200/_cluster/settings?pretty=1 -d '{ "persistent":{ "cluster.routing.rebalance.enable": "replicas" } }'
禁止集群中的分片自动均衡:
curl -XPUT http://127.0.0.1:9200/_cluster/settings?pretty=1 -d '{ "persistent":{ "cluster.routing.rebalance.enable": "none" } }'
设置集群自动均衡最低剩余存储容量(es7):
curl -u es-user:es-password -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9210/_cluster/settings?pretty=true' -d '{ "persistent":{ "cluster.routing.allocation.disk.watermark.low": "90%" } }'
设置集群自动均衡最高使用存储容量(es7):
curl -u es-user:es-password -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9210/_cluster/settings?pretty=true' -d '{ "persistent":{ "cluster.routing.allocation.disk.watermark.low": "95%" } }'
设置集群信息更新时间(es7):
curl -u es-user:es-password -H "Content-Type: application/json" -XPUT 'http://127.0.0.1:9210/_cluster/settings?pretty=true' -d '{ "persistent":{ "cluster.info.update.interval": "1m" } }'
[THE END]