WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [66,815] milliseconds. tomcat启动耗时67067ms折合67秒,刚刚安装的干净tomcat,显然不对劲。 有一条日志引起了我的注意:

WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [66,815] milliseconds.

显然tomcat执行到这里时出问题了,google了一下:"tomcat startup take long time SecureRandom",经过搜索,发现了一个解决方法 Slow startup on Tomcat 7.0.57 because of SecureRandom
问题缘由:当没有足够的entropy反馈给/dev/random时调用securerandom的时候可能引起阻塞。
解决方法1: 修改 /opt/jdk1.8/jre/jre/lib/security/java.security

securerandom.source=file:/dev/random

改成

securerandom.source=file:/dev/./urandom

解决方法2:安装haveged(以ubuntu为例)

apt-get install haveged
#编辑配置文件,输入下面一行
vim /etc/default/haveged 
DAEMON_ARGS="-w 1024"
#刷新配置
update-rc.d haveged defaults

ubuntu顺利解决,其他linux请参照How to Setup Additional Entropy for Cloud Servers Using Haveged