How to install the Redis in-memory database server on Ubuntu 22.04

Date:

Share:


Jack Wallen walks you through installing and configuring a single-node Redis server for your in-memory database server needs.

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 127.0.0.1 ::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 192.168.1.22 ::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 192.168.1.22 -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.



Source link

━ more like this

Samsung QN90D 98-inch review: solid and classy, but worth the price tag? | Tech Reader

Samsung QN90D 98-inch QLED TV “The QN90D series is excellent, but the 98-inch model fell apart for us.” Pros Excellent color accuracy Deep blacks, impressive contrast Solid on-board...

Space station crew had an amazing stroke of luck during Starship launch | Tech Reader

NASA astronaut and current space station inhabitant Don Pettit seems to have the luck of the stars. During SpaceX’s sixth test flight of...

3 great dramas on Amazon Prime Video you need to watch in November 2024 | Tech Reader

Never let it be said that Amazon Prime Video isn’t stacked with great dramas. Amazon wasn’t content to only have the great MGM...

Get ready for AI-dubbed YouTube videos | Tech Reader

YouTube has reportedly started rolling out a new AI-empowered translation feature for its content creators, one that will automatically redub a video’s contents...

ChatGPT’s latest model may be a regression in performance | Tech Reader

According to a new report from Artificial Analysis, OpenAI’s flagship large language model for ChatGPT, GPT-4o, has significantly regressed in recent weeks, putting...
spot_img