生产环境ES集群扩容及优化

本文档提供了Elasticsearch集群的优化步骤,包括停止服务、调整JVM内存设置、重启集群、配置副本数量及恢复并发和速度限制。建议最大内存不超过30GB,重启前关闭重新分片配置,重启后恢复原设置。此外,提供了多种用于监控集群状态的HTTP API。
摘要由CSDN通过智能技术生成

ES集群优化

具体详情请看官方文档建议:https://www.elastic.co/guide/en/elasticsearch/reference/7.5/restart-cluster.html

1.先把elasticsearch的服务停掉
systemctl stop elasticsearch
kill -9 进程号
2.修改jvm.options配置文件下最大、最小内存限制
-Xms26g
-Xmx26g

官方文档建议是不要超过32g,最好保持在30g以内,26g最优
3.重启elasticsearch
建议是全部停了之后,一起启动集群
systemctl start elasticsearch

#注意 重启之前要先把重新分片的配置关掉,以免数据量太大,导致重启时,集群重新分片,等候时间长短不确定(有可能等个好几天)
4.配置
# 调整副本数量
curl -X PUT "localhost:9200/xxx" -H 'Content-Type: application/json' -d' 
{
    "number_of_replicas": 0
}'

# 调整分配并发,默认2
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d' 
{
    "persistent" : {
        "indices.recovery.max_concurrent_file_chunks": 10
    }
}'

# 调整分配速度限制, 默认40mb
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d' 
{
    "persistent" : {
        "indices.recovery.max_bytes_per_sec" : "2048mb"
    }
}'

#注意 集群起来后,要把配置还原
5.可供使用的查询地址
# 查看集群信息
http://localhost:9200/_cat/health?v

# 查看恢复进度
http://localhost:9200/_cat/recovery

#查看分片信息
http://localhost:9200/_cat/shards?v

#查看节点资源情况
http://localhost:9200/_cat/nodes?v&h=host,heap.current,heap.percent,heap.max,ram.max,disk.avail,node.role

#查看索引信息
http://localhost:9200/_cat/indices?v

#查看集群动态配置
http://localhost:9200/_cluster/settings?pretty

#查看副本数量
http://localhost:9200/_cat/indices?v

ES优化

  "index.refresh_interval": "60s",
  "index.translog.flush_threshold_size": "500mb",
  "index.translog.durability": "async",
  "index.merge.scheduler.max_thread_count": "1",
  "index.merge.policy.max_merge_at_once": "10",
  "index.merge.policy.max_merged_segment": "10gb",
  "index.merge.policy.segments_per_tier": "50",
  "index.merge.policy.floor_segment": "50mb",
  "index.number_of_replicas": "0"
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值