前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ES维护常见问题(持续更新)

ES维护常见问题(持续更新)

作者头像
YG
发布2018-05-23 17:15:17
3.4K0
发布2018-05-23 17:15:17
举报
文章被收录于专栏:YG小书屋YG小书屋
1 存在未分片索引

1)找出未分片的索引

代码语言:javascript
复制
curl xxx/_cat/shards?v | grep UNASSIGNED

2)查看未分配的原因

代码语言:javascript
复制
curl -XGET 'http://xxx/_cluster/allocation/explain?pretty' -d '{
    "index": "index_name",
    "shard": 0,
    "primary": true
}'

3)根据原因进行处理,目前遇到过以下三种情况:

代码语言:javascript
复制
a. 某个节点的某个磁盘满(手动移动分片到大磁盘机器即可,最好用大磁盘机器)
b. allocation 限制,不能分配(修改allocation的规则即可)
c. 重试次数达到限制,依然不能分配(手动尝试即可 curl -XPOST 'xxx/_cluster/reroute?retry_failed&pretty')
2 下线剔除某台机器

1) 不能用数组的形式

代码语言:javascript
复制
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
    "transient": {
        "cluster.routing.allocation.exclude._ip": ["ip1","ip2","ip3"]
    }
}'

2)逗号后面不能有空格

代码语言:javascript
复制
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
    "transient": {
        "cluster.routing.allocation.exclude._ip": "ip1, ip2, ip3"
    }
}'

3)正确的写法

代码语言:javascript
复制
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
    "transient": {
        "cluster.routing.allocation.exclude._ip": "ip1,ip2,ip3"
    }
}'
3 机器突然重启,ES节点不能正常启动

这种主要是因为状态文件为空导致的,查看日志,找出状态文件路径,删除即可。

代码语言:javascript
复制
Error injecting constructor, ElasticsearchException[java.io.IOException: failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IOException[failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IllegalStateException[class org.apache.lucene.store.BufferedChecksumIndexInput cannot seek backwards (pos=-16 getFilePointer()=0)];
  at org.elasticsearch.gateway.GatewayMetaState.<init>(Unknown Source)
  while locating org.elasticsearch.gateway.GatewayMetaState
Caused by: ElasticsearchException[java.io.IOException: failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IOException[failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IllegalStateException[class org.apache.lucene.store.BufferedChecksumIndexInput cannot seek backwards (pos=-16 getFilePointer()=0)];

找出空文件删除即可:

find /data*/search/data/nodes/0/indices/ | grep state | grep "\.st" | xargs ls -l | awk '{if($5==0)print $0}' 
-rw-rw-r-- 1 search search    0 Oct  1 22:53 /data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
-rw-rw-r-- 1 search search    0 Oct  1 22:53 /data3/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
-rw-rw-r-- 1 search search    0 Oct  1 22:53 /data4/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-1.st
-rw-rw-r-- 1 search search    0 Oct  1 22:53 /data4/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
4 查询提示shard数达到限制
代码语言:javascript
复制
"reason" : "Trying to query 1344 shards, which is over the limit of 1000. This limit exists because querying 
many shards at the same time can make the job of the coordinating node very CPU and/or memory 
intensive. It is usually a better idea to have a smaller number of larger shards. Update 
[action.search.shard_count.limit] to a greater value if you really want to query that many shards at the same time."

修改配置即可:

代码语言:javascript
复制
curl -u admin:admin -XPUT 'https://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d' 
{
    "persistent" : {
        "action.search.shard_count.limit" : "1500"
    }
}
'
or
curl -u admin:admin -XPUT 'https://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d' 
{
    "transient" : {
        "action.search.shard_count.limit" : "1500"
    }
}
'

persistent :重启后依然有效 transient :重启后无效

5 standard分词器无法以逗号分割两个数字字母字符串

我开发了一个分词器a。有天查询的时候发现,标准分词器要比a查出的数据量少一半。查看不同文档的分词效果:

代码语言:javascript
复制
curl -XGET 'xx/xx/xx/AV9zRnrjq2szramqtpAT/_termvector?fields=strdescription&pretty=true'

发现标准分词没能将字符串分成想要的形式,比如说:

代码语言:javascript
复制
curl -XPOST 'xxx/_analyze?pretty' -H 'Content-Type: application/json' -d'
{
  "tokenizer": "standard",
  "text": "2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014"
}
'

针对与这种字符串我们期望字符串能够按照逗号分割,但是用标准分词你会发现,这个字符串的term是它自己。具体原因应该是:逗号两边都是数字,我们知道针对于一个大数字比如说10,000,我们喜欢在数字间加一个逗号,所以上述字符串无法分割。 解决方案:将逗号变为空格即可。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.11.14 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 存在未分片索引
  • 2 下线剔除某台机器
  • 3 机器突然重启,ES节点不能正常启动
  • 4 查询提示shard数达到限制
  • 5 standard分词器无法以逗号分割两个数字字母字符串
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档