DEV Community

Cover image for Installing and setting up Redis
Dev Sharma
Dev Sharma

Posted on • Originally published at blog.devsharma.live

Installing and setting up Redis

Redis

Redis is an in-memory data structure store, used as a database, cache, and message broker that allows for incredibly fast read and write ops.

We are going to see 3 ways of setting up Redis. I will be using Ubuntu 20.04 for this tutorial.

1. Installing Redis Locally

Installing docker on

sudo apt update
sudo apt install redis-server
Enter fullscreen mode Exit fullscreen mode

You need to configure a couple of thing after this, use any editor and change the supervised directive to systemd.

sudo nano /etc/redis/redis.conf
Enter fullscreen mode Exit fullscreen mode

Screenshot from 2021-05-01 06-36-49.png

You can also set your redis password, since Redis is pretty fast you need a very strong password. Use the following command to generate one.

openssl rand 60 | openssl base64 -A
Enter fullscreen mode Exit fullscreen mode

image.png

Save the files and restart the Redis service to check if its running.

sudo systemctl restart redis.service
sudo systemctl status redis
Enter fullscreen mode Exit fullscreen mode

Screenshot from 2021-05-01 06-40-32.png

2. Use a Docker Image

Pull the Redis docker image

docker pull redis
Enter fullscreen mode Exit fullscreen mode

And start a redis instance

docker run --name some-redis -d redis
Enter fullscreen mode Exit fullscreen mode

3. Managed Redis Labs instance

You can also use a free tier instance from Redis Labs.

Create an account and select your favourite cloud provider.
Redis Labs set up initial screen

I'm gonna select the 30 MB free tier, that's more than enough for our project.

Redis Labs select subscription

You will be directed to set up a database:
A few things to consider here:

  • Type of eviction policy (I highly recommend setting up an eviction policy).
  • If you want to use a Redis module, you can set it up here.

Setting up a database on
I have selected the allkeys-lru eviction policy and no modules.

This blog is part of a series, in the next part, we will set up our node server to cache data with Redis. You can continue with the series using any of the Redis setups mentioned in this blog.

Feel free to reach out to me on Twitter @cryptus_neoxys and connect with me on LinkedIn.

Refs

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04

https://redis.io/download

Top comments (0)