linux下或者cenos7下tomcat不能启动或者启动巨TM慢

[INFO ] 2018-04-09 18:35:44,946 method:org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:285)
Root WebApplicationContext: initialization started
[INFO ] 2018-04-09 18:35:45,010 method:org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:510)
Refreshing Root WebApplicationContext: startup date [Mon Apr 09 18:35:45 CST 2018]; root of context hierarchy
[INFO ] 2018-04-09 18:35:45,046 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-trans.xml]
[INFO ] 2018-04-09 18:35:45,174 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-dao.xml]
[INFO ] 2018-04-09 18:35:45,211 method:org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317)
Loading XML bean definitions from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/spring/applicationContext-service.xml]
[INFO ] 2018-04-09 18:35:45,373 method:org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Loading properties file from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/resources/db.properties]
[INFO ] 2018-04-09 18:35:45,374 method:org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Loading properties file from file [/usr/java/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/classes/resources/resource.properties]
[INFO ] 2018-04-09 18:35:45,967 method:org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
Root WebApplicationContext: initialization completed in 1019 ms

我的tomcat7到这里就不动了,找了大量资料还是没有解决。过了大半天忽然发现tomcat启动起来了。

就改变了搜索策略,tomcat启动慢怎么办

查阅大量资料发现是由于tomcat启动时产生随机数导致jvm阻塞,可能是我多次重启tomcat导致熵池被用空造成阻塞。。

在apache-tomcat官方文档:如何让tomcat启动更快里面提到了一些启动时的优化项,其中一项是关于随机数生成时,采用的“熵源”(entropy source)的策略。他提到tomcat7的session id的生成主要通过java.security.SecureRandom生成随机数来实现,随机数算法使用的是”SHA1PRNG”

有两种解决方式

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大概在70行 ,替换成

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值