Elasticsearch主要配置及性能调优
1、最小主节点数防止集群发生脑裂,计算方式:( master 候选节点个数 / 2) + 1
http://i2.运维网.com/images/blog/201805/04/e9dbc8a86a60e3280b48fcf2921ede76.png
可以通过修改配置文件elasticsearch.yml
discovery.zen.minimum_master_nodes: 2
或者通过api接口动态修改
curl -XPUT 'http://127.0.0.1:9200/_cluster/settings' -d '
{
"persistent" : {
"discovery.zen.minimum_master_nodes" : 2
}
}'
2、集群恢复配置
gateway.recover_after_nodes: 8##Elasticsearch 在存在至少 8 个节点(数据节点或者 master 节点)才进行数据恢复
gateway.expected_nodes: 10 ##集群有多少个节点
gateway.recover_after_time: 5m##等待节点多长时间
上面三个参数意味着
等待集群至少存在 8 个节点
等待 5 分钟,或者10 个节点上线后,才进行数据恢复,这取决于哪个条件先达到。
3、最好使用单播
discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]
4、堆内存:大小和交换
根据《Elasticsearch官网》所说分配机器的的一半内存给Lucene,并且不要超过32GB给Elasticsearch;并且避免Elasticsearch使用Swap空间
http://i2.运维网.com/images/blog/201805/04/2ccf58d3ba941288c19cc21204c8fdb8.png
http://i2.运维网.com/images/blog/201805/04/da60096e230f0a7524c839c48e8b1e94.png
http://i2.运维网.com/images/blog/201805/04/97963e8593fe2bfd58705ce0899c7544.png
5、线程池
非必要尽量避免修改线程池,实在需要修改尽量避免超过CPU核心数2倍,官网原文如下:
http://i2.运维网.com/images/blog/201805/04/303c2db8b3b973a7191bcc3e5265bbfc.png
参考资料:
1、https://www.elastic.co/blog/a-heap-of-trouble
2、https://www.elastic.co/guide/cn/elasticsearch/guide/current/important-configuration-changes.html
3、https://elasticsearch.cn/question/3995
页:
[1]