CentOS7 adds tomcat startup, stop, use systemctl for configuration, centos7systemctl
1, centos7 use systemctl to replace the service command reference: redhat document: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html#sect-Managing_Services_with_systemd-Services-List
View All service commands:
Systemctl list-unit-files -- type service
View services
Systemctl status name. service
Start the service
Systemctl start name. service
Stop Service
Systemctl stop name. service
Restart service
Systemctl restart name. service increase startup
Systemctl enable name. service
Delete startup
Systemctl disable name. service
The. service can be omitted.
2. Added startup parameters for tomcat.
Tomcat needs to add a pid File
Add the setenv. sh configuration under the release a/bin directory. The configuration will be called when catalina. sh is started, and java memory parameters are configured at the same time.
#add tomcat pidCATALINA_PID="$CATALINA_BASE/tomcat.pid"#add java optsJAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
3. Added tomcat. service
Add tomcat. service to the/usr/lib/systemd/system directory. The directory must be an absolute directory.
[Unit]Description=TomcatAfter=syslog.target network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/data/tomcat/tomcat.pidExecStart=/data/tomcat/bin/startup.sh ExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target
[Unit] indicates that the service is configured and executed after the network is started. [Service] configure the service pid, service start, stop, and restart. [Install] the user is configured.
4. Use tomcat. service
Configure startup
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. pid file is generated in the tomcat root directory at startup, and deleted after it is stopped.
At the same time, when tomcat is started, executing start will not start two tomcat servers, so that only one tomcat service is always running.
Multiple tomcat servers can be configured in multiple directories without affecting each other.