1

I'd like to start 3 instances of Redis 6 via systemd. System info:

 root@ubnt:/home/test11# uname -a Linux ubnt 4.15.0-88-generic #88-Ubuntu
 SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
 root@ubnt:/home/test11# lsb_release -a No LSB modules are available.
 Distributor ID: Ubuntu Description:    Ubuntu 18.04.4 LTS Release:    
 18.04 Codename:       bionic

I created service /lib/systemd/system/redis_server_7000.service with content:

[Unit]
Description=Redis data structure server - instance 7000
Documentation=https://redis.io/documentation
After=network.target

[Service]
ExecStart=/etc/redis/redis-server /etc/redis/redis_7000.conf
ExecStop=/etc/redis/redis-cli -p 7000 shutdown
Restart=always
LimitNOFILE=65000
NoNewPrivileges=yes
Type=notify
UMask=0077
User=redis
Group=redis

[Install]
WantedBy=multi-user.target 

and it works with issues. It start Redis instance but fails with timeout

root@ubnt:/home/test11# ps -aux | grep redis
redis    30468  0.4  0.5  64320  5616 ?        Ssl  11:15   0:00 /etc/redis/redis-server 127.0.0.1:7000 [cluster]

Feb 29 11:09:55 ubnt systemd[1]: redis_server_7000.service: Start operation timed out. Terminating.
Feb 29 11:09:55 ubnt systemd[1]: redis_server_7000.service: Failed with result 'timeout'.
Feb 29 11:09:55 ubnt systemd[1]: Failed to start Redis data structure server - instance 7000.

root@ubnt:/home/test11# systemctl status redis_server_7000.service
● redis_server_7000.service - Redis data structure server - instance 7000
   Loaded: loaded (/lib/systemd/system/redis_server_7000.service; enabled; vendor preset: enabled)
   Active: activating (start) since Sat 2020-02-29 11:28:03 UTC; 12s ago
     Docs: https://redis.io/documentation
 Main PID: 30679 (redis-server)
    Tasks: 5 (limit: 1108)
   CGroup: /system.slice/redis_server_7000.service
           └─30679 /etc/redis/redis-server 127.0.0.1:7000 [cluster]

Feb 29 11:28:03 ubnt systemd[1]: Starting Redis data structure server - instance 7000...

Redis config file:

root@ubnt:/home/test11# cat /etc/redis/redis_7000.conf
#daemonize yes
maxmemory 2G
maxmemory-policy volatile-ttl
dir /var/lib/redis_7000
loglevel notice
supervised systemd
tcp-backlog 1000
bind 127.0.0.1
pidfile /var/run/redis_7000.pid
logfile /var/log/redis/redis-server-7000.log
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

I checked types of systemd servise:

I checked types of systemd units simple - A long-running process that does not background its self and stays attached to the shell.
    forking - A typical daemon that forks itself detaching it from the process that ran it, effectively backgrounding itself.
    oneshot - A short-lived process that is expected to exit.
    dbus - Like simple, but notification of processes startup finishing is sent over dbus.
    notify - Like simple, but notification of processes startup finishing is sent over inotify.
    idle - Like simple, but the binary is started after the job has been dispatched.

and I used notify type but it looks like redis started but didn't sent notifications to systemd.

So my questions are: -How to change service file to start one instance properly? -Is this possible to run 3 Redis instances from one service file? Or it would be better to create 3 separate files?

0

You must log in to answer this question.

Browse other questions tagged .