server configuration command lines on a monitor
Image: ronstik/Adobe Stock

Redis is an open-source, in-memory key-value store that can be used as a powerful database server. Redis supports numerous data structures, such as strings, hashes, lists, sets, bitmaps, sorted sets and much more. And given that Redis stores everything in-memory, it’s blazingly fast. The one caveat to this is you’ll want to install it on a server with a fairly large amount of RAM.

What I’m going to do here is walk you through the process of getting a single node Redis server up and running. In a later tutorial, we’ll discuss setting up a Redis cluster, so you can gain high availability with your server.

Until then, let’s get that single instance server up and running.

SEE: Hiring Kit: Database engineer (TechRepublic Premium)

What you’ll need

I’ll be demonstrating with Ubuntu Server 22.04, so you’ll need an instance of that Linux distribution up and running—although you can install it on 20.04 as well—and a user with sudo privileges.

That’s it. Let’s get to work.

How to install Redis

The first thing you’ll want to do is update Ubuntu Server with the commands:

sudo apt-get update
sudo apt-get upgrade -y

If the kernel gets upgraded in the process, you’ll need to restart the machine, so the changes take effect.

Once the upgrade is complete, install Redis with:

sudo apt-get install redis-server -y

The installation shouldn’t take too much time. Before you start/enable the server, let’s take care of a couple of configurations.

How to configure Redis

Open the Redis configuration file with the command:

sudo nano /etc/redis/redis.conf

Look for the following line:

bind ::1

We’ll configure Redis, so it listens on the IP address of the hosting server by changing that line to (editing it to reflect your server’s IP address):

bind ::1

Next, look for the line:

supervised no

Change that line to:

supervised systemd

Save and close the file.

How to start and enable Redis

Redis is probably already running, so what we’ll do is restart it, so the configuration changes take effect, with the command:

sudo systemctl restart redis-server

Next, enable Redis, so it starts at boot with the command:

sudo systemctl enable redis-server

Verify that Redis is running with the command:

sudo systemctl status redis-server

Test to make sure Redis is listening with the command:

redis-cli -h -p 6397

You should now find yourself on the Redis console. Test it with:

ping “Hello, TechRepublic!”

You should see “Hello, TechRepublic!” in the output.

Congratulations, you now have a Redis in-memory database server up and running. Next time around we’ll configure this for a cluster and join a node. Until then, you can start learning your way around the Redis command-line interface (CLI) by reading the official documentation.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Learn more with The Mastering Linux Development Bundle from TechRepublic Academy.