某次在做ES导入数据的时候发现报错
{
"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新节点的数据目录data存储空间不足,导致从master主节点接收同步数据的时候失败,此时ES集群为了保护数据,会自动把索引分片index置为只读read-only「cluster_block_exception」
查看mappings可以看到:"read_only_allow_delete" : "ture"
{
"settings" : {
"index" : {
"refresh_interval" : "1s",
"number_of_shards" : "5",
"blocks" : {
"read_only_allow_delete" : "ture"
},
"provided_name" : "index_name",
"creation_date" : "1561280427271",
"analysis" : {
"analyzer" : {
"comma" : {
"pattern" : ",",
"type" : "pattern"
}
}
},
"number_of_replicas" : "1",
"uuid" : "xxxxxxxxxxxxxxx",
"version" : {
"created" : "6050399"
}
}
}
}
解决方法:
- 1 磁盘扩容,可在配置文件中修改ES数据存储目录,重启ES
- 2 放开索引只读设置,在服务器上通过curl工具发起PUT请求
法一:
扩容后即可~
法二:
PUT _settings
{
"index": {
"blocks": {
"read_only_allow_delete": "false"
}
}
}