最近忙于毕业论文2个月没有更新博客了,还有小伙伴的私信也是才看到,真是非常抱歉了!今天要说的是对Elasticsearch的集群进行管理。主要包括:集群节点监控、集群分片迁移、集群节点配置、节点发现与集群平衡位置。实验用到的前置安装环境及版本,Elasticsearch、kibana、head插件,版本均为5.2.0
1,集群节点监控
Elasticsearch运行时,监控非常重要,作用是能够检测和预防问题的发生。对Elasticsearch的监控主要包括三类:1)和集群相关的,_cluster作为开头;2)监控节点相关的,_nodes开头;3)任务相关的,_tasks开头。
1.1 集群健康值查看
在kibana中的执行命令
GET _cluster/health?pretty=true
执行结果如下
查看具体索引的健康情况,在health后面添加索引名称即可。
返回值的含义:green——所有主分片和副本分片都是活动状态;yellow——所有主分片活动状态,其他副本状态不一定;red——主分片有不是活动状态的。
1.2集群状态
命令如下
GET _cluster/state
执行结果如下
state后面可以增加参数:metadata请求索引结构相关的信息;routing_talbe请求索引分片相关的信息;routing_nodes请求路由节点相关的信息;
实例语句
GET _cluster/health?pretty=true
GET _cluster/health/gcrz3?pretty=true
GET _cluster/state
GET _cluster/state/metadata/foo
GET _cluster/state/metadata/bar
GET _cluster/state/routing_table/foo
GET _cluster/state/routing_table/bar
GET _cluster/state/_all
GET _cluster/state/_all/foo
GET _cluster/state/_all/bar
GET _cluster/state/blocks
1.3 集群统计
集群统计语句如下
GET _cluster/state
1.4 集群任务管理
语句如下
GET _tasks
GET _tasks?nodes
GET _tasks/task_id=578360
GET _tasks?parent_task_id=
1.5 节点管理
语句如下
GET _nodes
GET _nodes/hot_threads
GET _nodes/stats