問題出現:
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解除索引只讀限制