本文是在以下 6 篇基础上的继续扩展版本,不求大而全,只求对实战有帮助。
1、干货 | Elasticsearch 运维实战常用命令清单
2、干货 | Elasticsearch Top10 监控指标
3、你不得不关注的 Elasticsearch Top X 关键指标
4、干货 | Elasticsearch 开发实战常用命令清单
5、干货 | Elasticsearch开发人员最佳实战指南
1、未分配分片查看
GET _cat/shards?v&h=index,shard,prirep,state,unassigned.reason&s=state:asc
复制
2、动态调整副本数
PUT my-index-2021.05.30-000002/_settings{"number_of_replicas": 0}
复制
ps:主分片不可以修改(除非shrink),但:副本可以动态调整大小。
3、重新打开分片分配策略
PUT /_cluster/settings{ "transient": { "cluster.routing.allocation.enable": "all" }}
复制
4、手动移动未分配的分片
POST /_cluster/reroute{ "commands": [ { "move": { "index": "test", "shard": 0, "from_node": "node1", "to_node": "node2" } }, { "allocate_replica": { "index": "test", "shard": 1, "node": "node3" } } ]}
复制
5、查看磁盘使用率
GET /_cat/allocation?v
复制
使用率大于等于85%,知道已经达到警戒水位线了,要预警。
6、查看各个节点的版本号
GET /_cat/nodes?v&h=host,name,version
复制
集群多节点版本不一致,可能会引发各种未知异常。
7、检索性能调优实战
7.1 慢日志设置
PUT /my-index-000001/_settings{ "index.search.slowlog.threshold.query.warn": "10s", "index.search.slowlog.threshold.query.info": "5s", "index.search.slowlog.threshold.query.debug": "2s", "index.search.slowlog.threshold.query.trace": "500ms", "index.search.slowlog.threshold.fetch.warn": "1s", "index.search.slowlog.threshold.fetch.info": "800ms", "index.search.slowlog.threshold.fetch.debug": "500ms", "index.search.slowlog.threshold.fetch.trace": "200ms", "index.search.slowlog.level": "info"}
复制
7.2 构建Mapping 设置路由
PUT my-index-000002{ "mappings": { "_routing": { "required": true } }}
复制
7.3 段合并
POST /my-index-000001/_forcemerge
复制
8、写入优化篇
8.1 批量写入
POST _bulk{ "index" : { "_index" : "test", "_id" : "1" } }{ "field1" : "value1" }{ "delete" : { "_index" : "test", "_id" : "2" } }{ "create" : { "_index" : "test", "_id" : "3" } }{ "field1" : "value3" }{ "update" : {"_id" : "1", "_index" : "test"} }{ "doc" : {"field2" : "value2"} }
复制
8.2 增加刷新频率
PUT /my-index-000001/_settings{ "index" : { "refresh_interval" : "30s" }}
复制
8.3 副本设置为0,提升写入
PUT my-index-000001/_settings{ "number_of_replicas": 0}
复制
8.4 translog 异步刷盘
PUT my-index-2021.06.03/_settings{ "index": { "translog": { "durability": "async" } }}
复制
9、堆内存调优实战
在 jvm.option 配置文件中(不支持动态调整,需要重启后生效)
ES_HEAP_SIZE=DESIRED_SIZE (e.g. "3g")
复制
10、磁盘不足解决方案
磁盘的三个警戒水位线需要再一次强调。如果 Elasticsearch 集群节点的磁盘空间不足,则会影响集群性能。
一旦可用存储空间低于特定阈值限制,它将开始阻止写入操作,进而影响数据进入集群。那么,如何扩展呢?
三个警戒水位线推荐阅读:你不得不关注的 Elasticsearch Top X 关键指标。
小结

Elasticsearch性能优化实战指南 让Elasticsearch飞起来!——性能优化实践干货 Elasticsearch大文件检索性能提升20倍实践(干货) Elasticsearch 聚合性能优化六大猛招 Elasticsearch 高基数聚合性能提升3倍,改动了什么?
参考
elasticsearch_monitoring_cheatsheet.pdf
https://www.elastic.co/guide/en/elasticsearch/reference/7.14/modules-cluster.html#disk-based-shard-allocation
https://www.elastic.co/guide/en/elasticsearch/reference/7.14/how-to.html
推荐


文章转载自铭毅天下Elasticsearch,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
数据库国产化替代深化:DBA的机遇与挑战
代晓磊
1338次阅读
2025-04-27 16:53:22
2025年4月国产数据库中标情况一览:4个千万元级项目,GaussDB与OceanBase大放异彩!
通讯员
824次阅读
2025-04-30 15:24:06
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
545次阅读
2025-04-17 17:02:24
一页概览:Oracle GoldenGate
甲骨文云技术
512次阅读
2025-04-30 12:17:56
GoldenDB数据库v7.2焕新发布,助力全行业数据库平滑替代
GoldenDB分布式数据库
486次阅读
2025-04-30 12:17:50
阿里云 Elasticsearch Serverless 检索增强型 8.17 版来袭!
阿里云大数据AI技术
381次阅读
2025-04-18 10:24:15
优炫数据库成功入围新疆维吾尔自治区行政事业单位数据库2025年框架协议采购!
优炫软件
370次阅读
2025-04-18 10:01:22
给准备学习国产数据库的朋友几点建议
白鳝的洞穴
364次阅读
2025-05-07 10:06:14
XCOPS广州站:从开源自研之争到AI驱动的下一代数据库架构探索
韩锋频道
320次阅读
2025-04-29 10:35:54
MySQL 30 周年庆!MySQL 8.4 认证免费考!这次是认真的。。。
数据库运维之道
309次阅读
2025-04-28 11:01:25