CentOS7 increase tomcat boot, stop, configure with Systemctl

Source: Internet
Author: User

1,centos7 replaced the service command with SYSTEMCTLreference: Redhat Documentation: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 boot start
Systemctl Enable Name.service
Remove Boot Boot
Systemctl Disable Name.service
where the. Service can be omitted.

2,tomcat increasing the startup parameters

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 "

3, Increase Tomcat.service

Add Tomcat.service to the/usr/lib/systemd/system directory and 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


The [unit] Configures the description of the service, which specifies that it is executed after network startup. the [service] configures the service's PID, the service starts, stops, restarts. [Install] is configured to use the user.

4, 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.


CentOS7 increase tomcat boot, stop, configure with Systemctl

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.