欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

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

程序员文章站 2022-06-27 15:21:56
jenkins+tomcat服务器配置过程中,修改了tomcat配置文件;然后再访问服务器的tomcat页面发现根本加载不出来企图重启tomcat/opt/tomcat/bin/shutdown.sh...

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启动慢请关注其它相关文章!

相关标签: tomcat 启动