Run multiple Redis Instances on your Machine

Dileep
2 min readMar 4, 2021

--

There are multiple methods to install Redis. we are discussing here the simplest one.

Funda : Main idea is to run Redis-server on two different ports on same instance.

Installation

  • From Source Code
$ wget https://download.redis.io/releases/redis-6.2.1.tar.gz
$ tar xzf redis-6.2.1.tar.gz
$ cd redis-6.2.1
$ make
  • This installation process already explain on Redis webpage(https://redis.io/download)
  • You can choose Redis version which you want to use by replacing 6.2.1 with your version which you want to download in this url (wget https://download.redis.io/releases/redis-6.2.1.tar.gz)
  • make command compiles your Redis project and generate binaries.
  • Rename your Redis folder redis-6.2.1 to redis1 (easy to understand)

Start your First Redis Server

$ ./redis1/src/redis-server redis.conf --daemonize yes
  • redis.conf file will be present in your Redis folder (redis1)
  • Run above command to start your first Redis server.
  • By Default Redis run of port 6379. (so now your one instance of Redis running on port 6379.
  • You can connect with your redis instance with redis-cli ./redis1/src/redis-cli -p 6379
  • Comment out bind 127.0.0.1 in redis.conf file, if you want to expose your Redis server publically.

Start your Second Redis Server

  • Copy-paste your Redis folder (redis1) into another folder redis2.
  • go to redis2 folder and do the below changes in your redis.conf file.
pidfile /var/run/redis_6380.pid
port 6380
# bind 127.0.0.1 (if you want to run redis publically)
  • what we are doing here is we are changing port number to (6380) and file path to store Redis process-id (/var/run/redis_6380.pid)
$ ./redis2/src/redis-server redis.conf --daemonize yes
  • Run above command to start your second server.
  • You can connect with your second redis instance with redis-cli ./redis2/src/redis-cli -p 6380
  • Run ps aux | grep redis command to verify

Congratulation now your two Redis instances running on two different ports on same instance.

This is one method to run multiple instances of Redis server.

If you already installed Redis server by (apt-get install redis) command, then then you can follow link(https://gist.github.com/inecmc/f40ca0ee622e86999d9aa016c1b15e8c) to run multiple Redis instances.

Thanks for reading!

--

--

Dileep

Passionate about coding, cyber security | Software Engineer | IIT Roorkee.