ES03--性能调优02(文件数、内存、root静默启动)

一、“Too many open files”

方式1:

发现日志中大量出现这个错误

执行

curl http:// 

localhost:9200

/_nodes/process\?pretty

可以看到

"max_file_descriptors" : 4096,

官方文档中

Make sure to increase the number of open files descriptors on the machine (or for the user running elasticsearch). Setting it to 32k or even 64k is recommended.

而此时, 可以在系统级做修改, 然后全局生效

最简单的做法, 在bin/elasticsearch文件开始的位置加入

ulimit -n 64000

然后重启es, 再次查询看到

"max_file_descriptors" : 64000

方式2:

vi /etc/security/limits.conf 添加下面两行

soft nofile 65536

hard nofile 131072


二、Elasticsearch JVM 内存配置大小

修改bin/elasticsearch.in.sh中ES_MIN_MEM和ES_MAX_MEM的大小,建议设置一样大,避免频繁的分配内存,根据服务器内存大小,一般分配60%左右(默认256M) 注意:内存最大不要超过32G

  一旦你越过这个神奇的32 GB边界,指针会切换回普通对象指针.。每个指针的大小增加,使用更多的CPU内存带宽。事实上,你使用40~50G的内存和使用32G的内存效果是一样的。


三、分片多的话,通过提升建立索引的能力,5~20

如果分片数过少或过多,都会导致检索比较慢。分片数过多会导致检索时打开比较多的文件,另外也会导致多台服务器之间通讯,而分片数过少会导至单个分片索引过大,所以检索速度也会慢。建议单个分片最多存储20G左右的索引数据,所以,分片数量=数据总量/20G。

四、root启动elasticsearch

bin/elasticsearch -Des.insecure.allow.root=true -d //默认以root账号启动
或者修改/bin/elasticsearch文件,修改如下语句:
exec"$JAVA"$JAVA_OPTS$ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" \
修改为:
exec"$JAVA"$JAVA_OPTS$ES_JAVA_OPTS -Des.path.home="$ES_HOME" -Des.insecure.allow.root=true -cp "$ES_CLASSPATH" \

参考博客:https://www.cnblogs.com/zlslch/p/6478773.html

猜你喜欢

转载自blog.csdn.net/envinfo2012/article/details/80627943