org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not

文章目录

    • 一. 搭建集群时出现错误
      • 错误日志elasticsearch.log
        • org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not recovered / initialized];
      • 原因:
      • 解决方案:

一. 搭建集群时出现错误

错误日志elasticsearch.log

org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not recovered / initialized];

[2021-12-04T11:21:36,848][INFO ][o.e.n.Node               ] [x1KT3lU] started
[2021-12-04T11:21:37,465][WARN ][r.suppressed             ] path: /.reporting-*/esqueue/_search, params: {index=.reporting-*, type=esqueue, version=true}
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];
	at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException(ClusterBlocks.java:166) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedRaiseException(ClusterBlocks.java:152) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.action.search.TransportSearchAction.executeSearch(TransportSearchAction.java:286) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.action.search.TransportSearchAction.lambda$doExecute$4(TransportSearchAction.java:193) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:60) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:113) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.index.query.Rewriteable.rewriteAndFetch(Rewriteable.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
	

原因:

由于磁盘空间不足,导致Elasticsearch触发磁盘保护,强制将所有索引设置成了只读状态,相关参数见官方文档:Disk-based Shard Allocation。

主要相关参数如下:

  • cluster.routing.allocation.disk.threshold_enabled:是否启动根据磁盘空间自动分配,默认为true
  • cluster.routing.allocation.disk.watermark.low:控制磁盘使用率的低水位,默认是85%,当一个节点的磁盘空间使用率超过85%,就不会给该节点分配新的shard
  • cluster.routing.allocation.disk.watermark.high:控制磁盘使用率的高水位,默认是90%,当一个节点的磁盘空间使用率超过90%,就会将该节点的部分shard转移到其他节点上
  • cluster.routing.allocation.disk.watermark.flood_stage:洪水水位线,默认为95%,当一个节点的磁盘空间使用率超过95%,就会把所有索引设为只读。这是最后一个保护措施,索引的只读状态必须通过人工手动解除
  • cluster.info.update.interval:检查磁盘使用率的频率,默认30s

解决方案:

在elasticsearch.yml中添加cluster.routing.allocation.disk.threshold_enabled:false 即关闭磁盘分配保护
org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not_第1张图片
补充:

path.data: /opt/elasticsearch/data # 数据目录位置
path.logs: /opt/elasticsearch/logs # 日志目录位置
network.host: 0.0.0.0 # 此行前面带一个空格 绑定到0.0.0.0,允许任何ip来访问

你可能感兴趣的:(错误,elasticsearch,搜索引擎,big,data)