skip to Main Content

Is it possible to host 2 redis databases on the same linux server?

The reason why there is 2 redis dbs, is because the client we support Redis for has two environments. So each of the redis dbs have different data on.

I know that I can build another linux box and host it from there too, but the company wants to save costs.

This is kind of the flow I need.

Environment 1 -> Redis Server -> Redis db 1
Environment 2 -> Redis Server -> Redis db 2

The only dilemma is, how do you distinguish what database you want each environment to use?

3

Answers


  1. You can install docker and operate with two redis instances at the same time, see https://github.com/ThiagoBarradas/multi-redis-docker

    They would run on the same server and you would be able to communicate with both.

    Login or Signup to reply.
  2. Not sure I understand the issue, but you can run two (or more) Redis instances on a single machine by running each instance on a different port.

    So you would copy your normal redis.conf that runs on port 6379 and make a new redis.conf file, maybe called redis-6378.conf and in there you would have some lines like this:

    port 6378
    dbfilename dump-6378.rdb
    pidfile /var/run/redis/redis-server-6378.pid
    logfile /var/log/redis/redis-server-6378.log
    

    Then, when you want to connect to the instance on port 6378, you just specify the port number:

    redis-cli -p 6378
    
    Login or Signup to reply.
  3. Yes, you can! The two instances do need seperate ports however, and also different storage backends. Otherwise the data between them might be shared, which might or moght not be what you are looking for. For loadbalancing please see this question

    The two redis instances should run without conflicts.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search