1.首先查看集群整体健康状态

# curl -XGET http://10.27.35.94:9200/_cluster/health?pretty
{
"cluster_name" : "yunva-es",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : ,
"number_of_data_nodes" : ,
"active_primary_shards" : ,
"active_shards" : ,
"relocating_shards" : ,
"initializing_shards" : ,
"unassigned_shards" : ,
"delayed_unassigned_shards" : ,
"number_of_pending_tasks" : ,
"number_of_in_flight_fetch" : ,
"task_max_waiting_in_queue_millis" : ,
"active_shards_percent_as_number" : 86.26373626373626
}

如果是red状态,说明有节点挂掉,找到挂掉的索引分片和节点

如下例子,可以看到 voice:live:logout 这个索引的0分片都没有分配说明挂掉了,我们可以查看之前正常的时候的分片情况(可以定期将分片的分配情况记录下来)

# curl 10.26.241.237:/_cat/shards
....
voice:live:logout p STARTED .9kb 10.27.65.121 yunva_etl_es6
voice:live:logout r STARTED .9kb 10.26.241.239 yunva_etl_es3
voice:live:logout r STARTED .8kb 10.45.150.115 yunva_etl_es9
voice:live:logout p STARTED .8kb 10.25.177.47 yunva_etl_es11
voice:live:logout p STARTED .7kb 10.26.241.239 yunva_etl_es3
voice:live:logout r STARTED .7kb 10.25.177.47 yunva_etl_es11
voice:live:logout p STARTED .2kb 10.27.35.94 yunva_etl_es7
voice:live:logout r STARTED .2kb 10.27.78.228 yunva_etl_es5
voice:live:logout 0 p UNASSIGNED
voice:live:logout 0 r UNASSIGNED

定期记录分片的脚本

# cat es_shard.sh
#!/bin/bash echo $(date +"%Y-%m-%d %H:%M:%S") >> /data/es_shards.txt
curl -XGET http://10.26.241.237:9200/_cat/shards >> /data/es_shards.txt

2.依次查询节点的健康状态,如果哪个节点不返回,或者很慢,可能是内存溢出,需要直接重启该节点

# curl -XGET http://IP:9200/_cluster/health?pretty

内存溢出的典型特征会在elasticsearch/bin目录下产生类似如下文件:

hs_err_pid27186.log
java_pid1151.hprof

3.zabbix添加监控
①如果挂掉自动启动(注意不能是root用户)

自动启动elasticsearch脚本:

# cat /usr/local/zabbix-agent/scripts/start_es.sh

#!/bin/bash
# if elasticsearch process exists kill it
source /etc/profile count_es=`ps -ef|grep elasticsearch|grep -v grep|wc -l`
if [ $count_es -gt ];then
ps -ef|grep elasticsearch|grep -v grep|/bin/kill `awk '{print $2}'`
fi
rm -f /data/elasticsearch-5.0./bin/java_pid*.hprof
# start it
su yunva -c "cd /data/elasticsearch-5.0.1/bin && /bin/bash elasticsearch &"

②有hs_err*.log或者hprof文件删除文件然后重启该节点(可以直接触发start_es.sh脚本)

elasticsearch报错监控项:
UserParameter=es_debug,sudo /bin/find /data/elasticsearch-5.0.1/bin/ -name hs_err_pid*.log -o -name java_pid*.hprof|wc -l

java报错的监控项:

UserParameter=java_error,sudo /bin/find /home -name hs_err_pid*.log -o -name java_pid*.hprof -o -name jvm.log|wc -l

③curl -XGET http://IP:9200/_cluster/health?pretty 如果响应时间超过30S重启

for IP in 10.28.50.131 10.26.241.239 10.25.135.215 10.26.241.237 10.27.78.228 10.27.65.121 10.27.35.94 10.30.136.143 10.174.12.230 10.45.150.115 10.25.177.47
do
curl -XGET http://$IP:9200/_cluster/health?pretty
done

4.优化配置:

# 以下配置可以减少当es节点短时间宕机或重启时shards重新分布带来的磁盘io读写浪费

discovery.zen.fd.ping_timeout: 300s
discovery.zen.fd.ping_retries:
discovery.zen.fd.ping_interval: 30s
discovery.zen.ping_timeout: 300s

5.es集群状态检测
UserParameter=es_cluster_status,curl -sXGET http://10.11.117.18:9200/_cluster/health/?pretty | grep "status"|awk -F '[ "]+' '{print $4}'|grep -c 'green'

后续如果有其他方面的一些好的方法也会更新上来

索引修改以后,需要刷新index表达式,否则无法正常识别

