剛部署好程序,第一次登錄時,加載非常得慢,查看log日志發現:Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [33,755] milliseconds. 說什么創建用於會話ID生成的SecureRandom實例花費了[33,755]毫秒。
解決辦法:打開$JAVA_PATH/jre/lib/security/java.security這個文件,找到下面的內容:
securerandom.source=file:/dev/urandom 替換成 securerandom.source=file:/dev/./urandom
原因(網上說的):
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: