How to install and configure redis on ubuntu 22. 04

How to Install and Configure Redis on Ubuntu 22.04

Redis is an open-source, freely-available data structure store that is utilized as a cache, message broker, and key-value database. It offers support for geospatial indexes, Strings, sets, bitmaps, hyper logs, hashes, streams, sorted sets with range queries, and lists. Redis Sentinel software logic enables high availability and the Redis cluster creates automatic partitioning between Redis nodes.

This blog will demonstrate the procedure for installing and configuring Redis on Ubuntu 22.04. Let’s get started!

How to install Redis on Ubuntu 22.04

For the purpose of installing Redis on Ubuntu 22.04, follow the given instructions.

Step 1: Update system packages

First of all, hit “CTRL+ALT+T” and update the system packages with the help of the following command:

$ sudo apt update

How to install and configure redis on ubuntu 22. 04 1

Step 2: Add PPA repository

In the next step, we will add the “redislabsPPA repository to our Ubuntu 22.04 system:

$ sudo add-apt-repository ppa:redislabs/redis

How to install and configure redis on ubuntu 22. 04 2

How to install and configure redis on ubuntu 22. 04 3

Step 3: Install Redis

After adding the required respiratory, execute the following command for Redis installation:

$ sudo apt-get install redis

How to install and configure redis on ubuntu 22. 04 4

The given output states that we have successfully installed Redis on our Ubuntu 22.04 system:

See also  Change the Timezone in Ubuntu

How to install and configure redis on ubuntu 22. 04 5

Step 4: Check Redis version

Lastly, verify the version of installed Redis by executing the “redis-server” command with the “-v” option:

$ redis-server -v

How to install and configure redis on ubuntu 22. 04 6

Now, let’s head towards the procedure of configuring Redis on our system.

How to configure Redis on Ubuntu 22.04

Follow the below-given instructions for Redis configuration on Ubuntu 22.04.

Step 1: Enable Redis service

For configuring Redis on Ubuntu 22.04, firstly enable the Redis service by executing the following command:

$ sudo systemctl enable –now redis-server

How to install and configure redis on ubuntu 22. 04 7

Now, move to the next step.

Step 2: Open Redis configuration file

In the next step, open up the Redis Configuration file in the “nano” editor to make some required changes:

$ sudo nano /etc/redis/redis.conf

How to install and configure redis on ubuntu 22. 04 8

The opened “redis.conf” file will somehow look like this:

How to install and configure redis on ubuntu 22. 04 9

Find the line stating the “bind” address as “127.0.0.1”:

How to install and configure redis on ubuntu 22. 04 10

Replace it with the “bind 0.0.0.0”:

How to install and configure redis on ubuntu 22. 04 11

Then specify the password required for Redis configuration with the “requirepass” attribute and press “CTRL+O” to save the added changes and switch back to the terminal:

How to install and configure redis on ubuntu 22. 04 12

Step 3: Restart Redis service

Now, restart the Redis service with the help of provided command:

$ sudo systemctl restart redis-server

How to install and configure redis on ubuntu 22. 04 13

Step 4: Verify Redis IP and Port

Utilize the following “ss” command to check the IP and port number used by Redis:

$ ss -tunelp | grep 6379

How to install and configure redis on ubuntu 22. 04 14

Also, allow port “6379” for “tcp” connections:

$ sudo ufw allow 6379/tcp

How to install and configure redis on ubuntu 22. 04 15

Step 5: Test Redis server

Now, it’s time to test the Redis server and connect to it locally:

$ redis-cli

How to install and configure redis on ubuntu 22. 04 16

First of all, execute the “AUTH” command and specify the password which you have entered in the Redis configuration file:

> AUTH Linuxhint098

Entering the correct password will establish a successful connection to Redis and output “OK”:

See also  Kubeflow 1.6 on Kubernetes 1.23 and beyond

How to install and configure redis on ubuntu 22. 04 17

Step 6: Check Redis information

In order to check Redis information, run “INFO” command:

> INFO

How to install and configure redis on ubuntu 22. 04 18

Step 7: Ping Redis service

Next, “ping” the Redis service:

> ping

How to install and configure redis on ubuntu 22. 04 19

Step 8: Exit Redis CLI

Type the “quit” command for exiting the current Redis CLI shell:

> quit

How to install and configure redis on ubuntu 22. 04 20

How to uninstall Redis on Ubuntu 22.04

To uninstall Redis on Ubuntu 22.04, write out the following command in terminal:

$ sudo apt remove –autoremove redis-server -y

How to install and configure redis on ubuntu 22. 04 21

We have compiled the easiest method to install and configure Redis on Ubuntu 22.04.

Conclusion

To install Redis on Ubuntu 22.04, firstly, update system packages and execute the “$ sudo apt-get install redis” command. After that, configure Redis by making some required changes in the “redis.conf” file such as setting the “bind” address and password with the “AUTH” attribute. Then, restart the Redis service and establish a connection to the Redis server for testing. This blog demonstrated the procedure of installing and configuring Redis on Ubuntu 22.04.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply