6.17 Installing and Configuring Redis
Redis (Remote Dictionary Server) is a powerful key-value database management system that has gained widespread adoption among developers due to its high performance and versatility. This technology serves not just as a data store but also as an effective tool for caching, message queues, and implementing complex data structures in real-time.
The uniqueness of Redis lies in its ability to store various data types — from simple strings to complex structures such as lists, sets, hash tables, and others. Thanks to in-memory operations support and the ability to persist data to disk, Redis provides unmatched data processing speed while maintaining reliability.
Important: before installing Redis, make sure Your system meets the minimum system requirements and has current system updates.
It is important to have root
access level. The setup can be implemented on our virtual and dedicated server services.
System Preparation
System Update
For Debian/Ubuntu:
For CentOS/AlmaLinux/RockyLinux:
Installing Redis
Debian/Ubuntu:
CentOS/AlmaLinux/RockyLinux:
Basic Redis Configuration
- Editing the configuration file:
- Key security settings:
- Save and restart the service:
- Enable service autostart:
- Check if autostart is active:
If the command returns enabled
, it means autostart is enabled.
The result might be alias
, which means the redis service is running through a symbolic link (alias) to another service. This usually happens if Redis in Your system is configured as an “alias” to another service, for example, redis-server
.
Firewall Configuration
Information: for convenience when entering multiple sequential commands, You will be provided with an example using Heredoc. Let’s look at what this is.
Heredoc (shortened from “here document”) is a convenient mechanism in bash scripting that allows passing multiline text or command sequences directly to a command or interpreter. The heredoc syntax uses <<
operators with an arbitrary delimiter (most commonly EOF
), creating a unique way to group and execute commands.
The heredoc mechanism works as follows:
- The bash interpreter creates a temporary text stream.
- All commands between the
<<EOF
andEOF
markers are executed sequentially. - Allows grouping complex command sequences without creating temporary files.
- Provides controlled data transfer between commands.
The main advantage is the ability to execute a block of commands with elevated privileges (via sudo
) without the need to create a separate script.
Configuring iptables:
Save the rules:
When saving rules, You will be asked for confirmation. You need to press Yes
.
Configuring firewalld:
Configuring UFW:
Checking Redis Service Status
1. Checking Redis system service status.
To find out if the Redis service is running, execute the command:
You will see information about the service status, including activity and possible errors.
2. Checking Redis through redis-cli
.
For a quick check if Redis is responding:
The response should be PONG
, indicating correct operation.
3. Checking if the service is listening on port 6379 (default port).
Use netstat
or ss
to check if Redis is listening on the required port:
Or using ss
:
If the port is being listened to, this confirms that Redis is working.
4. Additional Redis configuration check.
To find out active Redis parameters, connect to it using the client:
And enter the command:
This will show all configuration parameters, including port, operation mode, and other settings.