美文网首页
Linux 服务器部署 Tomcat 启动异常缓慢

Linux 服务器部署 Tomcat 启动异常缓慢

作者: leeehao | 来源:发表于2018-09-29 12:51 被阅读0次

Tomcat 7/8都使用 ```org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom``` 类产生安全随机类 ```SecureRandom```的实例作为会话ID,这里花去了342秒,也即接近6分钟。

有两种解决办法:

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```

相关文章

网友评论

      本文标题:Linux 服务器部署 Tomcat 启动异常缓慢

      本文链接:https://www.haomeiwen.com/subject/tlxlbttx.html