龙空技术网

Centos8设置Tomcat8.5开机自动启动

卖薯条老师 239

前言:

现在小伙伴们对“centostomcat启动不了”大致比较看重,看官们都想要学习一些“centostomcat启动不了”的相关知识。那么小编在网上搜集了一些对于“centostomcat启动不了””的相关文章,希望小伙伴们能喜欢,兄弟们快快来学习一下吧!

需求:服务器有时候需要重启,手动重启比较麻烦

1、在tomcat\bin\catalina.sh中加入JAVA_HOME环境变量配置

export JAVA_HOME=/uidcloud/jdk8export JRE_HOME=/uidcloud/jdk8/jreexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$PATHexport FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS=trueJAVA_OPTS="-XX:+UseParallelGC -Dlog4j2.formatMsgNoLookups=true -XX:+UseParallelOldGC -Xms64m -Xmx512m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:hcljfl_admin_gc.log"

2、配置tomcat开机启动

vim /usr/lib/systemd/system/adminTomcat.service

[unit]Description=Admin_TomcatAfter=syslog.target network.target remote-fs.target nss-lookup.target[Service]Type=oneshotExecStart=/uidcloud/HaiCangTomcatFolders/adminTomcat/bin/startup.shExecStop=/uidcloud/HaiCangTomcatFolders/adminTomcat/bin/shutdown.shExecReload=/bin/kill -s HUP $MAINPIDRemainAfterExit=yes[Install]WantedBy=multi-user.target

配置ExecStart,ExecStop的文件位置是tomcat相关文件的位置

3、相关服务操作

设置开机自动启动服务systemctl enable adminTomcat.service禁用开机自启tomcatsystemctl disable tomcat.service    停止tomcatsystemctl stop adminTomcat.servicesystemctl start adminTomcat.service重启tomcat systemctl restart adminTomcat.service查看状态tomcat systemctl status adminTomcat.service不关闭UNIT的情况下重新载入配置文件,让配置生效,只重新加载.conf类的文件systemctl reload  adminTomcat.service

标签: #centostomcat启动不了