ELASTICSEARCH健康red的解决
今天惯例看统计报表, 才发现es集群悲剧了......昨天下午到今天早上, 持续报错, 写了1G的错误日志>_<#(暂无监控....)
当前状态: 单台机器, 单节点(空集群), 200W 数据, 500+shrads, 约3G大小
以下是几个问题的处理过程
大量unassigned shards
其实刚搭完运行时就是status: yellow(所有主分片可用,但存在不可用的从分片), 只有一个节点, 主分片启动并运行正常, 可以成功处理请求, 但是存在unassigned_shards, 即存在没有被分配到节点的从分片.(只有一个节点.....)
.当时数据量小, 就暂时没关注. 然后, 随着时间推移, 出现了大量unassigned shards
curl -XGET http://localhost:9200/_cluster/health\?pretty
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 1,
"active_primary_shards" : 538,
"active_shards" : 538,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 558,
"number_of_pending_tasks" : 0
}
处理方式: 找了台内网机器, 部署另一个节点(保证cluster.name一致即可, 自动发现, 赞一个). 当然, 如果你资源有限只有一台机器, 使用相同命令再启动一个es实例也行. 再次检查集群健康, 发现unassigned_shards减少, active_shards增多.
操作完后, 集群健康从yellow恢复到 green
status: red
集群健康恶化了......
这次检查发现是status: red(存在不可用的主要分片)
curl -XGET http://localhost:9200/_cluster/health\?pretty
{
"cluster_name" : "elasticsearch",
"status" : "red", // missing some primary shards
"timed_out" : false,
"number_of_nodes" : 4,
"number_of_data_nodes" : 2,
"active_primary_shards" : 538,
"active_shards" : 1076,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 20, // where your lost primary shards are.
"number_of_pending_tasks" : 0
}
fix unassigned shards
开始着手修复
查看所有分片状态
curl -XGET http://localhost:9200/_cat/shards
找出UNASSIGNED分片
curl -s "http://localhost:9200/_cat/shards" | grep UNASSIGNED
pv-2015.05.22 3 p UNASSIGNED
pv-2015.05.22 3 r UNASSIGNED
pv-2015.05.22 1 p UNASSIGNED
pv-2015.05.22 1 r UNASSIGNED
查询得到master节点的唯一标识
curl 'localhost:9200/_nodes/process?pretty'
{
"cluster_name" : "elasticsearch",
"nodes" : {
"AfUyuXmGTESHXpwi4OExxx" : {
"name" : "Master",
....
"attributes" : {
"master" : "true"
},
.....
执行reroute(分多次, 变更shard的值为UNASSIGNED查询结果中编号, 上一步查询结果是1和3)
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
"commands" : [ {
"allocate" : {
"index" : "pv-2015.05.22",
"shard" : 1,
"node" : "AfUyuXmGTESHXpwi4OExxx",
"allow_primary" : true
}
}
]
}'
批量处理的脚本(当数量很多的话, 注意替换node的名字)
#!/bin/bash
for index in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
for shard in $(curl -s 'http://localhost:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
echo $index $shard
curl -XPOST 'localhost:9200/_cluster/reroute' -d "{
'commands' : [ {
'allocate' : {
'index' : $index,
'shard' : $shard,
'node' : 'Master',
'allow_primary' : true
}
}
]
}"
sleep 5
done
done
“Too many open files”
发现日志中大量出现这个错误
执行
curl http://localhost:9200/_nodes/process\?pretty
可以看到
"max_file_descriptors" : 4096,
官方文档中
Make sure to increase the number of open files descriptors on the machine (or for the user running elasticsearch). Setting it to 32k or even 64k is recommended.
而此时, 可以在系统级做修改, 然后全局生效
最简单的做法, 在bin/elasticsearch文件开始的位置加入
ulimit -n 64000
然后重启es, 再次查询看到
"max_file_descriptors" : 64000,
问题解决
ELASTICSEARCH健康red的解决的更多相关文章
- ELK 学习笔记之 elasticsearch启动时Warning解决办法
elasticsearch启动时Warning解决办法: 转载:http://www.dajiangtai.com/community/18136.do?origin=csdn-geek&dt ...
- 【docker】elasticsearch-head无法连接elasticsearch的原因和解决,集群健康值:未连接,ElasticSearch——跨域访问的问题
环境 ==================== 虚拟机启动 centos 7 ip:192.168.92.130 elasticsearch 5.6.9 port:9200 9201 elas ...
- elasticsearch 索引 red 状态恢复 green
方案一 找到状态为 red 的索引 curl -X GET "http://172.xxx.xxx.174:9288/_cat/indices?v=" red open index ...
- Elasticsearch 健康状态处理
笔者在自己的 ubuntu 服务器上使用 GET /_cat/health?v 命令时,返回值如下所示 可以看到集群状态为 yellow,这是什么意思呢?原来在 es 的集群状态中,有三种情况,官网描 ...
- elasticsearch常见异常及解决办法
报错信息:Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 20602552 ...
- logstash 读取MySQL数据到elasticsearch 相差8小时解决办法
logstash和elasticsearch是按照UTC时间的,kibana却是按照正常你所在的时区显示的,是因为kibana中可以配置时区信息. 具体看这个: logstash 的配置文件添加 fi ...
- 线上 ELK 集群健康值 red 状态问题排查与解决
之前一直运行正常的数据分析平台,最近一段时间没有注意发现日志索引数据一直未生成,大概持续了n多天,当前状态: 单台机器, Elasticsearch(下面称ES)单节点(空集群),1000+shrad ...
- Elasticsearch 集群和索引健康状态及常见错误说明
之前在IDC机房线上环境部署了一套ELK日志集中分析系统, 这里简单总结下ELK中Elasticsearch健康状态相关问题, Elasticsearch的索引状态和集群状态传达着不同的意思. 一. ...
- Elasticsearch 集群 - 健康检查
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
随机推荐
- StartServiceCtrlDispatcher
服务程序通常编写成控制台类型的应用程序,总的来说,一个遵守服务控制管理程序接口要求的程序 包含下面三个函数: 1.服务程序主函数(main):调用系统函数 StartServiceCtrlDispat ...
- Laravel Eloquent Model->isDirty() Function
1 引言 introduction 有时,我们需要在 Model 某些属性发生变化时,作出相应的处理. 这时,我们可以使用 Model->isDirty() 方法进行判断. 2 场景 比如,姓名 ...
- eclipse新建web项目,发布 run as 方式和 new server然后添加项目方式。 后者无法自动编译java 成class文件到classes包下。
eclipse新建web项目,发布 run as 方式和 new server然后添加项目方式. 后者无法自动编译java 成class文件到classes包下. 建议使用run as - run ...
- win8 app code中设置Resources里定义好的Style
WPF中应该可以用这个: rectangle.Style = (Style)FindResource("FormLabelStyle"); 但 Win8.1 App是个精简框架,F ...
- 构造函数constructor 与析构函数destructor(二)
(1)转换构造函数 转换构造函数的定义:转换构造函数就是把普通的内置类型转换成类类型的构造函数,这种构造函数只有一个参数.只含有一个参数的构造函数,可以作为两种构造函数,一种是普通构造函数用于初始化对 ...
- 2018.09.08 bzoj1151: [CTSC2007]动物园zoo(状压dp)
传送门 状压dp好题啊. 可以发现这道题的状压只用压缩5位. f[i][j]表示当前在第i个位置状态为j的最优值. 显然可以由f[i-1]更新过来. 因此只用预处理在第i个位置状态为j时有多少个小朋友 ...
- 2018.07.17 牛奶模式Milk Patterns(二分+hash)
传送门 一道简单的字符串.这里收集了几种经典做法: SAM,不想写. 后缀数组+二分,不想写 后缀数组+单调队列,不想写 hash+二分,for循哈希,天下无敌!于是妥妥的hash 代码如下: #in ...
- hdu - 1072(dfs剪枝或bfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1072 思路:深搜每一个节点,并且进行剪枝,记录每一步上一次的s1,s2:如果之前走过的时间小于这一次, ...
- 在“开始”菜单中的“运行”一栏输入特定命令打开windows程序
winver 检查Windows版本 wmimgmt.msc 打开Windows管理体系结构(wmi) wupdmgr Windows更新程序 wscript Windows脚本宿主设置 ...
- 快速排序—三路快排 vs 双基准
快速排序被公认为是本世纪最重要的算法之一,这已经不是什么新闻了.对很多语言来说是实际系统排序,包括在Java中的Arrays.sort. 那么快速排序有什么新进展呢? 好吧,就像我刚才提到的那样(Ja ...