How to Install Redis on Ubuntu 22.04 LTS Jammy

Let’s learn the steps to install the Redis database server on Ubuntu 22.04 LTS Jammy JellyFish using the command terminal.

Redis is a “Key-Value Store” (or KV Store for short) Database. Here, the data is always stored in the form of key-value pairs. So you can think of the database in such a way that there is only one table with two columns, namely one column for the key and one for the value. However, since Redis knows different data types for the values, the developers prefer to refer to the database as a “data structure store”.

Compared to other databases such as MySQL, PostgreSQL, or CouchDB, Redis is extremely fast. Even on reasonably up-to-date desktop computers, the database manages over 100,000 (simple) writes and over 80,000 (simple) reads per second. This is primarily because the database is kept completely in RAM and is only written to the hard disk after a certain time or a certain number of changed values. Furthermore, Redis masters replication and is also cluster-capable since version 3.0.

Redis is designed as a server-client architecture, i.e. the Redis server runs as a service (in the background) and can then be queried by the client. Furthermore, the Redis installation also includes a command line, which can be used to use the full range of functions of the server.

It is also important that with Redis keys are “everything” and values are “nothing”. This means that all queries always refer to a key and return a value.

Steps to install Redis on Ubuntu 22.04 LTS Linux

This guide can be used for other versions of Ubuntu Linux such as 20.04 including other similar OS let’s say Debian, Linux Mint, POP_OS, and more…

1. Refresh the APT package Index

Perform the system update command that will refresh the APT package manager package index cache as well as install the latest available security updates.

sudo apt update && sudo apt upgrade

 

2. Install Redis on Ubuntu 22.04

Redis is an open-source database server that is available to install using the default system repository of Ubuntu. Hence, we don’t need to add any third-party repository.

sudo apt install redis-server

To check the installed version, use:

redis-server -v

 

3. Check the service status

After the installation let’s check whether the Redis-server service is running in the background without any error.

sudo systemctl restart redis

For status:

sudo systemctl status redis

Redis server install Ubuntu 22.04

 

4. Use Redis-CLI to confirm server connection

To confirm our system can connect to the Redis server, we can use a command-line utility called – redis-tool that can be used to send commands to Redis… Redis instance running on localhost at port 6379.   Here are the commands to follow:

redis-cli

After that type:

ping

This will reply with – PONG

 

5. Test Redis on Ubuntu 22.04

We can also use the Redis-CLI tool to set and retrieve values, to check how it works, let’s add a key and a value for it. After that use the key to retrieve the value as we know this database is an in-memory key-value NoSQL database.

redis-cli

Let’s say we have a key called “key1” and  “My First Key” is the value we are setting for it.

set key1 "My Fist Key"

Get key value:

get key1

To exit:

quit

Know more about Altering and querying the keyspace on the official doc page.

Redis command

 

6. Set password for Redis

By default, there will be no authentication when you send commands to the server using the redis-tool. To add an extra layer of security we can assign a password. For that edit the configuration file.

sudo nano /etc/redis/redis.conf

Set password to Redis Server client

Find line:

requirepass fooboard

uncomment it by removing the # symbol. After that change “fooboard” with whatever password you want to set for Redis-tool.

Save the file by pressing Ctrl+O; hit the Enter key, and then exit the file using – Ctrl+X.

Restart the Redis service

sudo systemctl restart redis

Now, let’s check whether the Redis tool is asking for a password to send commands or not.

redis-cli

Let’s send the command “ping

You will have an error:

(error) NOAUTH Authentication required.

This means we need to supply the password. For that type:

auth your-password

After that enter the Redis command you want to use.

check authentication for redis too

 

Other Articles:

Install Brew on Ubuntu 22.04 LTS Jammy Linux
How to Install Helm on Ubuntu 22.04 LTS
Steps to Install MySQL on Ubuntu 22.04 LTS
How to Install Ubuntu 22.04 Linux on Windows

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.