elasticsearch5.0.1集群排错的几个思路总结的更多相关文章

  1. elasticsearch5.0.1集群一次误删除kibana索引引发的血案

    elasticsearch集群中一次删除kibana索引引发的血案 1.问题发生的过程: 早上的时候有某个索引无法看到报表数据,于是就点该报表多次,估计集群被点挂了,报错:Elasticsearch ...

  2. elasticsearch5.0.1集群索引分片丢失的处理

    elasticdump命令安装 yum install npm npm install elasticdump -g 命令安装完毕,可以测试. 可能会报出nodejs的版本之类的错误,你需要升级一下版 ...

  3. ElasticSearch-5.3.1集群环境搭建,安装ElasticSearch-head插件,安装错误解决

    说起来甚是惭愧,博主在写这篇文章的时候,还没有系统性的学习一下ES,只知道可以拿来做全文检索,功能很牛逼,但是接到了任务不想做也不行, leader让我搭建一下分布式的ES集群环境,用来支持企业信用数 ...

  4. Redis 3.0 Cluster集群配置

    Redis 3.0 Cluster集群配置 安装环境依赖 安装gcc:yum install gcc 安装zlib:yum install zib 安装ruby:yum install ruby 安装 ...

  5. 分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群(转载-2)

    原文:http://www.cnblogs.com/PurpleDream/p/4510279.html 分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群 前言:       ...

  6. 菜鸟玩云计算之十九:Hadoop 2.5.0 HA 集群安装第2章

    菜鸟玩云计算之十九:Hadoop 2.5.0 HA 集群安装第2章 cheungmine, 2014-10-26 在上一章中,我们准备好了计算机和软件.本章开始部署hadoop 高可用集群. 2 部署 ...

  7. 菜鸟玩云计算之十八:Hadoop 2.5.0 HA 集群安装第1章

    菜鸟玩云计算之十八:Hadoop 2.5.0 HA 集群安装第1章 cheungmine, 2014-10-25 0 引言 在生产环境上安装Hadoop高可用集群一直是一个需要极度耐心和体力的细致工作 ...

  8. Redis-4.0.11集群配置

    版本:redis-3.0.5 redis-3.2.0  redis-3.2.9  redis-4.0.11 参考:http://redis.io/topics/cluster-tutorial. 集群 ...

  9. Redis 5.0.5集群搭建

    Redis 5.0.5集群搭建 一.概述 Redis3.0版本之后支持Cluster. 1.1.redis cluster的现状 目前redis支持的cluster特性: 1):节点自动发现 2):s ...

随机推荐

  1. html body 100%

    html body 100% html <div class="header"> </div> <div class="main" ...

  2. golang命令行参数

    os.Args获取命令行参数 os.Args是一个srting的切片,用来存储所有的命令行参数 package main import ( "fmt" "os" ...

  3. golang sort包使用

    https://studygolang.com/static/pkgdoc/pkg/sort.htm#StringSlice.Search package main import ( "fm ...

  4. cdqz2017-test1-数论 (BSGS + 二次剩余 + CRT)

    若m=0, 就是求n^2n ≡ x mod p (x--) 因为一定优解,所以x一定是p的二次剩余 令g为p的1个原根,且g^k ≡ x mod p 则k是偶数,证明k是偶数: 假设 g1^k1 ≡ ...

  5. MySQL学习笔记(二)性能优化的笔记(转)

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  6. Sqlserver远程过程调用失败

    这种情况一般是由于有高版本的SqlServer导致的,网上有删除Loaldb之类的建议,这样其实不太好,回头用高版本数据库的话还得装回来.其实可以通过计算机管理->服务和应用程序进行设置,用下面 ...

  7. html取消回车刷新提交

    <form class="weui-search-bar__form" onsubmit="return false;"> <form cla ...

  8. 14.Scrapy Shell

    Scrapy终端是一个交互终端,我们可以在未启动spider的情况下尝试及调试代码,也可以用来测试XPath或CSS表达式,查看他们的工作方式,方便我们爬取的网页中提取的数据. 如果安装了 IPyth ...

  9. python中的PEP是什么?怎么理解?(转)

    PEP是什么? PEP的全称是Python Enhancement Proposals,其中Enhancement是增强改进的意思,Proposals则可译为提案或建议书,所以合起来,比较常见的翻译是 ...

  10. python之字符串常用的方法

    1. 去掉空格或换行符 s='. hello .world .\n' new_s = s.strip()#默认去掉字符串前后的空格和换行符 new_s = s.strip('.')#可传参去掉字符串前 ...