最近在部署項(xiàng)目啟動(dòng)tomcat的時(shí)候,發(fā)現(xiàn)啟動(dòng)超慢,啟動(dòng)一次要4-5分鐘。在查看tomcat的日志的時(shí)候看到:WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [152,858] milliseconds。這個(gè)就是罪魁禍?zhǔn)琢恕?/p>
于是就在網(wǎng)上百度解決方案,
在你的 JRE 中,在 lib/security 下編輯 java.security。
把securerandom.source=file:/dev/random
改成
securerandom.source=file:/dev/./urandom
這樣倒是把問題解決了,但是還是其所以然。
查看java.security 文件,看到有這么的注釋:

image.png
我就去網(wǎng)上搜 file:/dev/random 和file:/dev/urandom,還真的搜到了。這里貼上該作者的地址: http://blog.csdn.net/ohmygirl/article/details/40385083
我在本地使用 cat /dev/random | od -x ,卡住了,半天都沒有數(shù)據(jù)出來。

image.png
換成 cat /dev/urandom | od -x ,刷刷出來很多數(shù)據(jù),秒殺啊。cat /dev/./urandom | od -x 也是很快。