编译安装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. SVM的sklearn.svm.SVC实现与类参数

    SVC继承了父类BaseSVC SVC类主要方法: ★__init__() 主要参数: C: float参数 默认值为1.0 错误项的惩罚系数.C越大,即对分错样本的惩罚程度越大,因此在训练样本中准确 ...

  2. Spark 编程模型(上)

    Spark的编程模型 核心概念(注意对比MR里的概念来学习) Spark Application的组成 Spark Application基本概念 Spark Application编程模型 回顾sc ...

  3. Web 跨域请求

    在前端开发过程中,难免和服务端产生数据交互.一般情况我们的请求分为这么几种情况:   1. 只关注发送,不关注接收  2.不仅要发送,还要关注服务端返回的信息       a.  同域请求      ...

  4. 20165233 2017-2018-2 《Java程序设计》第八周学习总结

    20165233 2017-2018-2 <Java程序设计>第八周学习总结 教材学习内容总结 基础:Java中的线程,Thread类与线程的创建 - 线程是比进程更小的单位. - JVM ...

  5. quartz 的简单使用

    0.依赖: <!-- 引入quartz对应的依赖 --> <dependency> <groupId>org.quartz-scheduler</groupI ...

  6. bootstrap做的导航

    顶部导航:nav-tabs 左边导航:nav-list 响应式布局:div嵌套 ~ container.row.ol-lg-X 效果: 源码: <!DOCTYPE html> <ht ...

  7. 机器学习入门-K-means算法

    无监督问题,我们手里没有标签 聚类:相似的东西聚在一起 难点:如何进行调参 K-means算法 需要制定k值,用来获得到底有几个簇,即几种类型 质心:均值,即向量各维取平均值 距离的度量: 欧式距离和 ...

  8. hibernate 异常

    1.异常:org.hibernate.AnnotationException: No identifier specified for entity异常. entity类是必须要主键的,否则就会报出这 ...

  9. 基于OpenGL编写一个简易的2D渲染框架-02 搭建OpenGL环境

    由于没有使用GLFW库,接下来得费一番功夫. 阅读这篇文章前请看一下这个网页:https://learnopengl-cn.github.io/01%20Getting%20started/02%20 ...

  10. Python library not found: libpython2.7mu.so.1.0

    在使用pyinstaller生成python可执行文件的时候,包错误,提示有几个依赖的库找不到:Python library not found: libpython2.7mu.so.1.0 参考st ...