码迷,mamicode.com
首页 > 移动开发 > 详细

Tomcat 启动卡在 Root WebApplicationContext: initialization completed in

时间:2019-09-11 09:51:06      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:排除   lib   生成   需要   开始   blog   ica   dom   etc   

tomcat 启动一直卡在

Root WebApplicationContext: initialization completed in

重启了很多次,更换jdk版本,tomcat版本都不行。

tomcat所在的JVM进程已经被启动了所以可以排除是JVM退出引起的问题。那么问题真的就是JVM因为某种原因被阻塞了。

https://blog.csdn.net/wwdwjm/article/details/77840113

主要是因为阿里云的熵池太小 熵池的大小是根据键盘 鼠标之类的噪音产生的数 然后/dev/random会根据熵池来生成随机数 而生成需要有足够的熵池里的噪音数 如果没有达到的话就会一直阻塞 tomcat启动的时候为了生成session id就会获取这个随机数来生成密匙 所以才出现上面的情况 一直阻塞在等待熵池里的数满足生成随机数的大小 3分钟以后熵池里的数够大了才开始部署

yum install -y rng-tools
systemctl start rngd
cp /usr/lib/systemd/system/rngd.service /etc/systemd/system
vi /etc/systemd/system/rngd.service

ExecStart=/sbin/rngd -f -r /dev/urandom

WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [348,853] milliseconds

后来查了一下,发现这个问题抱怨的还是蛮多的,以至于tomcat的wiki里面还单独列出来作为加速启动的一个方面:

Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy. You will see warning in the logs when this happens, e.g.:

There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom

尝试使用-Djava.security.egd=file:/dev/./urandom启动了一下,果然快了很多

https://wiki.apache.org/tomcat/HowTo/FasterStartUp

Tomcat 启动卡在 Root WebApplicationContext: initialization completed in

标签:排除   lib   生成   需要   开始   blog   ica   dom   etc   

原文地址:https://www.cnblogs.com/fsckzy/p/11504322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!