elasticsearch常用命令

前面我创建了一个包含一个主节点和一个子节点的elasticsearch集群。有时需我们需要查看集权或是单个节点的状态。

  • 在浏览器中输入localhost:9200/_cat可以列出所有可用的命令
=^.^=
/_cat/allocation 
/_cat/shards
/_cat/shards/{index}
/_cat/master 
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
  • GET /_cat/master 查看当前的master uuid, ip地址,master的名称.可以任一节点执行的

  • GET /_cat/nodes 查看所有节点信息,同样可以加 ?v显示表头

  • GET /_cat/health?v 查看集群是否健康,加?v会显示表头,不加?v则不显示表头

  • GET /_cat/indices?v 列出所有索引及存储大小

  • GET /_cluster/health?pretty 查看集群健康状况

  • POST /_cluster/nodes/aaaa/_shutdown 关闭指定节点

  • POST /_cluster/nodes/_shutdown 关闭整个集群

查询命令相关: https://www.cnblogs.com/shaner/p/5661071.html

中文文档: https://learnku.com/index.php/docs/elasticsearch-php/6.0/about/2015

官方文档: https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.5.x/index.html