Tomcat启动很慢如何解决(亲测有效)
tomcat启动耗时67067ms折合67秒,刚刚安装的干净tomcat,显然不对劲。
有一条日志引起了我的注意:
11-Sep-2017 12:20:34.870 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [66,193] milliseconds.
显然tomcat执行到这里时出问题了,google了一下:"tomcat startup take long time SecureRandom",经过搜索,发现了一个解决方法
Slow startup on Tomcat 7.0.57 because of SecureRandom
问题缘由:当没有足够的entropy反馈给/dev/random时调用securerandom的时候可能引起阻塞。
解决方法:
vi /usr/java/jdk1.8.0_251-amd64/jre/lib/security/java.security
securerandom.source=file:/dev/./urandom
更新后重启tomcat