6

I have installed redis on an ubuntu 16.04 machine and if I run /usr/local/bin/redis-server /etc/redis/cluster/7000/redis.conf it starts up and I can connect to it without issues.

However I want to start it using systemctl start redis, so I have created the following file at /etc/systemd/system/redis7000.service

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/cluster/7000/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

and the redis config has supervised systemd set

which I think looks good, but I get the following errors:

Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: Started Redis In-Memory Data Store.
Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=21661, just started
Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # Configuration loaded
Jan 19 14:54:27 ip-172-31-42-18 redis-server[21661]: 21661:C 19 Jan 14:54:27.680 # systemd supervision requested, but NOTIFY_SOCKET not found
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Main process exited, code=exited, status=1/FAILURE
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Unit entered failed state.
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Failed with result 'exit-code'.
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: redis7000.service: Service hold-off time over, scheduling restart.
Jan 19 14:54:27 ip-172-31-42-18 systemd[1]: Stopped Redis In-Memory Data Store.

And I am not even sure what this means, so could someone guide me in the right direction?

9

To run redis under systemd, you need to set supervised systemd.

See the configuration file:

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
#   supervised no      - no supervision interaction
#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
#   supervised auto    - detect upstart or systemd method based on
#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
#       They do not enable continuous liveness pings back to your supervisor.
supervised no

Needs to be changed to:

supervised systemd

You can also pass this on the command line, which overrides the setting in redis.conf. Red Hat based systems do this. This also allows for running the same redis instance manually or from systemd without changing the config file.

ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd

In addition, you also need to tell systemd that redis will be operating in this mode by setting Type=notify in the [Service] section.

3

As I cannot add a comment due to lack of reputation, please take this as a comment to Michael Hampston's answer.

When modifying the systemd service file, use the command systemctl edit redis-server to create an override. In the resulting edit window, type the following:

[Service]
Type=notify

Save and exit then finish the installation apt install -f.

If you modify the service in /lib/systemd/system, you'll lose those edits on next update.

See: modify systemd unit file without altering upstream unit file

PS: This question saved me from having to scratch my head for too long as I just encountered the issue.

0

One of the way to debug this is copy ExecStart line and execute on terminal you will get the error frequently. So it will give you more hints to debug and solve.

I have done the same and got exact error and got it solved.

  • 1
    The journal output already gives hints on what the problem may be: " NOTIFY_SOCKET not found" Do you have further info on this Redis problem? – AndreasM Mar 25 at 13:10
  • 1
    Yes journalctl -u service-name also gives output. – Viraj.Hadoop Mar 25 at 13:29
  • journalctl -u redis gave info about the error in my case *** FATAL CONFIG FILE ERROR *** Reading the configuration file, at line 147 >>> 'supervised systemd #signal systemd' Bad directive or wrong number of arguments which was to remove the commented out part after systemd – Kalyan Raghu Apr 1 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.