zoukankan      html  css  js  c++  java
  • Tomcat 启动卡在 Root WebApplicationContext: initialization completed in

    tomcat 启动一直卡在

    Root WebApplicationContext: initialization completed in
    

    重启了很多次,更换jdk版本,tomcat版本都不行。

    tomcat所在的JVM进程已经被启动了所以可以排除是JVM退出引起的问题。那么问题真的就是JVM因为某种原因被阻塞了。

    https://blog.csdn.net/wwdwjm/article/details/77840113

    主要是因为阿里云的熵池太小 熵池的大小是根据键盘 鼠标之类的噪音产生的数 然后/dev/random会根据熵池来生成随机数 而生成需要有足够的熵池里的噪音数 如果没有达到的话就会一直阻塞 tomcat启动的时候为了生成session id就会获取这个随机数来生成密匙 所以才出现上面的情况 一直阻塞在等待熵池里的数满足生成随机数的大小 3分钟以后熵池里的数够大了才开始部署

    yum install -y rng-tools
    systemctl start rngd
    cp /usr/lib/systemd/system/rngd.service /etc/systemd/system
    vi /etc/systemd/system/rngd.service
    

    ExecStart=/sbin/rngd -f -r /dev/urandom

    WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [348,853] milliseconds
    

    后来查了一下,发现这个问题抱怨的还是蛮多的,以至于tomcat的wiki里面还单独列出来作为加速启动的一个方面:

    Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy. You will see warning in the logs when this happens, e.g.:

    There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom

    尝试使用-Djava.security.egd=file:/dev/./urandom启动了一下,果然快了很多。

    https://wiki.apache.org/tomcat/HowTo/FasterStartUp

    Centos6

    yum install rng-tools -y
    cat /etc/sysconfig/rngd 
    
    # Add extra options here
    EXTRAOPTIONS="-r /dev/urandom"
    
    service rngd start
    cat /proc/sys/kernel/random/entropy_avail
    
  • 相关阅读:
    code#5 P2 棋子
    code#5 P1 报告
    ztz11的noip模拟赛T3:评分系统
    20181101noip模拟赛T1
    20181031noip模拟赛T2
    20181031noip模拟赛T1
    Linux进程的五个段
    进程和线程有什么区别
    shell中if条件字符串、数字比对,[[ ]]和[ ]区别
    Python实现单例模式
  • 原文地址:https://www.cnblogs.com/fsckzy/p/11504322.html
Copyright © 2011-2022 走看看