elasticsearch的服务器响应异常及解决策略(转)

摘要:
9200/_ plugin/head/我在browse river_ riverStatusImport_ Fail中看到了它。查看弹性搜索日志,发现有几条数据由于异常而无法同步。--查看线程池设置--curl XGET“http://_nodes/thread_pool/”非批量入站线程池设置可以修改如下:30 queue_size:

详述:

1 _riverStatus Import_fail 

问题描述: 发现有个索引的数据同步不完整,在 http://192.168.1.17:9200/_plugin/head/ 在browse - river里看到 _riverStatus Import_fail

查看 elasticsearch 的log发现 有几条数据由于异常造成同步失败,处理好数据好重新建索引数据同步正常。

es_rejected_execution_exception <429>

此异常主要是因为请求数过多,es的线程池不够用了。

默认bulk thead pool set  queue capacity =50 这个可以设置大点

打开 elasticsearch.yml 在末尾加上 

threadpool:
    bulk:
        type: fixed
        size: 60
        queue_size: 1000

重新启动服务即可

另:

--查看线程池设置--
curl -XGET "http://localhost:9200/_nodes/thread_pool/"


非bulk入库thread pool设置可以这样修改
threadpool:
    index:
        type: fixed
        size: 30
        queue_size: 1000

关于该异常,有网友给的解释挺好的:

Elasticsearch has a thread pool and a queue for search per node. A thread pool will have N number of workers ready to handle the requests. When a request comes and if a worker is free , this is handled by the worker. Now by default the number of workers is equal to the number of cores on that CPU. When the workers are full and there are more search requests , the request will go to queue. The size of queue is also limited. Its by default size is say 100 and if there happens more parallel requests than this , then those requests would be rejected as you can see in the error log.

The solution to this would be to -

1.    Increase the size of queue or threadpool - The immediate solution for this would be to increase the size of the search queue. We can also increase the size of threadpool , but then that might badly effect the performance of individual queries. So increasing the queue might be a good idea. But then remember that this queue is memory residential and increasing the queue size too much can result in Out Of Memory issues. You can get more info on the same here.
2.    Increase number of nodes and replicas - Remember each node has its own search threadpool/queue. Also search can happen on primary shard OR replica.

关于thread pool,可参看:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html

3 create_failed_engine_exception <500>

相关分片损坏.

删除该分片重建即可。

4 mapper_parsing_exception <400>

存在字段格式不正确,与mapping不匹配。

检查文档字段格式,格式不正确有两种情况,其一是格式与mapping不匹配,其二是对字符串而言,可能字符非法。

5 index_not_found_exception <404>

索引不存在。

建立索引。

6 Result window is too large, from + size must be less than or equal to: [10000] but was [10000000].

result window的值默认为10000,比实际需求的小,故而报错。

两个方法:其一,在elasticsearch.yml中设置index.max_result_window,也可以直接修改某索引的settings:

curl -XPUT http://127.0.0.1:9200/indexname/_settings -d '{ "index" : { "max_result_window" : 100000000}}'

其二,使用scroll api。

POST /twitter/tweet/_search?scroll=1m
{
    "size": 100,
    "query": {
        "match" : {
            "title" : "elasticsearch"
        }
    }
}

从服务器响应获取scroll_id,然后后面批次的结果可通过循环使用下面语句得到:

POST  /_search/scroll 
{
    "scroll" : "1m", 
    "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" 
}

关于scroll api,可参看:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

7 illegal_argument_exception: number of documents in the index cannot exceed 2147483519 <400>

分片上文档数达到20亿上限,无法插入新文档。

重建索引,增加分片;也可以增加节点。

8 action_request_validation_exception: Validation Failed:1:no requests added <400>

这个错误一般出现在bulk入库时,是格式不对,每行数据后面都得回车换行,最后一行后要跟空行。

修改格式就可以重新bulk了。

9 No Marvel Data Found (marvel error)

一般是人为删除(比如在sense插件里执行删除命令)marvel数据,导致marvel采集出错(删除了半天数据,另外半天数据将无法正常采集),不能统计;对于这种情况,等第二天marvel就可以正常使用了。

也有可能是9300端口被占用,marvel默认使用9300端口;对于这种情况,找到9300端口占用进程,kill掉,重启kibana即可。

10 Bad Request, you must reconsidered your request. <400>

一般是数据格式不对。

11 Invalid numeric value: Leading zeroes not allowed <400>

这种情况是整数类型字段格式不正确,比如一个整数等于0000。检查每个整数字段的数据生成即可。

12 #Deprecation: query malformed, empty clause found at [9:9] 

查询语句不合法,里面含有空大括号。

13 query:string_index_out_of_bounds_exception

查询数据时,曾遇到这个问题。后来发现是http请求头格式不对,url里多了一个斜杠,却报了这个错误,特此记录。

14 failed to obtain node locks

在同一个节点(linux系统)上启动多个elasticsearch时出现failed to obtain node locks错误,启动失败.

转载自:https://www.cnblogs.com/jiu0821/p/6075833.html#_label0_7

免责声明:文章转载自《elasticsearch的服务器响应异常及解决策略(转)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇信赖过度风险与样本规模成反向关系怎么理解Thrift的TJsonProtocol协议分析下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

1032. 挖掘机技术哪家强(20)

1032. 挖掘机技术哪家强(20) 为了用事实说明挖掘机技术到底哪家强,PAT组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。 输入格式: 输入在第1行给出不超过105的正整数N,即参赛人数。随后N行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从1开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。 输出...

python3 学习

实现备份文件功能 file_name = input("输入备份的文件: ") postion = file_name.rfind(".") file_name_new = file_name[:postion] + "[附件]" + file_name[postion:] f1 = open(file_name,'r',encoding="UT...

转:Oracle11g面向开发人员的重要新特性:Pivot 和 Unpivot

  Pivot 和 Unpivot使用简单的 SQL 以电子表格类型的交叉表报表显示任何关系表中的信息,并将交叉表中的所有数据存储到关系表中。Pivot如您所知,关系表是表格化的,即,它们以列-值对的形式出现。假设一个表名为 CUSTOMERS。 SQL> desc customersName                           ...

微信内置浏览器在使用video标签时(安卓)默认全屏的原因及解决办法

根据X5论坛得到的答案是:设计如此。   腾讯真是越来越嚣张了,一家独大后用户体验都不注重了(不给程序员留活路)。   听说有个申请加入vdeo白名单的,域名验证后就可以解决默认全屏(反正我是没见过申请入口,不给钱,想进来没门。) 最终的解决办法:   将video转化为canvas,逐帧播放,不过canvas貌似最高可以达到60帧/s,不过页够用了(扯淡...

vue中选择图片,预览图片,返回base64

1.html内容 <el-col :span="20" style="margin-left: 100px;"> <input type="file" name="avatar" accept="image/gif,image/jpeg,image/jpg,image/png" @change="changeCoverImg($ev...

Element-ui局部添加loading效果

项目:Vue+element-ui 在一个表格数据加载时,因为需要连接其它东西,所以后台接口返回数据需要较长时间,因此添加局部Loading效果,增加用户体验度, 最开始使用下面代码,直接放到<el-table>中,测试时遇到问题 element-loading-spinner="el-icon-loading" :element-loadin...