Redis is an open-source in-memory key-value data structure store that can be used as a cache server, message broker, etc. We can use a number of data types with redis like strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indexes.

It also provides a number of features like,

  • Replication
  • data persistence
  • LRU eviction
  • High availability using sentinel
  • Publish / Subscribe support for data
  • Keys with limited TTL
  • Automatic Failover
  • LUA scripting, etc

In this tutorial, we will learn to install Redis on Ubuntu servers. So let’s get going,


Install Redis on Ubuntu

Redis server packages are available on default Ubuntu repositories, so we are not required to install any official or 3rd party repos on the system. So just perform a repos update,

$ sudo apt update

& then install redis on ubuntu with the following command,

$ sudo apt install redis

Once the redis has been installed on server, we can start the server with the following command,

$ sudo systemctl start redis


Testing Redis installation

We can now check if the redis has been installed by running the following command,

$ redis-cli –version

We can also connect to the installed redis server with the following command,

$ redis-cli

then check the response to ping command for redis,

redis > PING

In response, we should get PONG as output.


Allowing remote connections to redis installation

By default, we can only connect to redis server from the local server. To allow connections to redis installation from remote machines, we need to make changes to redis configuration file,

$ sudo vi /etc/redis/redis.conf

then look for section that says ‘bind 127.0.0.1’ & change it

bind 0.0.0.0 

to allow connections from all remote servers or we can also mention single or multiple IP addresses to allow connections from those servers only, like

bind 10.10.10.10 192.168.1.10

here, connections will be allowed from two machines with IP addresses 10.10.10.10 & from 192.168.1.10.

Once the changes have been made, we need to restart the redis service to apply changes,

$ sudo systemctl restart redis

This completes our tutorial on how to install Redis on Ubuntu. In our future tutorials, we will learn to create MASTER-SLAVE replication for redis & also how we can secure the redis installation. If you have any doubts or questions related to this tutorial, you can reach to us using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.