编译安装tomcat-native和tomcat-deamon以后,发现toomcat启动很慢,好久才有响应。以下日志供参考:

11-Sep-2017 12:19:28.102 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-9.0/webapps/ROOT]
11-Sep-2017 12:19:28.667 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:20:34.870 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [66,193] milliseconds.
11-Sep-2017 12:20:34.917 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/ROOT] has finished in [66,815] ms
11-Sep-2017 12:20:34.918 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-9.0/webapps/host-manager]
11-Sep-2017 12:20:35.004 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:20:35.013 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/host-manager] has finished in [96] ms
11-Sep-2017 12:20:35.014 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-9.0/webapps/manager]
11-Sep-2017 12:20:35.062 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:20:35.066 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/manager] has finished in [53] ms
11-Sep-2017 12:20:35.074 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
11-Sep-2017 12:20:35.105 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
11-Sep-2017 12:20:35.113 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 67067 ms

tomcat启动耗时67067ms折合67秒,刚刚安装的干净tomcat,显然不对劲。

有一条日志引起了我的注意:

11-Sep-2017 12:20:34.870 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [66,193] milliseconds.

显然tomcat执行到这里时出问题了,google了一下:"tomcat startup take long time SecureRandom",经过搜索,发现了一个解决方法

Slow startup on Tomcat 7.0.57 because of SecureRandom

问题缘由:当没有足够的entropy反馈给/dev/random时调用securerandom的时候可能引起阻塞。

解决方法1:

修改 /opt/jdk1.8/jre/jre/lib/security/java.security

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

解决方法2:安装haveged

apt-get install haveged
vim /etc/default/haveged #编辑配置文件,输入下面一行
DAEMON_ARGS="-w 1024" #刷新配置
update-rc.d haveged defaults

笔者采用了第二种方法,ubuntu16 amd64,64位系统,其他linux系统参考How to Setup Additional Entropy for Cloud Servers Using Haveged

同以上操作顺利解决问题。

更新后重启tomcat日志如下:

[/opt/apache-tomcat-9.0/webapps/ROOT]
11-Sep-2017 12:28:00.324 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:28:00.374 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/ROOT] has finished in [567] ms
11-Sep-2017 12:28:00.375 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-9.0/webapps/host-manager]
11-Sep-2017 12:28:00.448 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:28:00.456 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/host-manager] has finished in [80] ms
11-Sep-2017 12:28:00.456 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-9.0/webapps/manager]
11-Sep-2017 12:28:00.502 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
11-Sep-2017 12:28:00.504 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-9.0/webapps/manager] has finished in [48] ms
11-Sep-2017 12:28:00.514 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
11-Sep-2017 12:28:00.545 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
11-Sep-2017 12:28:00.565 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 803 ms

参考:

Tomcat takes too much time to start - Java SecureRandom

How to Setup Additional Entropy for Cloud Servers Using Haveged

Slow startup on Tomcat 7.0.57 because of SecureRandom

Tomcat 8熵池阻塞变慢详解

WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [] milliseconds.的更多相关文章

  1. tomcat启动时间5分钟左右org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [342,445] milliseconds.

    org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance ...

  2. 解决 Tomcat reload WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but fail

    转自:http://www.cnblogs.com/interdrp/p/5632529.html 我的错误如下: 06-Sep-2016 18:57:10.595 WARNING [localhos ...

  3. 解决 01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.D

    01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoade ...

  4. 转载:org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.Annotation

    转载:org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.Annotation (2012 ...

  5. org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor

    这几天来公司,公司的SVN坏掉了,然后项目还比较大,是一个分布式的,然后同事就把项目发我了.我在myeclipse里面导入项目了,把相应的jar包也建了个人的library导入了项目,现在项目不报错了 ...

  6. Tomcat启动问题:严重[main] org.apache.catalina.core.AprLifecycleListener.init An incompatible version...

    今天观察tomcat启动日志,有一些以前没注意到的信息: 严重 [main] org.apache.catalina.core.AprLifecycleListener.init An incompa ...

  7. JavaWeb问题记录——SessionIdGeneratorBase.createSecureRandom

    JavaWeb问题记录——SessionIdGeneratorBase.createSecureRandom 摘要:本文主要记录了在启动Tomcat时,出现的一个警告以及解决办法. 部分内容来自以下博 ...

  8. org.apache.catalina.LifecycleException: Failed to start component

    1.错误描述 Using CATALINA_BASE: "D:\NetBeans\apache-tomcat-8.0.12" Using CATALINA_HOME: " ...

  9. tomcat启动时SessionIdGeneratorBase.createSecureRandom耗时5分钟的问题

    通常情况下,tomcat启动只要2~3秒钟,突然有一天,tomcat启动非常慢,要花5~6分钟,查了很久,终于在这篇文章找到了解决方案,博主牛人啊. 原文参见:http://blog.csdn.net ...

随机推荐

  1. Dividing Infinity - Distributed Partitioning Schemes

    This is the second post in a series discussing the architecture and implementation of massively para ...

  2. oracle 收集的一些图

    ================================================ ================================================ da ...

  3. 小朋友学C++(1)

    Hello World! 在学C++之前,最好先学习一下C语言 让我们先运行一段简单的代码,编译器可以使用 在线C++编译器 或 Xcode(苹果系统) 或Dev C++(Windows系统). #i ...

  4. Solr优化案例分析

    随着umc接入主机的数量越来越多,每天产生的syslog日志数量也在剧增, 之前一天产生的syslog数量才不 到1W,随着整个集团的网络设备不端接入,导致现在每天产生的syslog数量大概在180w ...

  5. 「CQOI2016」K 远点对

    /* 考虑暴力 可以n ^ 2枚举点对 然后用一个容量为2k的小根堆来维护第k大 kd-tree呢就是来将这个暴力优化, 每次先找远的并且最远距离不如堆顶的话就不继续找下去 貌似挺难构造数据卡的 */ ...

  6. node进阶之用流实现上传文件

    内容: 1.文件上传基础 2.node文件处理机制 3.用流实现文件上传 1.文件上传基础 前端代码: <form action="localhost:8080/" meth ...

  7. Survival Coxph log-rank

    Difference between survdiff log-rank and coxph log-rank Ask Question 6 1 I'm using the survival pack ...

  8. jsp 传多个值给后端

     页面上是这样 http://localhost:8080/smartcloset/getClothByCategory/1/11 直接用/分 后台是这样取的 @RequestMapping(valu ...

  9. xe7 Unresolved external CSPIN.OBJ

    工程里打开使用了CSPIN控件的界面窗体,再编译就好了 [ilink32 Error] Error: Unresolved external 'Vcl::Controls::TControl::Set ...

  10. BDE 退出历史 迁移至FireDAC

    BDE组件套TQuery\TTable\TStoreProce结束历时使命. ADO组件套也停止更新, 将来是FireDAC组件套的江湖 Migrating BDE Applications to F ...