记录jenkins因为缓存空间不足挂掉问题

前言:今天老大说让我写个jenkins挂掉自动拉起的脚本,然后说jenkins挂了好多次了,让我找找原因,当时想自动拉起脚本不能根本上解决问题,我就去看tomcat日志,因为jenkins是在tomcat下启动的,然后过滤查询catalina.xxxx.log日志发现以下报错。

 在网上查看相关问题,发现是因为资源添加到Web应用程序[/jenkins]的缓存中,在清除过期缓存条目后可用空间仍不足 - 请考虑增加缓存的最大空间

解决方法如下:

摘自tomcat官网的说明

https://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

下面一段文字是跟这个问题相关  

cacheMaxSize	
The maximum size of the static resource cache in kilobytes. If not specified, the default value is 10240 (10 megabytes). This value may be changed while the web application is running (e.g. via JMX). If the cache is using more memory than the new limit the cache will attempt to reduce in size over time to meet the new limit. If necessary, cacheObjectMaxSize will be reduced to ensure that it is no larger than cacheMaxSize/20.

只要在$tocamt_home/conf/context.xml里增加资源最大可缓存的大小就行了,大小可按自己的需要定义

<?xml version="1.0" encoding="UTF-8"?>
    <Resources cachingAllowed="true" cacheMaxSize="102400"/>
</Context>

然后重启tomcat即可,发现重启之后就没有报错了,暂时也没发现挂掉了。

总结: 学会看日志能解决很多问题,出问题不用慌。每天进步一点点啦

posted @ 2022-05-26 22:23  lucky_tomato  阅读(1034)  评论(0编辑  收藏  举报