Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] milliseconds
来源:互联网 发布:java 生成二维码带log 编辑:程序博客网 时间:2024/06/04 18:48
通常情况下,tomcat启动只要2~3秒钟,突然有一天,tomcat启动非常慢,要花5~6分钟,查了很久,终于在这篇文章找到了解决方案,博主牛人啊。
原文参见:http://blog.csdn.net/chszs/article/details/49494701
Tomcat 8启动很慢,且日志上无任何错误,在日志中查看到如下信息:
Log4j:[2015-10-29 15:47:11] INFO ReadProperty:172 - Loading properties file from class path resource [resources/jdbc.properties]
Log4j:[2015-10-29 15:47:11] INFO ReadProperty:172 - Loading properties file from class path resource [resources/common.properties]
29-Oct-2015 15:52:53.587 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [342,445] milliseconds.
原因
Tomcat 7/8都使用org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom类产生安全随机类SecureRandom的实例作为会话ID,这里花去了342秒,也即接近6分钟。
SHA1PRNG算法是基于SHA-1算法实现且保密性较强的伪随机数生成器。
在SHA1PRNG中,有一个种子产生器,它根据配置执行各种操作。
1)如果Java.security.egd 属性或securerandom.source属性指定的是”file:/dev/random”或”file:/dev/urandom”,那么JVM 会使用本地种子产生器NativeSeedGenerator,它会调用super()方法,即调用 SeedGenerator.URLSeedGenerator(/dev/random)方法进行初始化。
2)如果java.security.egd属性或securerandom.source属性指定的是其它已存在的URL,那么会调用SeedGenerator.URLSeedGenerator(url)方法进行初始化。
这就是为什么我们设置值为”file:///dev/urandom”或者值为”file:/./dev/random”都会起作用的原因。
在这个实现中,产生器会评估熵池(entropy pool)中的噪声数量。随机数是从熵池中进行创建的。当读操作时,/dev/random设备会只返回熵池中噪声的随机字节。/dev/random非 常适合那些需要非常高质量随机性的场景,比如一次性的支付或生成密钥的场景。
当熵池为空时,来自/dev/random的读操作将被阻塞,直到熵池收集到足够的环境噪声数据。这么做的目的是成为一个密码安全的伪随机数发生器,熵池要有尽可能大的输出。对于生成高质量的加密密钥或者是需要长期保护的场景,一定要这么做。
那么什么是环境噪声?
随机数产生器会手机来自设备驱动器和其它源的环境噪声数据,并放入熵池中。产生器会评估熵池中的噪声数据的数量。当熵池为空时,这个噪声数据的收集是比较花时间的。这就意味着,Tomcat在生产环境中使用熵池时,会被阻塞较长的时间。
解决
有两种解决办法:
1)在Tomcat环境中解决
可以通过配置JRE使用非阻塞的Entropy Source。
在catalina.sh中加入这么一行:-Djava.security.egd=file:/dev/./urandom 即可。
加入后再启动Tomcat,整个启动耗时下降到Server startup in 2912 ms。
2)在JVM环境中解决
打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:
securerandom.source=file:/dev/urandom
替换成
securerandom.source=file:/dev/./urandom
作者:Lave Zhang
出处:http://www.cnblogs.com/lavezhang/
- Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] milliseconds
- tomcat启动慢, Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] mil
- tomcat 启动慢 Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] mil
- tomcat启动慢, Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] mil
- Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [184,726] millisec
- tomcat 启动慢 Creation of SecureRandom instance for session ID generation using [SHA1PRNG]
- Tomcat启动 Creation of SecureRandom instance for session ID
- Tomcat启动时Creation of SecureRandom instance for session ID很慢
- Tomcat启动缓慢 Creation of SecureRandom instance for ... 花费时间过长的解决方法
- tomcat启动太慢,耗时很长的问题 Creation of SecureRandom instance for ...
- secureRandom 实现 之 SHA1PRNG
- The operation order of instance creation
- Using Class of Secure Transport (COST) to Restrict Instance Registration in Oracle RAC (Doc ID 13408
- ArcGIS for Server:Error: Server Object instance creation failed
- oratop - Utility for Near Real-time Monitoring of Databases, RAC and Single Instance (Doc ID 1500864
- crash: xx.xx.xx failed to scene-create after 19.50s (launch took 0.50s of total time limit 20.00s)
- [C/C++] An instance of using EPoll
- How to Enable SQL_TRACE for Another Session or in MTS Using Oradebug(文档 ID 1058210.6)
- springboot事务管理
- Python爬虫利器之Beautiful Soup的用法
- velocity往word/excel模版填充数据并导出
- RxJava(十一)defer操作符实现代码支持链式调用
- JNI找不到类文件。
- Creation of SecureRandom instance for session ID generation using [SHA1PRNG]took [xx] milliseconds
- C#入门经典第6版学习 十二
- Java-垃圾回收机制
- 状态机的VHDL设计
- 从分布式一致性谈到CAP理论、BASE理论
- 02-VTK编译安装
- 如何更新百宝云应用中心已发布的应用?
- 大数据初步调研
- 单例模式