pingFang SC", "Microsoft YaHei", SimHei, Arial, SimSun; font-size: 20px; color: rgb(79, 79, 79); line-height: 30px; overflow-wrap: break-word; text-wrap: wrap; background-color: rgb(255, 255, 255);">systemctl管理Tomcat启动、停止、重启、开机启动
系统环境
root@debian:~# cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
定制tomcat.service脚本
[Unit] Description=tomcatserver After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/usr/local/src/java/jdk8u191-b12 Environment=CATALINA_HOME=/usr/local/src/Apache-tomcat-9.0.44/ ExecStart=/usr/local/src/apache-tomcat-9.0.44/bin/startup.sh ExecStop=/usr/local/src/apache-tomcat-9.0.44/bin/shutdown.sh Restart=on-abort [Install] WantedBy=multi-user.target
指令操作
cp tomcat.service /etc/systemd/system/ systemctl daemon-reload systemctl enable tomcat reboot
service管理Tomcat启动、停止、重启、开机启动
配置
问题记录
Too Many Open Files
java invoked oom-killer: gfp_mask
Apache Tomcat 9:windows" data-pretit="windows" style="box-sizing: border-box; outline: 0px; margin: 24px 3px 8px 0px; padding: 0px 18px 0px 0px; color: #4EA1DB; overflow-wrap: break-word; cursor: pointer; background: url("../img/gitcode-key.png") right center / 14px 14px no-repeat transparent; box-shadow: none;">Windows服务启动失败排查过程
java.lang.OutOfMemoryError: Java heap space at java.nio.HeapByteBuffer.(HeapByteBuffer.java:57) at java.nio.ByteBuffer.allocate(ByteBuffer.java:335) at org.apache.coyote.http11.Http11OutputBuffer.(Http11OutputBuffer.java:110) at org.apache.coyote.http11.Http11Processor.(Http11Processor.java:163) at org.apache.coyote.http11.AbstractHttp11Protocol.createProcessor(AbstractHttp11Protocol.java:1001) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)
登录后复制
18-May-2021 16:25:55.990 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数:-Xms128m 18-May-2021 16:25:55.990 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数:-Xmx256m
内存设置太小
登录后复制
18-May-2021 17:19:58.841 信息 [Abandoned connection cleanup thread] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading 非法访问:此Web应用程序实例已停止。无法加载[]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈跟踪。 java.lang.IllegalStateException: 非法访问:此Web应用程序实例已停止。无法加载[]。为了调试以及终止导致非法访问的线程,将抛出以下堆栈跟踪。 at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1385) at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1038) at com.mysql.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:90) at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:63) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
登录后复制
18-May-2021 17:19:51.643 信息 [Thread-43] org.apache.catalina.core.StandardService.stopInternal 正在停止服务[Catalina] 18-May-2021 17:19:53.883 警告 [Thread-43] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc Web应用程序 [cs] 注册了JDBC驱动程序 [com.alibaba.druid.proxy.DruidDriver],但在Web应用程序停止时无法注销它。 为防止内存泄漏,JDBC驱动程序已被强制取消注册。 18-May-2021 17:19:53.887 警告 [Thread-43] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc Web应用程序 [cs] 注册了JDBC驱动程序 [com.mysql.jdbc.Driver],但在Web应用程序停止时无法注销它。 为防止内存泄漏,JDBC驱动程序已被强制取消注册。 18-May-2021 17:19:53.889 警告 [Thread-43] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads Web应用程序[cs]似乎启动了一个名为[Thread-6]的线程,但未能停止它。这很可能会造成内存泄漏。线程的堆栈跟踪:[ java.lang.Thread.sleep(Native Method) com.cvos.cs.modules.map.camera.web.QueueListenter$1.run(QueueListenter.java:30) java.lang.Thread.run(Thread.java:748)] 18-May-2021 17:19:53.890 警告 [Thread-43] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads Web应用程序[cs]似乎启动了一个名为[Abandoned connection cleanup thread]的线程,但未能停止它。这很可能会造成内存泄漏。线程的堆栈跟踪:[ java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:64) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) java.lang.Thread.run(Thread.java:748)]
解决方案
问题)Tomcat服务启动:jsp页面返回404现象
02-Jun-2021 16:17:30.174 警告 [http-nio-8080-exec-14] org.apache.jasper.compiler.Compiler.removeGeneratedFiles 未能删除生成的Java文件[E:\Cloudvos\apache-tomcat-9.0.39-windows-x64\apache-tomcat-9.0.39\work\Catalina\localhost\cs\org\apache\jsp\WEB_002dINF\views\modules\ri\communityList_jsp.java]
1.startup.bat脚本启动的Tomcat,可以在catalina.bat开头添加set JAVA_OPTS=-server -Xms512m -Xmx2048m -Xss512k -XX:MaxNewSize=128m
2.服务形式启动的无法通过上述的添加实现,因为服务启动的程序是tomcat9.exe,设置在catalina.bat中的配置不会生效,可以通过查看catalina.bat生成的日志文件可以查看
解决方案:在service.bat文件中添加set JvmMs=2048 set JvmMx=2048,然后重新注册服务即可
本文链接:https://blog.runxinyun.com/post/91.html 转载需授权!
留言0