Jack Wallen walks you through installing and configuring a single node Redis server for your in-memory database server needs.
Redis is an open source in-memory key-value store that can be used as a powerful database server. Redis supports many data structures, such as strings, hashes, lists, sets, bitmaps, ordered sets, and more. And since Redis stores everything in memory, it’s blazingly fast. The only caveat to this is that 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 look at setting up a Redis cluster, so you can get 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 will need
I’ll be demoing with Ubuntu Server 22.04, so you’ll need a working instance of that Linux distribution, although you can also install it on 20.04, and a user with sudo privileges.
That is all. 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 is updated in the process, you will need to reboot the machine for the changes to take effect.
Once the upgrade is complete, install Redis with:
sudo apt-get install redis-server -y
Installation shouldn’t take too long. Before we start/enable the server, let’s take care of a couple of settings.
How to configure Redis
Open the Redis configuration file with the command:
sudo nano /etc/redis/redis.conf
Look for the following line:
We’ll configure Redis to listen on the IP address of the hosting server by changing that line to (editing it to reflect your server’s IP address):
Next, find the line:
Change that line to:
Save and close the file.
How to start and enable Redis
Redis is probably already running, so what we will do is restart it, so that the configuration changes take effect, with the command:
sudo systemctl restart redis-server
Then enable Redis, so it starts on boot with the command:
sudo systemctl enable redis-server
Check 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 192.168.1.22 -p 6397
You should now be in the Redis console. Try it with:
ping “Hello TechRepublic!”
You should see “Hello TechRepublic!” at the exit.
Congratulations, you now have a working Redis in-memory database server. Next time we will configure this for a cluster and join a node. Until then, you can start getting familiar with the Redis command line interface (CLI) by reading the official documentation.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube to get the latest tech tips for business professionals from Jack Wallen.