Learn how to Install and Secure Redis on Rocky Linux 9 for safety and performance. Our Redis Support team is ready to assist you.
Install and Secure Redis on Rocky Linux 9
Keeping Rocky Linux 9 updated ensures better security, stability, and performance before installing Redis. In this guide, you will learn how to update your system, install Redis, configure it for security and performance, and test the setup for smooth operation.
Update Your Rocky Linux 9 System
Before you install Redis or any other software, it’s important to make sure your Rocky Linux 9 system is fully updated. Running the latest packages gives you better stability, security patches, and bug fixes.
- Log in to your server
Connect to your Rocky Linux system either through SSH or directly via the local console.
- Check for available updates
Run the following command to see which packages have updates available:
sudo dnf check-update
- Install all updates
To upgrade every package to the latest version, run:
sudo dnf update -y
The -y flag lets the system install updates without asking for confirmation.
- Reboot if required
If the update includes a new kernel or core libraries, reboot your server to apply the changes:
sudo reboot
By keeping your Rocky Linux 9 system updated, you ensure a secure and stable environment before installing Redis.
Install Redis on Rocky Linux 9
You can install Redis on Rocky Linux 9 directly from the default repositories. Follow these steps:
- Update your system
sudo dnf update -y
- Install Redis
sudo dnf install -y redis
- Enable Redis to start at boot
sudo systemctl enable redis
- Start the Redis service
sudo systemctl start redis
- Check Redis service status
sudo systemctl status redis
The output should display active (running) if Redis is working.
- Test Redis installation (optional)
redis-cli ping
A successful installation will return PONG.
Start and Enable Redis Service
Once Redis is installed, the next step is to make sure it runs properly. You need to start the service for the current session and also configure it to launch automatically when the server reboots. This ensures your applications can always connect to Redis without manual intervention.
First, start the Redis service by running the following command:
sudo systemctl start redis
In some systems, the service might be called redis-server. If the above command does not work, try:
sudo systemctl start redis-server
Next, enable Redis so it starts automatically at boot. Use the command:
sudo systemctl enable redis
Or, if your system uses the alternate name:
sudo systemctl enable redis-server
Finally, check the status of the service to confirm everything is running correctly:
sudo systemctl status redis
When Redis is active, you should see the output showing active (running) and also enabled. This confirms that Redis will keep running even after a restart.
Configure Redis for Your Environment
After installing Redis, you should adjust its settings in the redis.conf file (usually found in /etc/redis/redis.conf).
Performance tuning:
- Set maxmemory to limit RAM usage.
- Use maxmemory-policy allkeys-lru to evict the least used keys.
- Enable persistence with appendonly yes or tune RDB save intervals.
- Increase tcp-backlog for handling more connections.
Security hardening:
- Set a strong password with requirepass.
- Bind Redis to 127.0.0.1 to restrict access.
-
- Change the default port from 6379.
- Disable or rename risky commands like FLUSHALL.
Restart Redis after changes:
sudo systemctl restart redis
Secure Redis with Password Authentication
To protect your Redis server, enable password authentication by editing the redis.conf
Steps:
- Locate the redis.conf file, often in /etc/redis/redis.conf.
- Open it in a text editor:
sudo nano /etc/redis/redis.conf
- Find and set the password:
requirepass your_strong_password
Use a long, random password for better security.
- Save changes and restart Redis:
sudo systemctl restart redis-server
- Verify with the CLI:
redis-cli
set mykey myvalue # should fail
AUTH your_strong_password
set mykey myvalue # should succeed
Test Redis Installation and Access
After installing Redis, you should confirm it is running and accessible. Follow these steps:
- Launch the Redis CLI
Open your terminal and type:
redis-cli
If successful, the prompt will show 127.0.0.1:6379>.
- Test connectivity with PING
127.0.0.1:6379> PING
You should see PONG, confirming the server is active.
- Perform a basic data operation
127.0.0.1:6379> SET mykey "Hello Redis"
OK
127.0.0.1:6379> GET mykey
"Hello Redis"
This shows Redis can store and retrieve data successfully.
- Exit the Redis CLI
127.0.0.1:6379> exit
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
By following these steps, you can successfully Install and Secure Redis on Rocky Linux 9. Keeping your server updated, enabling password protection, and fine-tuning performance settings ensures Redis runs safely and efficiently. This setup provides a strong foundation for stable and secure applications.
In brief, our Support Experts demonstrated how to fix the “554 5.7.1 : Relay access denied” error.
0 Comments