Running multiple Redis instances on the same server.

Setting up multiple Redis instances on the same server is pretty easy, but if you want to be able to easily start/stop and restart instances, you’ll need to play with the init scripts of redis-server.

I needed this to be able to offer Redis buckets to different customers on a shared platform.

This is how I managed to set up multiple instances on the same server.
Since installing redis-server is out of the scope of this article, I’ll only explain what I did to manage multiple Redis Servers.

* Setting up a new INIT script:

* Paste this into the new redis-server init script:

Once that is done, we need to add multiple config files for our different buckets:

And enter some config settings looking like this:

Creating new instances is easily done by copying this initial conf file and adjusting the params (port, name, pid, savefilename, password,…)

Now, if you want to start/stop or restart all redis instances at the same time, this can be done with the normal service command:

The new init script we create above, will simply index all config instances from /etc/redis/servers and manage those 1 at a time.

Or, if you only want to manage 1 instance at a time, just do something like this for example:

which will restart only the instance running for website

Since we use this on a shared environment, we have a provisioning system in place, where our customers can change some settings

This article is based on: Robofirm: Setting up multiple redis instances, but I had to change some configuration to make it work. Anyway, a big thanks to Kirk Madera for pointing me in the right direction!

2 thoughts on “Running multiple Redis instances on the same server.”

  1. Thank you for this article. I followed the instructions carefully and configured two Redis instances which start, stop, and restarts successfully. However, both of them are running from the same port 6379. The second port for the second instance, 6380, is not working. I checked netstat which only returned 6379. telnet on 6380 does not connect.

    Please is there any bug on any of the scripts which could cause this? Thank you.

    1. Hi there,

      Did you change the port number to something else than 6379?
      #Which Port to use for this instance
      port 5033

Leave a Reply

Your email address will not be published. Required fields are marked *