一、內存優化
在bin/elasticsearch.in.sh中進行配置
修改配置項爲儘可能大的內存:
ES_MIN_MEM=8g
ES_MAX_MEM=8g
二者最好改爲同樣的,不然容易引起長時間GC(stop-the-world)html
elasticsearch默認使用的GC是CMS GC
若是你的內存大小超過6G,CMS是不給力的,容易出現stop-the-world
建議使用G1 GC
註釋掉:
JAVA_OPTS=」$JAVA_OPTS -XX:+UseParNewGC」
JAVA_OPTS=」$JAVA_OPTS -XX:+UseConcMarkSweepGC」java
JAVA_OPTS=」$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75″
JAVA_OPTS=」$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly」
修改成:
JAVA_OPTS=」$JAVA_OPTS -XX:+UseG1GC」
JAVA_OPTS=」$JAVA_OPTS -XX:MaxGCPauseMillis=200″node
若是G1 GC優勢是減小stop-the-world在概率,可是CPU佔有率高。
須要更優化的性能,你能夠參考
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.htmlweb
二、合理配置主節點和數據節點
配置文件:conf/elasticsearch.yaml
node.master: true
node.data: trueoracle
1) 當master爲false,而data爲true時,會對該節點產生嚴重負荷;
2) 當master爲true,而data爲false時,該節點做爲一個協調者;
3) 當master爲false,data也爲false時,該節點就變成了一個負載均衡器。負載均衡
三、設置合理的刷新時間
創建的索引,不會立馬查到,這是爲何elasticsearch爲near-real-time的緣由
須要配置index.refresh_interval參數,默認是1s。
你能夠像
http://zhaoyanblog.com/archives/299.html
文件中同樣,調用接口配置
也能夠直接寫到conf/elasticsearch.yaml文件中
index.refresh_interval:1s
這樣全部新建的索引都使用這個刷新頻率。elasticsearch