您现在的位置是:网站首页 > 代码编程 > JAVA开发JAVA开发
【原】Linux下tomcat启动卡住的解决方案图文教程
不忘初心 2019-03-02 围观() 评论() 点赞() 【JAVA开发】
简介:之前的服务器到期了,新入手了一台云服务器,在发布工程的时候,发现tomcat卡住很久,之前的服务器没有这个问题,开始以为是项目哪里配置出错了,自己检查了没问题,在本地也是可以启动的,就是在新买的这台服务器上面超级慢,一度让我怀疑是否新买的服务器有问题,一波百度下来,发现原来这个问题可以从tomcat着手找原因。。。大家可以看到,这两行日志之间卡了将近4分钟之久,真的是不能忍,具体日志信息如下:02
之前的服务器到期了,新入手了一台云服务器,在发布工程的时候,发现tomcat卡住很久,之前的服务器没有这个问题,开始以为是项目哪里配置出错了,自己检查了没问题,在本地也是可以启动的,就是在新买的这台服务器上面超级慢,一度让我怀疑是否新买的服务器有问题,一波百度下来,发现原来这个问题可以从tomcat着手找原因。。。
大家可以看到,这两行日志之间卡了将近4分钟之久,真的是不能忍,具体日志信息如下:
02-Mar-2019 18:32:34.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.30
02-Mar-2019 18:32:34.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 1 2015 22:30:46 UTC
02-Mar-2019 18:32:34.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.30.0
02-Mar-2019 18:32:34.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-514.26.2.el7.x86_64
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/jdk/jre
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_112-b15
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
02-Mar-2019 18:32:34.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
02-Mar-2019 18:32:34.160 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
02-Mar-2019 18:32:34.543 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
02-Mar-2019 18:32:34.569 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Mar-2019 18:32:34.583 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
02-Mar-2019 18:32:34.585 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Mar-2019 18:32:34.589 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1271 ms
02-Mar-2019 18:32:34.626 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
02-Mar-2019 18:32:34.626 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
02-Mar-2019 18:32:38.844 INFO [localhost-startStop-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.
02-Mar-2019 18:34:02.990 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [77,044] milliseconds.
02-Mar-2019 18:34:06.508 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
02-Mar-2019 18:34:06.747 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 239 ms
02-Mar-2019 18:34:06.747 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
02-Mar-2019 18:34:06.839 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 91 ms
02-Mar-2019 18:34:06.839 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
02-Mar-2019 18:34:06.862 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 23 ms
02-Mar-2019 18:34:06.862 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/jwcz
02-Mar-2019 18:34:09.749 INFO [localhost-startStop-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.
02-Mar-2019 18:34:18.455 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/jwcz has finished in 11,593 ms
02-Mar-2019 18:34:18.455 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
02-Mar-2019 18:34:18.482 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 26 ms
02-Mar-2019 18:34:18.502 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Mar-2019 18:34:18.507 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
02-Mar-2019 18:34:18.510 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 103920 ms
日志信息太多了,前面的刷没了,我又重新启动了一遍,这次虽然没有卡住4分钟这么长,但是也卡住了快2分钟(唯一的区别:刚才找日志时发现太多了,难找的很,日志文件竟然有2G了,所以我清空了一下日志)。
为了验证是不是因为我清除了日志影响到了卡顿时间,所以我特意重启了一遍,这次又跟第一次一样卡住了很久,4分半钟
02-Mar-2019 18:37:26.869 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
02-Mar-2019 18:37:31.061 INFO [localhost-startStop-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.
02-Mar-2019 18:41:52.152 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [254,338] milliseconds.
02-Mar-2019 18:41:55.444 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
所以,上面的猜测可以排除了。
细看日志,发现卡住的地方就在deploy web这个位置
02-Mar-2019 18:34:02.990 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [77,044] milliseconds.
02-Mar-2019 18:34:06.508 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
第一行虽然不是deploy web的日志,但是基本可以确定,就是在发布webapps目录中的工程时卡住了。
遂百度之,发现有大神碰见过这个问题,大概原因是启动时获取随机数时卡住了
解决方案:修改 $JAVA_HOME/jre/lib/security/java.security 文件,替换securerandom.source=file:/dev/random 为 securerandom.source=file:/dev/urandom
顺着此方案找到java.security文件,里面真的写的是file:/dev/random
修改为securerandom.source=file:/dev/urandom之后,再次重启tomcat
02-Mar-2019 18:57:54.772 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
02-Mar-2019 18:57:58.760 INFO [localhost-startStop-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.
02-Mar-2019 18:58:09.402 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
02-Mar-2019 18:58:09.641 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 238 ms
时间已经缩短到了10秒以内,至此,问题得到解决!!!
Tips:在参考的文章中,作者说他改为了urandom之后也没有生效,需要多加一层目录(securerandom.source=file:/dev/./urandom),但是我在机器上测试的时候,直接写urandom就可以了,大家如果写urandom还没有解决,不妨也试试这种写法。
大神的文章地址:http://blog.csdn.net/queshuihaimian/article/details/78117356
看完文章,有任何疑问,请加入群聊一起交流!!!
很赞哦! ()
相关文章
- Linux环境下tomcat控制台乱码解决方案
- Linux不使用tomcat搭建springboot服务图文教程
- Tomcat历史旧版本官网下载图文教程
- springboot打war包,部署到外部tomcat
- tomcat启动时重复加载项目资源
- tomcat8.x在idea控制台乱码问题的解决方案
- jenkins启动tomcat报错“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined”的解决方案
- Jenkins自动打包部署到远程服务器中的Tomcat
- Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
- One or more listeners failed to start. Full details will be found in the appropriate container log file
标签云
猜你喜欢
- IntelliJ IDEA 2019.2已经可以利用补丁永久破解激活了
- IntelliJ IDEA 2019.3利用补丁永久破解激活教程
- IntelliJ IDEA高版本最灵活的永久破解激活方法(含插件激活,时长你说了算)
- Jetbrains全家桶基于ja-netfilter的最新破解激活详细图文教程
- IntelliJ IDEA 2022.1永久破解激活教程(亲测可用,持续更新)
- 分享几个正版 IntelliJ IDEA 激活码(破解码、注册码),亲测可用,持续更新
- ja-netfilter到底需不需要mymap,2021.3.2版本激活失效?
- 如何激活idea2022.1及以上版本中的插件(亲测可用)
- 【史上最全】IntelliJ IDEA最新2022.1版本安装和激活视频教学(含插件)
- IntelliJ IDEA 2022.2 版本最新2099年永久激活方法,亲测可用,也可以开启新UI了。
站点信息
- 网站程序:spring + freemarker
- 主题模板:《今夕何夕》
- 文章统计:篇文章
- 标签管理:标签云
- 微信公众号:扫描二维码,关注我们