快速解决Tomcat重新配置后启动慢的问题

(编辑:jimmy 日期: 2024/12/24 浏览:2)

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.<init>(Socket.java:452) at java.net.Socket.<init>(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启动慢请关注其它相关文章!

一句话新闻

一文看懂荣耀MagicBook Pro 16
荣耀猎人回归!七大亮点看懂不只是轻薄本,更是游戏本的MagicBook Pro 16.
人们对于笔记本电脑有一个固有印象:要么轻薄但性能一般,要么性能强劲但笨重臃肿。然而,今年荣耀新推出的MagicBook Pro 16刷新了人们的认知——发布会上,荣耀宣布猎人游戏本正式回归,称其继承了荣耀 HUNTER 基因,并自信地为其打出“轻薄本,更是游戏本”的口号。
众所周知,寻求轻薄本的用户普遍更看重便携性、外观造型、静谧性和打字办公等用机体验,而寻求游戏本的用户则普遍更看重硬件配置、性能释放等硬核指标。把两个看似难以相干的产品融合到一起,我们不禁对它产生了强烈的好奇:作为代表荣耀猎人游戏本的跨界新物种,它究竟做了哪些平衡以兼顾不同人群的各类需求呢?