Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does CentOS7 add tomcat start and stop

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how CentOS7 increases tomcat start and stop". In daily operation, I believe many people have doubts about how CentOS7 increases tomcat start and stop. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how CentOS7 increases tomcat start and stop". Next, please follow the editor to study!

1centos7 replaces the service command with systemctl

Reference: 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 Servic

Systemctl status name.service

Start the service

Systemctl start name.service

Out of Service

Systemctl stop name.service

Restart the service

Systemctl restart name.service added boot boot

Systemctl enable name.service

Delete boot boot

Systemctl disable name.service

Where .service can be omitted.

2Magol tomcat adds startup parameters

Tomcat needs to add a pid file

Under the tomca/bin directory, add the setenv.sh configuration, which will be called when catalina.sh starts, and configure the java memory parameters.

The code is as follows:

# add tomcat pid

CATALINA_PID= "$CATALINA_BASE/tomcat.pid"

# add java opts

JAVA_OPTS= "- server-XX:PermSize=256M-XX:MaxPermSize=1024m-Xms512M-Xmx1024M-XX:MaxNewSize=256m"

3. Add tomcat.service

Add tomcat.service under the / usr/lib/systemd/system directory and the directory must be an absolute directory.

The code is as follows:

[Unit]

Description=Tomcat

After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/data/tomcat/tomcat.pid

ExecStart=/data/tomcat/bin/startup.sh

ExecReload=/bin/kill-s HUP $MAINPID

ExecStop=/bin/kill-s QUIT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

[unit] configures the description of the service and specifies that it is executed after the network starts. [service] configure the pid of the service, start, stop, and restart the service. [install] the user is configured.

4, use tomcat.service

Configure boot boot

Systemctl enable tomcat

Start tomcat

Systemctl start tomcat

Stop tomcat

Systemctl stop tomcat

Restart tomcat

Systemctl restart tomcat

Because pid is configured, the tomcat.pid file will be generated in the root directory of tomcat at startup, and will be deleted after stopping.

At the same time, when tomcat starts, executing start does not start two tomcat, ensuring that only one tomcat service is running all the time.

Multiple tomcat can be configured in multiple directories and do not affect each other.

At this point, the study on "how CentOS7 increases tomcat start and stop" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report