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

Homes evacuated as ‘radioactive’ material found in bags in Hammersmith West London – London Business News | Londonlovesbusiness.com

Around a dozen homes have been evacuated after workers found “radioactive” materials in bin bags close to a primary school...

The best iPhone 16 and iPhone 16 Pro cases for 2024

If you’ve just picked up one of the latest Apple iPhone 16 models, you may be wondering what the best way is to...

Euro crashes to the lowest levels seen since the energy crisis of 2022 – London Business News | Londonlovesbusiness.com

The composite eurozone PMI slumped to 48.1, thanks to an unexpected dive to 49.2 in the services sector that has...

UK warns Ukraine frontline is ‘less stable’ and there has been ‘very clear escalation from Putin’ – London Business News | Londonlovesbusiness.com

The British Defence Secretary has warned the frontline in Ukraine is now “less stable” than it ever has been since...

Nearly one in three business owners plan redundancies as debt defaults loom – London Business News | Londonlovesbusiness.com

Newly published research taking the temperature of 500 business owners has revealed that nearly one in three firms surveyed (31%)...
spot_img