CentOS7 adds tomcat startup, stop, use systemctl for configuration, centos7systemctl

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.