如何解决Tomcat重新配置后启动慢的问题

这篇文章主要介绍了如何解决Tomcat重新配置后启动慢的问题,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联专注于网站建设|网站维护|优化|托管以及网络推广,积累了大量的网站设计与制作经验,为许多企业提供了网站定制设计服务,案例作品覆盖成都封阳台等行业。能根据企业所处的行业与销售的产品,结合品牌形象的塑造,量身开发品质网站。

Jenkins+Tomcat服务器配置过程中,修改了tomcat配置文件;然后再访问服务器的tomcat页面发现根本加载不出来

企图重启tomcat

/opt/tomcat/bin/shutdown.sh

出现如下报错

[root@izbp1fmfc2pdjiw9u143xfz conf]# /opt/tomcat/bin/shutdown.sh Using CATALINA_BASE: /opt/tomcat Using CATALINA_HOME: /opt/tomcat Using CATALINA_TMPDIR: /opt/tomcat/temp Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar 二月 20, 2020 1:37:22 下午 org.apache.catalina.startup.Catalina stopServer 严重: Could not contact [localhost:8005]. Tomcat may not be running. 二月 20, 2020 1:37:22 下午 org.apache.catalina.startup.Catalina stopServer 严重: Catalina.stop: java.net.ConnectException: 拒绝连接 (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at java.net.Socket.connect(Socket.java:556) at java.net.Socket.(Socket.java:452) at java.net.Socket.(Socket.java:229) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:504) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:389) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:479)

经查证,出现这种报错的原因是Tomcat尚未启动完成;

接下来尝试了强制关闭tomcat

ps -ef | grep tomcat 查看tomcat进程号
kill -9 + 进程号 杀死进程

重新启动tomcat

/opt/tomcat/bin/startup.sh

tomcat页面依旧无法加载

打印tomcat运行日志

[root@izbp1fmfc2pdjiw9u143xfz conf]# cd /opt/tomcat [root@izbp1fmfc2pdjiw9u143xfz tomcat]# ls bin BUILDING.txt conf CONTRIBUTING.md lib LICENSE logs NOTICE README.md RELEASE-NOTES RUNNING.txt temp webapps work [root@izbp1fmfc2pdjiw9u143xfz tomcat]# cd logs [root@izbp1fmfc2pdjiw9u143xfz logs]# ls catalina.2020-02-20.log host-manager.2020-02-20.log localhost_access_log.2020-02-20.txt catalina.out localhost.2020-02-20.log manager.2020-02-20.log [root@izbp1fmfc2pdjiw9u143xfz logs]# tail -f catalina.out 20-Feb-2020 13:48:35.239 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat 20-Feb-2020 13:48:35.239 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat 20-Feb-2020 13:48:35.239 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp 20-Feb-2020 13:48:35.239 信息 [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] 20-Feb-2020 13:48:35.348 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"] 20-Feb-2020 13:48:35.391 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 20-Feb-2020 13:48:35.403 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 895 ms 20-Feb-2020 13:48:35.487 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 20-Feb-2020 13:48:35.487 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.51 20-Feb-2020 13:48:35.524 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [/opt/tomcat/webapps/docs]

发现运行日志卡在最后一行:localhost-startStop-1,无法向下继续进行

解决方案:

$ JAVA_HOME / jre / lib / security / java.security文件中的securerandom.source参数修改为文件:/ dev /./ urandom

[root@izbp1fmfc2pdjiw9u143xfz logs]# cd $JAVA_HOME/jre/lib/security
[root@izbp1fmfc2pdjiw9u143xfz security]# ls
blacklisted.certs cacerts java.policy java.security nss.cfg policy
[root@izbp1fmfc2pdjiw9u143xfz security]# vi java.security

顺带一提,在vi中快速搜索的方法:

命令模式下输入“/字符串”,例如“/Section 3”。如果查找下一个,按“n”即可。

感谢你能够认真阅读完这篇文章,希望小编分享的“如何解决Tomcat重新配置后启动慢的问题”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


当前标题:如何解决Tomcat重新配置后启动慢的问题
文章路径:http://myzitong.com/article/joedos.html