es2.4.5---调优
es的elasticsearch.in.sh 下初始内存配置:
ES_MIN_MEM=256m
ES_MAX_MEM=1g
1.内存优化:
在/www/server/es/bin/elasticsearch.in.sh 下
修改内存为总内存的一般并两者最好改成一样的,否则容易引发长时间GC (根据服务器内存设置)
ES_MIN_MEM=8g
ES_MAX_MEM=8g
elasticsearch默认使用的GC是CMS GC, 如果你的内存大小超过6G,CMS是不给力的,容易出现stop-the-world,建议使用G1 GC
注释掉:
ES_GC_OPTS="$ES_GC_OPTS -XX:+UseParNewGC"
ES_GC_OPTS="$ES_GC_OPTS -XX:+UseConcMarkSweepGC"
ES_GC_OPTS="$ES_GC_OPTS -XX:CMSInitiatingOccupancyFraction=75"
ES_GC_OPTS="$ES_GC_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
修改为:
ES_GC_OPTS="$ES_GC_OPTS -XX:+UseG1GC"
ES_GC_OPTS="$ES_GC_OPTS -XX:MaxGCPauseMillis=200"
如果G1 GC优点是减少stop-the-world在几率,但是CPU占有率高
2、合理配置主节点和数据节点
配置文件:conf/elasticsearch.yaml
node.master: true
node.data: true
1) 当master为false,而data为true时,会对该节点产生严重负荷;
2) 当master为true,而data为false时,该节点作为一个协调者;
3) 当master为false,data也为false时,该节点就变成了一个负载均衡器。
3、设置合理的刷新时间
建立的索引,不会立马查到,这是为什么elasticsearch为near-real-time的原因
需要配置index.refresh_interval参数,默认是1s。
index.refresh_interval:1s
这样所有新建的索引都使用这个刷新频率。
4.修改最大文件打开数, /etc/security/limits.conf,末尾添加
* soft nofile 65536
* hard nofile 65536

浙公网安备 33010602011771号