D
D
danforth2017-12-08 12:33:25
linux
danforth, 2017-12-08 12:33:25

How to make Redis start with the server?

After rebooting the VPS, Redis for some reason does not start. Redis itself works in unixsocket mode, here is its config:
redis.conf: https://pastebin.com/pzsC3PSq
service redis status:

● redis.service - Redis In-Memory Data Store
   Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Fri 2017-12-08 09:17:49 UTC; 1min 47s ago
  Process: 2646 ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (code=exited, status=1/FAILURE)
 Main PID: 2523 (code=exited, status=1/FAILURE)

Dec 08 09:17:49 danforth systemd[1]: redis.service: Control process exited, code=exited status=1
Dec 08 09:17:49 danforth systemd[1]: Failed to start Redis In-Memory Data Store.
Dec 08 09:17:49 danforth systemd[1]: redis.service: Unit entered failed state.
Dec 08 09:17:49 danforth systemd[1]: redis.service: Failed with result 'exit-code'.
Dec 08 09:17:49 danforth systemd[1]: redis.service: Service hold-off time over, scheduling restart.
Dec 08 09:17:49 danforth systemd[1]: Stopped Redis In-Memory Data Store.
Dec 08 09:17:49 danforth systemd[1]: redis.service: Start request repeated too quickly.
Dec 08 09:17:49 danforth systemd[1]: Failed to start Redis In-Memory Data Store.

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

[Service]
Type=forking # <--- изначально было без этой строки, но на stackoverflow был подобный вопрос, и посоветовали добавить, однако мне это никак не помогло
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

sudo journalctl -xe
Dec 08 09:26:27 danforth redis-server[3071]: 3071:M 08 Dec 09:26:27.353 # Opening Unix socket: bind: No such file or directory
Dec 08 09:26:27 danforth systemd[1]: redis.service: Control process exited, code=exited status=1

Did I understand correctly that it does not start due to the absence of the /var/run/redis/ folder? There I should have a redis.sock file, as I indicated in the config.
Question: how to make that when restarting the server, Redis itself creates this folder?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Chernykh, 2017-12-08
@danforth

in cron, your script should run on the @reboot event.
in the
mkdir /var/run/redis script and the required chown/chmod to this folder.

V
Vitaliy Orlov, 2017-12-08
@orlov0562

if it starts like this:
then add it to autoload
if it doesn’t start after start, then find out why, autoload has nothing to do with it

A
Andrey Stepanov, 2017-12-08
@leoykt

Maybe there are not enough rights to write the log file, check the permissions, try setting 700 for the log file
chmod 700 /var/log/redis/redis-server.log

R
Redaicd, 2017-12-09
@Redaicd

This is because /var/run/ you have tmpfs and all content naturally disappears after a reboot. Correct the path from /var/run/redis to /var/run in the redis config and everything will work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question