In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
This article mainly introduces you about systemctl management Tomcat start, stop, restart and boot related content, share out for your reference and study, the following words do not say much, let's take a look at the detailed introduction.
1. Create a service
When you use service to manage a service, you create a script file in the / etc/init.d/ directory to manage the start and stop of the service. Similarly, in systemctl, the file directory is different. Create a script file tomcat in the / lib/systemd/system directory, which contains the following contents:
[Unit] Description=TomcatAfter= network.target[Service] Type=forkingPIDFile=/usr/local/tomcat/pidExecStart=/usr/local/tomcat/bin/catalina.sh startExecReload=/usr/local/tomcat/bin/catalina.sh restartExecStop=/usr/local/tomcat/bin/catalina.sh stop[Install] WantedBy=multi-user.target
[Unit] indicates that this is basic information.
Description describes which service After is started after, usually after the network service is started.
[Service] indicates that this is the service information
Type is the service type PIDFile is the pid file path of the service. When enabled, you must add the CATALINA_PID parameter ExecStart to the bin/catalina.sh of tomcat. ExecStart is the command to start the service. ExecReload is the command to restart the service. ExecStop is the instruction to stop the service.
[Install] indicates that this is installation related information.
How does WantedBy start: multi-user.target indicates that this service needs to be run automatically when the system is started in multi-user mode (the default runlevel).
When you add the CATALINA_PID parameter to the bin/catalina.sh of tomcat, you need to add the CATALINA_PID parameter in # OS specific support. Join in
CATALINA_PID=/usr/local/tomcat/pid# OS specific support. $var _ must_ be set to either true or false.cygwin=false.... Slightly; slightly.
two。 Create a soft link
Soft links are created to automatically start the service when the system is initialized.
Ln-s / lib/systemd/system/tomcat.service / etc/systemd/system/multi-user.target.wants/tomcat.service
Creating a soft link is like a shortcut under Windows
Ln-s is to create soft links
Ln-s original file destination file (decision address of the shortcut)
If there is an exception when creating a soft connection, don't worry to see if the / etc/systemd/system/multi-user.target.wants/ directory is normal to create a soft link. Sometimes the error report is just a reminder that it is actually successful.
$ll / etc/systemd/system/multi-user.target.wants/total 8drwxr-xr-x 2 root root 4096 Mar 30 15:46. / drwxr-xr-x 13 root root 4096 Mar 13 14:18.. / lrwxrwxrwx 1 root root 31 Nov 23 14:43 tomcat.service-> / lib/systemd/system/tomcat.service... A little.
3. Refresh configuration
The service just configured needs to be recognized by systemctl, so the configuration must be refreshed.
$systemctl daemon-reload
You can use sudo if you don't have permission.
$sudo systemctl daemon-reload
4. Start, restart, stop
Start tomcat
$systemctl start tomcat
Restart tomcat
$systemctl restart tomcat
Stop tomcat
$systemctl stop tomcat
5. Boot self-start
Tomcat service joins boot startup
$systemctl enable tomcat
Do not start up.
$systemctl disable tomcat
6. View statu
View statu
$systemctl status tomcat
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.