Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example files for running Redis on CentOS 7 (after manual install)
/var/lib/redis/logs/redis.log {
rotate 14
Description=Redis Server
ExecStartPre=/bin/mkdir -p /var/lib/redis/logs
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=/bin/kill -15 $MAINPID
<?xml version="1.0" encoding="utf-8"?>
<short>Redis Server</short>
<description>Redis Datastore Server</description>
<port protocol="tcp" port="6379"/>
Copy link

nexdrew commented Apr 30, 2015


This is a systemd unit (service) config file. After you add this file, make sure to set proper file permissions via chmod 664 /etc/systemd/system/redis-server.service. Then you can use systemd to run Redis as a managed service, e.g.

$ systemctl daemon-reload
$ systemctl start redis-server
$ systemctl enable redis-server

This config has the following assumptions:

  • You have manually downloaded, built from source (via make), and installed (via make install) Redis, and the redis-server program was installed under /usr/local/bin
  • You have created (or copied) your desired Redis config at /etc/redis.conf
  • You want to run Redis as the redis user, which has write access to /var/lib/redis
  • Redis will be writing its log file under /var/lib/redis/logs (defined in /etc/redis.conf)
  • You want systemd to restart Redis on failures


This is a firewalld service config file. It lets you open the firewall for Redis as a service instead of by port and protocol directly. It assumes the following:

  • You want remote access to Redis via TCP
  • Redis is listening on port 6379 (default)
  • Redis is bound to all network interfaces (also default)

After you add this file, you can open remote access to Redis in firewalld via something like the following:

$ firewall-cmd --permanent --zone=public --add-service=redis-server
$ firewall-cmd --reload


This is a logrotate config file that assumes the following:

  • logrotate is installed and running as a cron job
  • Redis writes its log file at /var/lib/redis/logs/redis.log
  • You want to rotate redis.log each day and keep the last 14 days worth of logs

Copy link

govindkailas commented Feb 24, 2017

ExecStop=/bin/kill -15 $MAINPID
Where is MAINPID defined??

Copy link

jph commented Mar 8, 2017

Copy link

beuel66 commented May 15, 2018

Is there any advice regarding the Redis daemonize option within a systemd service? The Redis Administration page simply says "Use daemonize no when run under daemontools", which is default. Does this refer to any kind of startup system or just this specific tool set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment