Home > Database > Redis > body text

redis custom systemctl management service

Release: 2020-04-11 09:07:56
forward
2449 people have browsed it

redis custom systemctl management service

1. Preparation

Compile and install redis (my installation directory/usr/loacl/tool)

Connect redis-server and redis- cli move to the environment variable directory (/usr/loacl/bin); give execution permission

cp redis.conf to the configuration directory (/etc/redis/redis.conf) or make a soft connection; (I choose the former )

Note: For the corresponding directory and permissions, please refer to other requirements

2. Create systemctl service

When using service to manage services, it is in /etc/init. Create a script file in the d/ directory to manage the start and stop of the service. In systemctl, it is similar, but the file directory is different. Create a script file redis.service in the /lib/systemd/system directory with the contents inside. As follows:

[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecReload=/usr/local/bin/redis-server -s reload
ExecStop=/usr/local/bin/redis-server -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Copy after login

[Unit] indicates that this is basic information

Description is a description

After is started after that service, usually after the network service is started

[Service] means here is the service information

ExecStart is the command to start the service

ExecReload is the command to restart the service

ExecStop is the command to stop the service

[Install] Indicates that this is installation related information

WantedBy In which way it is started: multi-user.target indicates that when the system is started in multi-user mode (default run level), this service Needs to be run automatically.

3. Refresh the configuration

The systemctl just configured needs to refresh the configuration to take effect

$ systemctl daemon-reload
Copy after login

4. Set the boot usage

Set the redis service to be enabled at boot

$ systemctl enable redis.service
Copy after login

For more redis knowledge, please pay attention to the redis introductory tutorial column.

The above is the detailed content of redis custom systemctl management service. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template