In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "redis setup application boot self-start", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "redis setup application boot self-start" bar!
This paper describes how to manage our application through systemctl, and takes redis as an example to explain how to set redis as the system program to manage its self-startup process after installing redis through binary compilation.
Redis start, stop, boot
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 redis.service in the / lib/systemd/system directory, which contains the following contents:
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server / usr/local/redis/redis.conf-- daemonize no
ExecStop=/usr/local/bin/redis-cli-h 127.0.0.1-p 6379 shutdown
[Install]
WantedBy=multi-user.target
[Unit] indicates that this is basic information.
Description is the description
After starts after that service, usually after the network service starts.
[Service] indicates that this is the service information
ExecStart is the command to start the service
ExecStop is the order 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).
two。 Create a soft link
A copy can be generated through sysntemctl enable redis sysntemctl disable redis.
$ll / etc/systemd/system/multi-user.target.wants/
Total 8
Drwxr-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 redis.service-> / lib/systemd/system/redis.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 redis
$systemctl start redis
Restart redis
$systemctl restart redis
Stop redis
$systemctl stop redis
5. Boot self-start
Redis service joins boot startup
$systemctl enable redis
Do not start up.
$systemctl disable redis
6. View statu
View statu
$systemctl status redis
Thank you for your reading, the above is the content of "redis setup application boot self-startup". After the study of this article, I believe you have a deeper understanding of the problem of redis setting application boot self-startup, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.