合肥市建设行政主管部门网站,镇江网站外包,青岛品牌设计公司,网页代做价格要查看当前正在运行的 Elasticsearch 集群信息#xff0c;可以通过以下几种方法#xff1a;
1. 使用 _cluster/health API
_cluster/health API 返回集群的健康状态、节点数量、分片状态等信息。可以用 curl 命令直接访问#xff1a;
curl -X GET http://localhost…要查看当前正在运行的 Elasticsearch 集群信息可以通过以下几种方法
1. 使用 _cluster/health API
_cluster/health API 返回集群的健康状态、节点数量、分片状态等信息。可以用 curl 命令直接访问
curl -X GET http://localhost:9200/_cluster/health?pretty或者如果 Elasticsearch 运行在特定的 IP 地址和端口可以替换 localhost 和 9200 为相应的地址和端口例如
curl -X GET http://localhost:9200/_cluster/health?pretty返回结果类似于
{cluster_name : elasticsearch,status : green,timed_out : false,number_of_nodes : 3,number_of_data_nodes : 3,active_primary_shards : 10,active_shards : 20,relocating_shards : 0,initializing_shards : 0,unassigned_shards : 0,delayed_unassigned_shards : 0,number_of_pending_tasks : 0,number_of_in_flight_fetch : 0,task_max_waiting_in_queue_millis : 0,active_shards_percent_as_number : 100.0
}主要字段说明
cluster_name: 集群名称status: 集群状态green、yellow、rednumber_of_nodes: 集群中的节点数量number_of_data_nodes: 数据节点数量active_primary_shards: 活跃的主分片数量active_shards: 活跃的所有分片数量unassigned_shards: 未分配的分片数量
2. 使用 _cat/nodes API
_cat/nodes API 提供了关于集群节点的详细信息。你可以查看节点的资源使用情况、运行的版本等信息
curl -X GET http://localhost:9200/_cat/nodes?vpretty这将返回类似于以下的输出
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.16.10.11 25 92 7 0.12 0.10 0.09 cdm * node-1
172.16.10.12 20 88 4 0.08 0.09 0.09 cdm - node-2
172.16.10.13 15 91 6 0.09 0.08 0.09 cdm - node-3字段说明
ip: 节点的 IP 地址heap.percent: JVM 堆内存使用百分比ram.percent: RAM 使用百分比cpu: 当前 CPU 使用率load_1m: 过去 1 分钟的系统负载node.role: 节点的角色如 c 为协调节点d 为数据节点m 为主节点等master: 是否为主节点* 表示主节点
3. 使用 _cat/health API
_cat/health API 提供集群健康的简短视图
curl -X GET http://localhost:9200/_cat/health?vpretty返回类似于
cluster name status node.total node.data shards prirep unassigned.primary unassigned.relocating
elasticsearch green 3 3 10 p 0 0主要字段说明
cluster name: 集群名称status: 集群状态green、yellow、rednode.total: 总节点数量node.data: 数据节点数量shards: 分片数prirep: 主/副分片标识p 为主分片r 为副分片unassigned.primary: 未分配的主分片数量unassigned.relocating: 正在迁移的分片数量
4. 使用 /_nodes API 获取详细的节点信息
如果你需要获取更详细的节点信息如操作系统、JVM、硬件等资源使用情况可以使用 _nodes API
curl -X GET http://localhost:9200/_nodes?pretty返回的信息非常详细涵盖了节点的所有配置信息、硬件信息、JVM 设置等。
5. 使用 Kibana如果已安装 Kibana
如果你有 Kibana 部署在集群中可以通过 Kibana 的 Stack Monitoring 监控界面查看集群的状态、节点、索引等信息。只需登录 Kibana 控制台进入 Management Stack Monitoring即可看到集群的概况。 小结
你可以通过 curl 调用 Elasticsearch 的各种 _cat 和 _cluster API查看集群、节点和健康状态等信息或者使用 Kibana 的 Stack Monitoring 界面来可视化这些信息。常用的 API 包括
_cluster/health_cat/nodes_cat/health_nodes