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];
[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 即关闭磁盘分配保护
在这里插入图片描述
补充:

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

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值