A-A+

Elasticsearch 索引备份报错解决方案

2018年09月29日 15:55 学习笔记 暂无评论 共1759字 (阅读6,070 views次)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

因为我个人的Elasticsearch始终装在虚拟机里,因为有可能会经常重新恢复虚拟机快照,所以怕数据丢失,今天想着备份数据,结果备份Elasticsearch的索引就各种出错。首先看看报错如下。

{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character (' ' (code 160)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@a3c4d0; line: 2, column: 3]"}],"type":"json_parse_exception","reason":"Unexpected character (' ' (code 160)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@a3c4d0; line: 2, column: 3]"},"status":500}

其实报错已经告诉错误原因了。json_parse_exception 你可以把下划线去掉就理解了。json parse exception = json解析异常。
很明显了吧。其实是JSON语句错了,你可以先检查一下你的JSON语句是否正确,然后再执行相应的命令。你可以在https://jsonformatter.org/ 这个网站里面检测你的json语句。

所以以后你的 Elasticsearch status 500的时候你需要先自己看一下原因,如果弄不懂再google。

----------------下面是本人引用他人的问题与答案-----------------
I am trying to do a POST -bulk and am getting an error?

{
"error": {
"root_cause": [
{
"type": "json_e_o_f_exception",
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@5c64fb18; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@5c64fb18; line: 1, column: 3]"
}
],
"type": "json_e_o_f_exception",
"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@5c64fb18; line: 1, column: 1])\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@5c64fb18; line: 1, column: 3]"
},
"status": 500
}

答案:Sorry, yeah, that isn't a great error. The problem is that the json on one of your lines is invalid. _bulk first slices the json line by line and then parses it. It does this so the coordinating node doesn't have to parse the json for documents that it is just going to ship off to another node. So each line has to be a valid json document.

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×
标签:

给我留言