Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo yum update -y- Enable the EPEL Repository
Redis is available in the EPEL (Extra Packages for Enterprise Linux) repository. Enable it using the following command:
sudo yum install epel-release -y- Install Redis
Install Redis using theyumpackage manager:
sudo yum install redis -y- Start and Enable Redis
Start the Redis service:
sudo systemctl start redisEnable Redis to start on boot:
sudo systemctl enable redis- Verify Redis Installation
Check the Redis service status to ensure it is running:
sudo systemctl status redisIf Redis is running, you should see an active (running) status.
- Test Redis Installation
To test the Redis installation, use the Redis CLI to connect to the Redis server:
redis-cliOnce connected, you can test Redis by setting and getting a key:
SET mykey "Hello, Redis!"
GET mykeyYou should see the response “Hello, Redis!”.
- Secure Redis (Optional)
For additional security, consider setting a password. Open the Redis configuration file for editing:
sudo nano /etc/redis.confUncomment the requirepass directive and set a strong password:
requirepass your_passwordSave and close the file. Restart Redis to apply the changes:
sudo systemctl restart redis- Enable Persistence (Optional)
Redis supports two forms of persistence: RDB snapshots and AOF (Append Only File). To enable RDB snapshots, ensure the following lines are present in the Redis configuration file:
save 900 1
save 300 10
save 60 10000To enable AOF, uncomment and set the appendonly directive to yes:
appendonly yesSave and close the file. Restart Redis to apply the changes:
sudo systemctl restart redis- Configure Redis to Bind to Specific IP Address (Optional)
By default, Redis listens on all available IP addresses. To restrict access, open the Redis configuration file:
sudo nano /etc/redis.confFind the bind directive and set it to your server’s IP address:
bind 127.0.0.1Save and close the file. Restart Redis to apply the changes:
sudo systemctl restart redis- Monitor Redis
You can monitor Redis performance and statistics using theredis-cliwith theINFOcommand:bash redis-cli INFO


