1. Tomcat needs to add a PID file
Under the Tomca/bin directory, add the setenv.sh configuration, which is called when the catalina.sh is started and configures the Java memory parameters.
#add tomcat Pidcatalina_pid="$CATALINA _base/tomcat.pid"#add java optsjava_ OPTS="-server-xx:permsize=256m-xx:maxpermsize=1024m-xms512m-xmx1024m-xx:maxnewsize=256m "
2. Increase Tomcat.service
[unit]description =tomcatafter = Syslog.target network.target remote-fs.target nss-lookup.target[service]type = forkingpidfile =/usr/local/tomcat/apache-tomcat- 8.5 . 8 /tomcat.pidexecstart =/usr/local/ Tomcat/apache-tomcat-8.5 . 8 /bin/startup. sh execstop =/bin/kill - s QUIT $MAINPIDExecReload =/bin/kill -< Span style= "COLOR: #000000" >s HUP $MAINPIDPrivateTmp =true [install]wantedby =multi-user.target
3. Using Tomcat.service
Configure boot-up
Systemctl Enable Tomcat
Start Tomcat
Systemctl Start Tomcat
Stop Tomcat
Systemctl Stop Tomcat
Restart Tomcat
Systemctl Restart Tomcat
Because the PID is configured, the Tomcat root directory generates the Tomcat.pid file at boot time and is removed after it is stopped.
At the same time when Tomcat starts, executing start does not start two Tomcat, ensuring that only one Tomcat service is always running.
Multiple tomcat can be configured in multiple directories, with no impact.
CentOS 7 configuration Tomcat boot up