Run multiple Redis servers on Ubuntu

Updated . Posted . Visible to the public. Deprecated.

This was done with an older version of Ubuntu and probably wont work anymore.

This is a way to run multiple redis server on one ubuntu server.

These steps you have to do only once:

  • Adjust init script

Change some Variables.
From this:

DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pid

to this:

NAME=`basename ${0}`
DAEMON_ARGS=/etc/redis/${NAME}.conf
DESC=${NAME}
PIDFILE=/var/run/${NAME}.pid
  • Move redis configuration
    ^
    mv /etc/redis/redis.conf /etc/redis/redis-server.conf

These steps you have to do for every new redis server:

  • Copy configuration:
    ^
    cp /etc/redis/redis-server.conf /etc/redis/redis-server2.conf

  • In the /etc/redis/redis-server2.conf you have to change at least this options:
    ^
    pidfile /var/run/redis-server.pid
    port 6379
    logfile /var/log/redis/redis-server.log
    dir /var/lib/redis

to this for example:

pidfile /var/run/redis-server2.pid
port 6380
logfile /var/log/redis/redis-server2.log
dir /var/lib/redis2
  • Symlink the init script:
    ^
    ln -s /etc/init.d/redis-server /etc/init.d/redis-server2

  • Create working directory:
    ^
    mkdir /var/lib/redis2; chown redis.redis /var/lib/redis2;

  • Start server and add init script to system startup
    ^
    /etc/init.d/redis-server2 start
    update-rc.d redis-server2 defaults

Kim Klotz
Last edit
Kim Klotz
Keywords
ops
License
Source code in this card is licensed under the MIT License.