1、ps -ef | grep tomcat 查看是否启动
2、在tomcat目录的bin下创建setenv.sh
位置:/home/tomcat/apache-tomcat-9.0.33/bin
设置Tomcat的PID文件
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
添加JVM选项
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
3 、修改catalina.sh文件 位置:/home/tomcat/apache-tomcat-9.0.33/bin/catalina.sh
添加
export JAVA_HOME=/home/javajdk/jdk1.8.0_212
export JRE_HOME=/home/javajdk/jdk1.8.0_212/jre
4、创建tomcat.service文件 位置:/usr/lib/systemd/system
[Unit]
Description=Tomcat
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
TimeoutSec=0
PIDFile=/home/tomcat/apache-tomcat-9.0.33/tomcat.pid
ExecStart=/home/tomcat/apache-tomcat-9.0.33/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
5、重新加载及启动服务
systemctl daemon-reload
systemctl enable tomcat.service
systemctl start tomcat
systemctl status tomcat
systemctl list-unit-files | grep enabled
systemctl list-unit-files | grep tomcat