tomcat启动一直卡在Root WebApplicationContext: initialization completed

本文介绍了解决阿里云上Tomcat启动慢的问题,主要原因是容器内的熵池不足导致随机数生成受阻,进而影响Tomcat启动。通过安装并配置rngd服务来增加熵池大小,从而加快Tomcat启动速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我在阿里云上安装docker然后在docker容器里启动tomcat一直卡在Root WebApplicationContext: initialization completed in 2520 ms以后要等3分钟才会启动我上传上去的项目 后来看到http://www.jianshu.com/p/576d356dc163这篇文章里找到了原因 主要是因为阿里云的熵池太小 熵池的大小是根据键盘 鼠标之类的噪音产生的数 然后/dev/random会根据熵池来生成随机数 而生成需要有足够的熵池里的噪音数 如果没有达到的话就会一直阻塞 tomcat启动的时候为了生成session id就会获取这个随机数来生成密匙 所以才出现上面的情况 一直阻塞在等待熵池里的数满足生成随机数的大小 3分钟以后熵池里的数够大了才开始部署 所以我们可以使用rngd来增大熵池 因为docker容器的熵池都是共享的宿主机的 所以只要增大宿主机的熵池就可以了 在容器内是没办法通过rngd修改熵池的因为没有权限修改宿主机的东西 只能通过上面链接里提到的修改jre或者tomcat的方法
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 在最后加上-r /dev/urandom

ExecStart=/sbin/rngd -f -r /dev/urandom
重新载入服务
systemctl daemon-reload
重启服务
systemctl restart rngd
21-Mar-2025 14:28:33.975 ��Ϣ [RMI TCP Connection(2)-127.0.0.1] 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. 2025-03-21 14:28:34 -0 [RMI TCP Connection(2)-127.0.0.1] INFO - Root WebApplicationContext: initialization started 2025-03-21 14:28:34 -100 [RMI TCP Connection(2)-127.0.0.1] INFO - Refreshing Root WebApplicationContext: startup date [Fri Mar 21 14:28:34 CST 2025]; root of context hierarchy 2025-03-21 14:28:34 -169 [RMI TCP Connection(2)-127.0.0.1] INFO - Loading XML bean definitions from class path resource [spring/spring.xml] 2025-03-21 14:28:34 -545 [RMI TCP Connection(2)-127.0.0.1] INFO - Loading XML bean definitions from class path resource [spring/spring-mybatis.xml] 2025-03-21 14:28:35 -1324 [RMI TCP Connection(2)-127.0.0.1] ERROR - maxIdle is deprecated 2025-03-21 14:28:35 -1404 [RMI TCP Connection(2)-127.0.0.1] INFO - {dataSource-1} inited 2025-03-21 14:28:38 -3963 [RMI TCP Connection(2)-127.0.0.1] INFO - Root WebApplicationContext: initialization completed in 3957 ms 2025-03-21 14:28:38 -4026 [RMI TCP Connection(2)-127.0.0.1] INFO - FrameworkServlet 'SpringMVC': initialization started 2025-03-21 14:28:38 -4031 [RMI TCP Connection(2)-127.0.0.1] INFO - Refreshing WebApplicationContext for namespace 'SpringMVC-servlet': startup date [Fri Mar 21 14:28:38 CST 2025]; parent: Root WebApplicationContext 2025-03-21 14:28:38 -4032 [RMI TCP Connection(2)-127.0.0.1] INFO - Loading XML bean definitions from class path resource [spring/spring-mvc.xml] 2025-03-21 14:28:38 -4616 [RMI TCP Connection(2)-127.0.0.1] INFO - Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0' 2025-03-21 14:28:38 -4806 [RMI TCP Con
最新发布
03-22
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值