优化
性能测试
- 在一个节点的一个分片,不设置副本,测试性能
- 在完全默认设置上记录性能数据,作为测试的基准线
- 确保性能测试持续30分钟以上以确认长时间的性能;短时间的测试可能不会碰到segment合并和GC,无法确认这些因素的影响
- 每次基于默认基准线更改一个参数,如果性能有提升就保留设置,并基于此设置做后续的测试
生产环境elasticsearch的配置建议
以下主要来自官方文档,主要分为几块:
分片大小的建议 每个分片小于50GB
Elasticsearch集群搭建实战
大规模集群实践
PUT /_cluster/settings
{
"persistent" : {
"discovery.zen.minimum_master_nodes" : 8
}
}
gateway.expected_nodes: 15
gateway.recover_after_nodes: 12
gateway.recover_after_time: 5m
笔记
设置分片数
curl -X PUT -u {username}:{password} "{ip}:9200/{indexName}" -d '
{
"settings" : {
"number_of_shards" : {number}
}
}
'
task 观察任务运行状态
GET _tasks
GET _tasks?actions=*reindex&detailed
GET _tasks/uOCOZUwHQ-CWfbeizCDOOg:37931
POST _tasks/uOCOZUwHQ-CWfbeizCDOOg:37931/_cancel
别名alias
POST /_aliases
{
"actions": [
{
"add": {
"index": "probe_datecl2",
"alias": "probe_datecl4"
}
}
]
}
问答区
提高索引速度
限制reindex的速度,默认不限制
requests_per_second
can be set to any positive decimal number (
1.4
,
6
,
1000
, etc) and throttles rate at which reindex issues batches of index operations by padding each batch with a wait time. The throttling can be disabled by setting
requests_per_second
to
-1
.
https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html#reindex-from-remote
ElasticSearch 的一次非正常master脱离的调查
5.1.1存在经常节点失联的bug,导致集群状态不稳定(yellow),不停均衡,大量磁盘io以及cpu使用。影响入库以及查询效率。