Introduction
Redis stands for Remote Dictionary Server. Redis is a data structure that stores data in key-value pairs. All Redis data is stored in memory, enabling high data access rates. Unlike regular databases in Redis, it takes much less time to read and write to memory and supports millions of operations per second.
This article will explain how to install and configure Redis on Fedora 34.
Prerequisites
- A root or non-root user with
sudo
privileges.
Install Redis
- Update the system.
# sudo dnf -y update
- Once the system is updated, we can proceed to install Redis. To install Redis on Fedora 34, run the following command in the terminal.
# sudo dnf -y install redis
- Start the Redis service.
# sudo systemctl start redis
- Enable the Redis service.
# sudo systemctl enable redis
- Test the Redis setup with the below command.
If Redis running on your system above command print# redis-cli ping
PONG
as the response.
Configure and Securing Redis
- After installing Redis, we need to configure it to work properly. The configuration file for Redis is located at
/etc/redis/redis.conf
. Open the file using the following command.
Search# sudo vi /etc/redis/redis.conf
bind
and remove localhost IP and bind your IP address. - Secure your redis with password authentication.
Search the SECURITY section and then uncomment "requirepass" and provide the password as shown below.# sudo vi /etc/redis/redis.conf
Change the "foobared" with your strong password.requirepass foobared
- After making all the necessary changes, save the file, exit, and restart the Redis services.
# systemctl restart redis
Test Redis server connectivity
- Connect to the Redis client using
redis-cli -h <your-server-ip> -p 6379
.
# redis-cli -h 207.199.149.233 -p 6379
- You need to authenticate before invoking any command on the Redis CLI. Here we pass the password provided in the earlier step.
AUTH foobared
- After connecting to the Redis server let's try to set and get a new key in Redis.
set key1 "test_key"
get key1