Конфиг при инсталяции Redis
1) В redis.config:
ставим supervised systemd. (demonize должен быть no)
меняем dbfilename dump.rdb на dbfilename <имя нашего проекта>.rdb (=база.rdb)
меняем dir./ на <директория нашего проекта>
2) Создаем unit-файл: sudo nano /etc/systemd/system/redis.service
[Unit] Description=Redis In-Memory Data Store After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
Type=notify
UMask=0027
[Install]
WantedBy=multi-user.target
2') Выполняем: sudo systemctl daemon-reload
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.
Встречал, но не проверял, еще вариант:
[Unit] Description=Redis After=syslog.target [Service] ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf RestartSec=5s Restart=on-success [Install] WantedBy=multi-user.target
Make sure that redis.conf has demonize no (the default; systemd will take care of 'daemonizing'). The Restart=on-success in the service file means that the daemon will be auto-restarted only when it exited cleanly (so that 'bad' problems are not masked; see doc).
3) Создаем группу и пользователя. Как вариант, таким способом:
sudo adduser --system --group --no-create-home redis
3) Пользователь redis должен иметь права на чтение redis.conf, на чтение
и запись база.rdb и на чтение и запись директории, где находится база.rdb
4) Запуск Redis-сервера:
sudo systemctl start redis
5 ) Запуск Redis при включении системы:
sudo systemctl enable redis
sdmrnv, 2019-06-04 [0.727ms, r]