编译安装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. 对于入门Demo的看法

    对于一些以前没有接触过的技术,网上一搜,了解一些介绍信息,原理以及一些代码API的大致了解,接下来应该开始一个小Demo例子. 网上现在好多的教材,多数不知是怎么写的,基本大致一个样,对于初学者没什么 ...

  2. spark streaming 概述

    批处理 & 流处理 像这个是批处理 像这样就是流处理 为什么需要流处理--更多场景需要 Spark Core & RDD 本质上是离线运算 Spark Streaming是什么(分布式 ...

  3. json化的必要性

    参考文章:http://www.cnblogs.com/SanMaoSpace/p/3139186.html http://www.oschina.net/question/100267_61459

  4. Angular4之常用指令

    Angular4指令 NgIf <div *ngIf="false"></div> <!-- never displayed --> <d ...

  5. python基础补充内容

    知识内容: 1.三元运算表达式 2.python代码编写规范 3.模块导入与使用 4.python文件名 5.python脚本的"__name__"属性 6.python之禅 一. ...

  6. Latex Error:‘acmart.cls’ not found 解决方案:

    windows下latex编译ACM论文模板时,出现Latex Error:‘acmart.cls’ not found,解决方案:  首先cd至模板所在目录下,然后运行以下命令:  tex acma ...

  7. 红帽yum源安装报错initscripts-9.49.41-1.el7.x86_64 conflicts redhat-release &lt; 7.5-0.11" ?

    https://access.redhat.com/solutions/3425111 环境 Red Hat Enterprise Linux 7 问题 yum fails to apply upda ...

  8. 11. SpringMVC拦截器(资源和权限管理)

    1.DispatcherServlet SpringMVC具有统一的入口DispatcherServlet,所有的请求都通过DispatcherServlet.     DispatcherServl ...

  9. unity Object-c交互

    一.unity 调用 Object-c C/C++可以直接与Object-c交互,只要把文件后缀.m直接改成.mm,成为C/C++与Object-c混编文件.C#又可以调用C/C++方法,所以C#就是 ...

  10. ML_入门

    N-gram 输入法后来提醒nlp自然语言理解一个向量映射到另一个空间,为什么是向量呢?模型其实是向量,一张图片表示成向量,像素表示成rgb ,每一个维度 数的度文本变成向量 one-hot repr ...