如何撤消将Elasticsearch Index设置为只读?

时间:2016-01-20 21:43:04

标签: elasticsearch

所以我只将其中一个索引设置为readonly,现在想删除它。

将其设置为只读:

PUT my_index/_settings
{ "index": { "index.blocks.read_only" : true } }

当我试图删除它时,我得到了这个回复:

ClusterBlockException[blocked by: [FORBIDDEN/5/index read-only (api)];]

然后我尝试将索引设置为readonly false:

PUT my_index/_settings
{ "index": { "index.blocks.read_only" : false } }

但是它提供了与上面相同的错误消息。那么如何将readonly设置回false?

5 个答案:

答案 0 :(得分:22)

答案真的很老,所以我也要添加一个弹性6答案:

PUT /[_all|<index-name>]/_settings
{
  "index.blocks.read_only_allow_delete": null
}

https://www.elastic.co/guide/en/elasticsearch/reference/6.x/disk-allocator.html

FYI(针对上下文):由于磁盘空间不足,我遇到了只读索引,并且从logstash收到了错误消息:

...retrying failed action with response code: 403 ({"type"=>"cluster_block_exception", "reason"=>"blocked"

elasticsearch:
ClusterBlockException[blocked by: [FORBIDDEN/12/index read-only / allow delete(api)];]

答案 1 :(得分:20)

# kubectl describe po Name: k8s-master-dpcdd3 Namespace: default Image(s): gcr.io/google_containers/hyperkube:v1.1.3,gcr.io/google_containers/hyperkube:v1.1.3,gcr.io/google_containers/hyperkube:v1.1.3 Node: dpcdd3/ Labels: <none> Status: Pending Reason: Message: IP: Controllers: <none> Containers: controller-manager: Container ID: Image: gcr.io/google_containers/hyperkube:v1.1.3 Image ID: Command: /hyperkube controller-manager --master=127.0.0.1:8080 --v=2 QoS Tier: cpu: BestEffort memory: BestEffort State: Waiting Ready: False Restart Count: 0 Environment Variables: apiserver: Container ID: Image: gcr.io/google_containers/hyperkube:v1.1.3 Image ID: Command: /hyperkube apiserver --portal-net=10.0.0.1/24 --address=0.0.0.0 --etcd-servers=http://127.0.0.1:4001 --cluster-name=kubernetes --v=2 QoS Tier: cpu: BestEffort memory: BestEffort State: Waiting Ready: False Restart Count: 0 Environment Variables: scheduler: Container ID: Image: gcr.io/google_containers/hyperkube:v1.1.3 Image ID: Command: /hyperkube scheduler --master=127.0.0.1:8080 --v=2 QoS Tier: cpu: BestEffort memory: BestEffort State: Waiting Ready: False Restart Count: 0 Environment Variables: No volumes. No events. 设为只读的正确方法是

es index

PUT your_index/_settings { "index": { "blocks.read_only": true } } 更改为true以撤消它。

使用

设置非动态设置
false

我认为这不是你的意图。另外我认为你应该在第一次操作时看到错误,因为非动态设置只能在 { "index": { "index.blocks.read_only": false } } 上更新。

运行

close indices

然后尝试更改它。

答案 2 :(得分:3)

在ElasticSearch(ES)的2.x版中,您必须执行以下操作

PUT your_index/_settings

{
  "index": {
    "blocks": {
      "write": "false",
      "read_only": "false"
    }
  }
}

在内部将索引设置为read_only时,ES会将write更改为true,并且仅将read_only还原为false仍然不允许您更新索引以便您拥有明确更新write设置。

答案 3 :(得分:0)

如果安装了Kibana,则可以转到您的kibana网址:

Management (Left pane) -> Elasticseach Index Management -> Select your Index -> Edit Settings

然后更新:

"index.blocks.read_only_allow_delete": "false"

此外,要在kibana上进行全局设置,您可以转到开发工具(左窗格)并发出以下请求:

PUT _settings
{
  "index": {
    "blocks": {
      "read_only_allow_delete": "false"
    }
  }
}

答案 4 :(得分:0)

curl -X PUT "localhost:9200/_all/_settings" -H 'Content-Type: application/json' -d'{ "index.blocks.read_only" : false } }'