ElasticSearch会根据当前Node的剩余空间决定是否再往这个Node分配Shard或者将这个Node的Shard迁移到其余Nodenode
能够在elasticsearch.yml
中或使用cluster-update-settings
API配置下面的参数json
cluster.routing.allocation.disk.threshold_enabled
是否启动根据磁盘空间自动分配,默认为true
elasticsearch
cluster.routing.allocation.disk.watermark.low
磁盘使用的最低水位线,默认为85%,到了这个值,ES不会再分配新的Shard到这个Node.也能够设置为一个绝对空间大小,如500mb,表示容许的最小的剩余空间.这个值对新建立的索引的primary shard无效,特别要注意的是,这个值对从未分配过的Shard也无效.code
cluster.routing.allocation.disk.watermark.high
磁盘高水位线,默认为90%,当使用率超过这个值,ES会把这个node上的shard转移到其余node.这个值也一样能够设置为一个绝对值,表示最大容许的剩余空间,这个这对全部shard生效,这里有别于前一个配置.索引
cluster.routing.allocation.disk.watermark.flood_stage
洪水水位线,默认为95%,当使用率达到这个值,ES会将对应的索引设为只读.这是最后一个保护措施.只读状态必须在有了足够空间后人工解除.it
注意: 你能够混合使用百分比和绝对值水位线,可是不建议这么用,由于你常常没法判断这些值是否产生冲突(好比,高水位线比洪水线还高).io
PUT /twitter/_settings { "index.blocks.read_only_allow_delete": null }
cluster.info.update.interval
ES检查磁盘使用率的频率,默认30sast
cluster.routing.allocation.disk.include_relocations
默认为true,计算磁盘使用量时,是否把当前正在分配的shard所占用空间考虑在内,若是不考虑这部分空间,就会把这些空间计算在内,磁盘使用会被高估,显而易见.class
注意: 使用百分比时表示使用空间,而使用绝对值时表示剩余空间,看起来比较使人困惑,可是也没有更好的办法.配置
更新低水位线到100GB剩余空间,高水位线设为50GB,洪水线设为10GB,1分钟更新一次状态.
PUT _cluster/settings { "transient": { "cluster.routing.allocation.disk.watermark.low": "100gb", "cluster.routing.allocation.disk.watermark.high": "50gb", "cluster.routing.allocation.disk.watermark.flood_stage": "10gb", "cluster.info.update.interval": "1m" } }