• 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
    
  • 相关阅读:
    NSIndexPath 延伸
    iOS进阶推荐的书目
    配置App真机测试证书的流程 一览
    NSAttributedString 的21种属性 详解
    KVO & 通知 小记
    贝塞尔曲线 & CAShapeLayer & Stroke 动画 浅谈
    提升开发人员修为的探讨
    热门IOS 第三方库
    drawRect & 内存 -> 深究
    CALayer & UIView 关系浅析
  • 原文地址:https://www.cnblogs.com/fsckzy/p/11504322.html
Copyright © 2020-2023  润新知