ES解除索引只读限制

问题出现:

ES集群中一台机器硬盘损坏,换上新的硬盘后,数据分片同步,Spark入ES的程序启动失败,ES是3副本存储的

Spark:2.2.0-cdh5.12.0

ES:6.3.2

错误日志:

 INFO scheduler.TaskSetManager: Lost task 8.1 in stage 1.0 (TID 26) on bigdata-247, executor 3: org.elasticsearch.hadoop.EsHadoopException (Could not write all entries for bulk operation [1000/1000]. Error sample (first [5] error messages):
blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];
Bailing out...) [duplicate 9]

原因:

只是由于数据同步后,ES集群为了保护数据,会自动把索引分片index置为只读read-only

解决办法:

curl -XPUT -H "Content-Type: application/json" http://ip:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
返回:
{"acknowledged":true}

其中 _all 这个可以更改为自己在创建 Eleastisearch 索引的时候的name,用来修改单个索引只读状态,当然用 _all 也可以, _all 是修改了所有的索引只读状态ES解除索引只读限制

posted @ 2019-11-21 17:42  小跑、追幸福  阅读(2675)  评论(0编辑  收藏  举报