Redis is a kind of data structure storage and is used as a message broker, key-value database, and also cache system. It is written in C language and supports a large amount of data types like strings, lists, hashes, and many others. Here, we are going to analyze this applicable data store and learn 2 ways to install Redis on Ubuntu 22.04.
Steps to Install Redis on Ubuntu 22.04
Installing Redis is an easy process that may take just a few minutes. But first, you should prepare some requirements.
– A Linux VPS with Ubuntu 22.04 OS
– A root user or non-root user with sudo privileges
1- Updating system packages
Before you start the installation part, your system should be up to date. So, use the following command:
sudo apt update
2- Adding PPA repository
This section will show how you can add the PPA repository to the Ubuntu operating system.
sudo add-apt-repository ppa:redislabs/redis
3- Installing Redis
As you add the PPA repository, use the following command to start the installation process:
sudo apt-get install redis
4- checking the version of Redis
If you desire to see the version of the installed Redis, you can run the following command:
After the installation, It’s time to do the configuration part.
Configuring Redis on Ubuntu 22.04
Here, you can use step-by-step instructions to Configure Redis on your Ubuntu system.
1- Enabling Redis on Ubuntu
If you want to configure Redis, first of all, you should enable the Redis service by running the following command:
sudo systemctl enable --now redis-server
2- Opening the Configuration File
In this section, you should open the Redis configuration file in your desired editor to make changes:
Tip: Here, we will use nano editor.
Here is what the configuration file looks like:
Now, you should find the Bind address line (127.0.0.1) and replace it with the (Bind 0.0.0.0):
You will need a password for the configuration part which must be specified with the “Requirepass” attribute. Then hit the Ctrl+O keys to apply the changes and return to the terminal:
3- Restarting the Redis
In this section, you can use the command below to restart the Redis:
sudo systemctl restart redis-server
4- Verifying Redis IP and Port
Use the command below to check the IP and Port number which is used by this service:
ss -tunelp | grep 6379
Tip: To have a TCP connection you can use port: (6379)
sudo ufw allow 6379/tcp
5- Testing Redis Server
Run the related command to test the Redis server and connect locally:
Now, you should run the “AUTH” command and specify the password you set in the configuration part:
For a stable connection and positive output (Ok), you should enter the correct password.
6- Checking the Redis Info
Use the Info command to get detailed information about Redis:
You can use the ping command to ping the Redis:
7- How to exit Redis
To exit Redis, use the “quit” command:
Uninstalling Redis on Ubuntu 22.04
If you decide to uninstall Redis from your Ubuntu operating system, you can run the following command:
sudo apt remove --autoremove redis-server -y
This method was the best and easiest way to install and use Redis on Ubuntu OS.
You can install Redis on any server. But here we decided to focus on the Ubuntu operating system. Here, you learned how to install Redis on Ubuntu 22.04. We thought about the way of installation and configuration of this service. Also, we showed how you can uninstall Redis. Hope you enjoyed this article.
There can be up to 10000 connections on Redis or 4 simultaneous connections per MB of your memory.
As Redis is single-threaded, it can not use multiple cores of the server’s CPU.