tomcat createSecureRandom 花费了将近10分钟

http://www.th7.cn/Program/java/201603/776312.shtml

启动tomcat很慢,检查后发现:[localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [131,830] milliseconds。主要时间都花在Creation of SecureRandom instance上了。
百度谷歌了一番。。解决办法:打开$JAVA_HOME/jre/lib/security/java.security这个文件,找到下面的内容:        securerandom.source=file:/dev/urandom

    替换成    

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

    然而并没有什么卵用。。
    检查后发现linux下的的java -version和javac -version的版本不一致,可能是这个原因。。    修复了版本不一致的问题,问题依旧。。         最后仔细检查了下,发现$JAVA_HOME/jre/lib/security/java.security中用的是file:/dev/./random!前面少了个u!!所以上面的解决办法没生效就很正常了,改成file:/dev/urandom后,重启tomcat,sucess!
详见:http://security.stackexchange.com/questions/89/feeding-dev-random-entropy-pool
参考:    http://blog.csdn.net/chszs/article/details/49494701    http://stackoverflow.com/questions/26431922/tomcat7-starts-too-late-on-ubuntu-14-04-x64-digitalocean

posted @ 2017-02-15 15:01  hurner  Views(1374)  Comments(0Edit  收藏  举报