CentOS7下利用systemd机制实现tomcat开机自启动
参考https://www.cloudcared.cn/2173.html
但是报错,无法启动:
[root@god tomcat]# journalctl -xe
Aug 20 11:23:04 xuegod67.cn polkitd[548]: Unregistered Authentication Agent for unix-process:4714:288082 (system bus n
Aug 20 11:23:05 xuegod67.cn polkitd[548]: Registered Authentication Agent for unix-process:4731:288243 (system bus nam
Aug 20 11:23:05 xuegod67.cn systemd[1]: Starting Tomcat8...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has begun starting up.
Aug 20 11:23:05 xuegod67.cn startup.sh[4737]: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Aug 20 11:23:05 xuegod67.cn startup.sh[4737]: At least one of these environment variable is needed to run this program
Aug 20 11:23:05 xuegod67.cn systemd[1]: tomcat.service: control process exited, code=exited status=1
Aug 20 11:23:05 xuegod67.cn systemd[1]: Failed to start Tomcat8.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has failed.
--
-- The result is failed.
Aug 20 11:23:05 xuegod67.cn systemd[1]: Unit tomcat.service entered failed state.
Aug 20 11:23:05 xuegod67.cn systemd[1]: tomcat.service failed.
Aug 20 11:23:05 xuegod67.cn polkitd[548]: Unregistered Authentication Agent for unix-process:4731:288243 (system bus n
又参考另外一篇博文:https://www.jianshu.com/p/f0f8458e1631
setenv.sh,需要配置java环境
# 设置JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.8.0_211
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_BASE=/usr/local/tomcat
# 设置Tomcat的PID文件
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
# 添加JVM选项
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
这次成功了,记录一下
这是一个死循环
没钱学技术
没技术挣钱
只要你相信,知识改变命运,技术成就梦想
你就能够突破这个死循环。