内容简介:解决logstash启动过慢的问题
最近在搭elk时,发现logstash在服务器上要花费将近10分钟才能启动完成开始pipeline
而我用的机器是ucloud的2C4G,不太可能是服务器性能的瓶颈
查资料后发现和jruby的启动有关,于是找到了这个issue
https://github.com/elastic/logstash/issues/5507
提到了 jruby wiki 里的一段话
When JRuby boots up, the JDK libraries responsible for random number generation go to /dev/random for (at least) initial entropy. After this point, more recent versions of JRuby will use a PRNG for subsequent random numbers, but older versions will continue to return to /dev/random. Unfortunately /dev/random can “run out” of “good” random numbers, providing a guarantee that reads from it will not return until the entropy pool is restored. On some systems – especially virtualized – the entropy pool can be small enough that this slows down JRuby’s startup time or execution time significantly.
jruby启动的时候jdk回去从/dev/random中初始化随机数熵,新版本的jruby会用RPNG算法产生随后的随机数,但是旧版本的jruby会持续从/dev/random中获取数字。但是不幸的是,random发生器会跟不上生成速度,所以获取随机数的过程会被阻塞,直到随机数池拥有足够的熵然后恢复。这在某些系统上,尤其是虚拟化系统,熵数池可能会比较小从而会减慢jruby的启动速度。
检查了一下系统的熵数池 cat /proc/sys/kernel/random/entropy_avail
,发现只有65,正常情况这个数字推荐大于1000,对比了一下独立主机的这个数值,大约在700-900之间晃悠。
解决
最简单的解决方案是安装一个熵数发生器,比如 Haveged
,centos可从epel源中获取,安装后启动服务 sudo systemctl start haveged
就可以看到entropy_avail暴涨至2000多,logstash几乎是秒启,然后再 sudo systemctl enable haveged
设为开机自启。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 解决logstash启动过慢的问题
- Oracle 12.2监听无法启动解决方法
- SQL服务器无法启动的解决方法
- 苹果强制要求更换启动方式的解决方案
- 苹果强制要求更换启动方式的解决方案
- RAC中一节点无法启动解决步骤 荐
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Programming Collective Intelligence
Toby Segaran / O'Reilly Media / 2007-8-26 / USD 39.99
Want to tap the power behind search rankings, product recommendations, social bookmarking, and online matchmaking? This fascinating book demonstrates how you can build Web 2.0 applications to mine the......一起来看看 《Programming Collective Intelligence》 这本书的介绍吧!