在调查Ubuntu 15上我的tomcat 8服务器在启动时没有响应的原因时,事实证明它花费了大量时间来创建SecureRandom实例。为什么会这样,以及如何解决?
May 19, 2016 2:48:22 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
May 19, 2016 3:21:37 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
!!! ----> INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,994,925] milliseconds.
May 19, 2016 3:21:37 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /var/lib/tomcat8/webapps/ROOT has finished in 1,995,782 ms
May 19, 2016 3:21:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
May 19, 2016 3:21:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1995884 ms
答案 0 :(得分:1)
根据Javadoc
根据实施情况,{@code generateSeed}和 {@code nextBytes}方法可能会在收集熵时阻塞, 例如,如果他们需要在各种Unix上读取/ dev / random 操作系统。
你能检查/ dev / random是不是很慢,可能是secureRandom正在使用NativePRNG(/ dev / random)吗?
有关原因/ dev / random的详细信息,请参阅/dev/random Extremely Slow?