0

Redis fails to start every time I start our CentOS 7/openvas server. After the server boots up I can manually start redis without any issues using systemctl start redis.service.

Below are the relevant parts from journalctl

Jan 29 06:29:28 openvas01 systemd[1]: Reached target Network is Online.
Jan 29 06:29:28 openvas01 systemd[1]: Starting Network is Online.
Jan 29 06:29:28 openvas01 systemd[1]: Started Azure Linux Agent.
Jan 29 06:29:28 openvas01 systemd[853]: Failed at step RUNTIME_DIRECTORY spawning /usr/bin/redis-server: File exists
Jan 29 06:29:28 openvas01 systemd[1]: Starting Azure Linux Agent...
Jan 29 06:29:28 openvas01 systemd[1]: Started DNS caching server..
Jan 29 06:29:28 openvas01 systemd[1]: Starting DNS caching server....
Jan 29 06:29:28 openvas01 systemd[1]: redis.service: main process exited, code=exited, status=233/RUNTIME_DIRECTORY
Jan 29 06:29:28 openvas01 systemd[860]: Failed at step RUNTIME_DIRECTORY spawning /usr/libexec/redis-shutdown: File exists
Jan 29 06:29:28 openvas01 systemd[1]: redis.service: control process exited, code=exited status=233
Jan 29 06:29:28 openvas01 systemd[1]: Failed to start Redis persistent key-value database.
Jan 29 06:29:28 openvas01 systemd[1]: Unit redis.service entered failed state.
Jan 29 06:29:28 openvas01 systemd[1]: redis.service failed.

I can't tell which file it is complaining about existing already. The /var/log/redis/redis.log doesn't mention anything about this startup issue so I am thinking that this is related to systemd.

I searched online and didn't find any obvious solutions. The service is not set to start as a daemon and I have supervised systemd in the redis config file.

Any ideas?

thebitguru
  • 136
  • 1
  • 5

4 Answers4

1

After some more troubleshooting, I figured out that the /var/run/redis directory was being created by some other process and not the redis systemd service. Further troubleshooting revealed that our server admin had unexpectedly created /etc/tmpfiles.d/redis.conf that was creating the /var/run/redis directory before the service. Deleting this file, which only had this directory in it, addressed the problem.

thebitguru
  • 136
  • 1
  • 5
  • Had a similar issue with the centos/systemd docker image. /var/run/redis already exists, but redis is not installed according to yum. Solution was to rm -rf /var/run/redis then to yum install redis + systemctl enable redis.service – Vigrond Apr 09 '19 at 02:28
0

TL;DR: Disable the Redis service, reset, reload, then restart and finally re-enable the service.

I just had the same issue on CentOS7.9 (Virtuzzo) after Redis was updated from Redis6 to Redis7. I have several instances with 1 or 2 for each individual website but I didn't realise that only the original redis.service had been down for almost a week until I attempted to restart it after using the status command:

systemctl status -l redis.service

redis.service - Redis persistent key-value database
Loaded: loaded
(/usr/lib/systemd/system/redis.service;
enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
       └─limit.conf
Active: failed (Result: exit-code) since Thu 2022-05-05 23:02:50 BST; 28s ago
Process: 6425 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf --daemonize no --supervised systemd (code=exited,
status=233/RUNTIME_DIRECTORY)
Main PID: 6425 (code=exited,
status=233/RUNTIME_DIRECTORY)

Restarting my instances (redis2, redis3 etc) worked all except for this one.

Failed at step RUNTIME_DIRECTORY spawning /usr/bin/redis-server: File exists
redis.service: main process exited, code=exited, status=233/RUNTIME_DIRECTORY
Failed to start Redis persistent key-value database.
Unit redis.service entered failed state.
redis.service failed.

What worked for me without having to delete any files or folders was to disable the redis.service, then use the reset failed services command, reload the SystemD daemon, start the redis.service (now worked 1st time), then re-enable it so that it should restart automatically in future.

These were the commands, enter each line in turn...

systemctl disable redis
systemctl reset-failed
systemctl daemon-reload
systemctl start redis
systemctl enable redis



Outputs message: Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.


systemctl status -l redis.service

Outputs message: redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled;
vendor preset: disabled)

Drop-In: /etc/systemd/system/redis.service.d
       └─limit.conf
Active: active (running) since Thu 2022-05-05 23:08:03 BST; 31s ago
Main PID: 6899 (redis-server)
Status: "Ready to accept connections"
CGroup: /system.slice/redis.service
       └─6899 /usr/bin/redis-server
127.0.0.1:6379 /var/lib/redis/redis.sock 6379  /etc/redis/redis.conf
Starting Redis persistent key-value database...
Started Redis persistent key-value database.
0

This page led me to the answer. In my case elasticsearch did not start with errors: (code=exited, status=233/RUNTIME_DIRECTORY) Failed at step RUNTIME_DIRECTORY spawning /usr/share/elasticsearch/bin/systemd-entrypoint: File exists

grep -R elasticsearch /etc/ | grep var | grep run found old config that manually created mkdir /var/run/elasticsearch inside /etc/rc.local So when service tried to start folder was already there.

Igors
  • 1
-1

Try add to config file of systemd service

[Service]
Type=forking