How to run multiple redis instances with systemd

6,331

Like suggested by Michael Hampton, I checked the syslog and found that:

Oct 10 11:33:46 server101 redis-server[1947]: *** FATAL CONFIG FILE ERROR ***
Oct 10 11:33:46 server101 redis-server[1947]: Reading the configuration file, at line 5
Oct 10 11:33:46 server101 redis-server[1947]: >>> 'logfile /var/log/redis/redis-server-2.log'
Oct 10 11:33:46 server101 redis-server[1947]: Can't open the log file: Permission denied

So I just had to do this to fix the issue:

chown redis:redis /var/log/redis/redis-server-2.log
Share:
6,331

Related videos on Youtube

Nicolas BADIA
Author by

Nicolas BADIA

Sproutcore core team member working on GestiXi.

Updated on September 18, 2022

Comments

  • Nicolas BADIA
    Nicolas BADIA over 1 year

    I recently moved to Debian 8 "Jessie" which now use systemd and I can't find a way to run multiple redis instances.

    I found out there is a /lib/systemd/system/redis-server.service file to start redis-server on reboot. So I created a new file call /lib/systemd/system/redis-server-2.service with this content:

    [Unit]
    Description=Advanced key-value store
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/usr/bin/redis-server /etc/redis/redis-2.conf
    TimeoutStopSec=0
    Restart=always
    User=redis
    Group=redis
    
    [Install]
    WantedBy=multi-user.target
    

    But when I try to start the service like this: service redis-server-2 start I get this error:

    Job for redis-server-2.service failed. See 'systemctl status redis-server-2.service' and 'journalctl -xn' for details.
    

    And systemctl status redis-server-2.service give me:

    ● redis-server-2.service - Advanced key-value store
       Loaded: loaded (/lib/systemd/system/redis-server-2.service; disabled)
       Active: failed (Result: start-limit) since Sat 2015-10-10 11:09:54 CEST; 33s ago
      Process: 2473 ExecStart=/usr/bin/redis-server /etc/redis/redis-2.conf (code=exited, status=1/FAILURE)
     Main PID: 2371 (code=exited, status=1/FAILURE)
    
    Oct 10 11:09:54 server101 systemd[1]: redis-server-2.service: control process exited, code=exited status=1
    Oct 10 11:09:54 server101 systemd[1]: Failed to start Advanced key-value store.
    Oct 10 11:09:54 server101 systemd[1]: Unit redis-server-2.service entered failed state.
    Oct 10 11:09:54 server101 systemd[1]: redis-server-2.service start request repeated too quickly, refusing to start.
    Oct 10 11:09:54 server101 systemd[1]: Failed to start Advanced key-value store.
    Oct 10 11:09:54 server101 systemd[1]: Unit redis-server-2.service entered failed state.
    

    which is not really helping me.

    But if I run /usr/bin/redis-server /etc/redis/redis-2.conf my redis instance start correctly.

    So any idea why systemd don't what to start this instance by itself ?

    Thanks in advance for the help.

    • Michael Hampton
      Michael Hampton over 8 years
      Check your logs.
    • Nicolas BADIA
      Nicolas BADIA over 8 years
      Damn, the answer was indeed in the syslog... thanks!