某日,在重建ES索引并且迁移数据时报错,反复重来还是会报相同的错误。
org.elasticsearch.client.ResponseException: method [POST], host [http://127.0.0.1:9200], URI [_aliases], status line [HTTP/1.1 403 Forbidden]
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}
原因是:es内存不足,导致只读。
解决办法是:
curl --request PUT \
--url http://127.0.0.1:9200/_settings \
--header 'content-type: application/json' \
--data '{"index":{"blocks":{"read_only_allow_delete":"false"}}}'
如果在别的地方想解决这样的问题,只需要更换url地址就行。