ES 集群磁盘容量使用修改

官方文档

cluster.routing.allocation.disk.threshold_enabled
默认开启,关闭之后,磁盘使用没有限制

cluster.routing.allocation.disk.watermark.low
集群默认值为15%,就不在该磁盘上新建shard了,但是由于线上磁盘比较大,导致15%还剩余很多容量,一般修改为bytes value ,如100g

cluster.routing.allocation.disk.watermark.high
默认90%,超过之后,不会移动分片到这台机器上,修改为50g

cluster.routing.allocation.disk.watermark.flood_stage
默认95%,超过之后,整个索引修改为只读,修改为10g

在kibana中执行

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"
  }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
使用Elasticsearch的Java API连接Elasticsearch集群,需要添加以下三个依赖:org.elasticsearch.client.elasticsearch-rest-high-level-client、org.elasticsearch.client:elasticsearch-rest-client、org.elasticsearch:elasticsearch。这些依赖可以通过Maven或Gradle添加到项目中。接下来,可以使用Elasticsearch的Java API编写代码来连接Elasticsearch集群。具体步骤如下: 1. 创建RestHighLevelClient对象,该对象是与Elasticsearch集群进行通信的主要入口点。 2. 创建IndexRequest对象,该对象表示要索引的文档。 3. 使用IndexRequest对象设置索引名称、文档类型和文档ID等信息。 4. 使用IndexRequest对象设置要索引的文档内容。 5. 使用RestHighLevelClient对象执行IndexRequest对象,将文档索引到Elasticsearch集群中。 下面是一个示例代码,用于将文档索引到Elasticsearch集群中: ```java import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.rest.RestStatus; import java.io.IOException; public class ElasticsearchExample { private RestHighLevelClient client; public ElasticsearchExample(RestHighLevelClient client) { this.client = client; } public void indexDocument(String index, String type, String id, String json) throws IOException { IndexRequest request = new IndexRequest(index, type, id); request.source(json, XContentType.JSON); IndexResponse response = client.index(request, RequestOptions.DEFAULT); if (response.status() == RestStatus.CREATED) { System.out.println("Document indexed successfully"); } else { System.out.println("Failed to index document"); } } public static void main(String[] args) throws IOException { RestHighLevelClient client = new RestHighLevelClient(/* Elasticsearch连接配置 */); ElasticsearchExample example = new ElasticsearchExample(client); example.indexDocument("my_index", "my_type", "1", "{\"name\":\"John Doe\",\"age\":25}"); client.close(); } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值