ES环境安装
Elasticsearch-Head插件
配置git
# 解决fatal: unable to connect to github.com
$ git config --global url."https://github.com".insteadOf git://github.com
# git使用代理
$ vim ~/.ssh/config
Host github.com
User git
ProxyCommand nc -X connect -x 192.168.17.2:7897 %h %p
下载elasticsearch-head
$ git clone git://github.com/mobz/elasticsearch-head.git
# 修改Gruntfile.js
$ vim Gruntfile.js
...
connect: {
server: {
options: {
hostname: '*', # 增加这一行
port: 9100,
base: '.',
keepalive: true
}
}
}
...
# npm换源
$ npm config set registry https://registry.npmmirror.com
# 安装依赖
$ npm install
配置跨域
$ sudo vim /etc/elasticsearch/elasticsearch.yml
# 增加下面两行
http.cors.enabled: true
http.cors.allow-origin: "*"
# 重启ES
$ sudo systemctl restart elasticsearch.service
启动elasticsearch-head服务
# 在elasticsearch-head目录下执行
$ npm run start
效果如下
集群的健康检查
健康值状态
- Green:所有Primary和Replica均为active,集群健康
- Yellow:至少一个Replica不可用,但是所有Primary均为active,数据仍然是可以保证完整性的
- Red:至少有一个Primary为不可用状态,数据不完整,集群不可用
检查集群健康状态
Kibana中执行
GET _cat/health?v
# 返回示例
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1733763626 17:00:26 elasticsearch green 1 1 33 33 0 0 0 0 - 100.0%
# ------------------------------------------------------------------
GET _cluster/health
# 返回示例
{
"cluster_name": "elasticsearch",
"status": "green",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 33,
"active_shards": 33,
"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
}