📖 Scenario: You are managing a Redis setup with one master and two replicas. Sometimes the master server can go down, and you need to manually promote a replica to become the new master to keep your application running smoothly.
🎯 Goal: Learn how to perform a manual failover in Redis by promoting a replica to master and reconfiguring other replicas to follow the new master.
📋 What You'll Learn
Create a list of Redis nodes with their roles and IP addresses
Define the current master node IP
Write commands to promote a replica to master manually
Update other replicas to follow the new master
💡 Why This Matters
🌍 Real World
In real Redis deployments, manual failover is sometimes necessary when automatic failover fails or is not configured. This project simulates the commands and steps needed to perform manual failover.
💼 Career
Understanding manual failover helps database administrators and DevOps engineers maintain high availability and reliability of Redis services in production environments.
Progress0 / 4 steps
1
Setup Redis nodes list
Create a list called redis_nodes containing dictionaries for three Redis nodes with these exact entries: {'ip': '192.168.1.10', 'role': 'master'}, {'ip': '192.168.1.11', 'role': 'replica'}, and {'ip': '192.168.1.12', 'role': 'replica'}.
Redis
Hint
Use a Python list with dictionaries for each Redis node.
2
Define current master IP
Create a variable called current_master_ip and set it to the string '192.168.1.10' to represent the current master node IP.
Redis
Hint
Assign the IP of the master node to current_master_ip.
3
Promote a replica to master
Write a command string called promote_command that uses the Redis CLI command redis-cli -h 192.168.1.11 SLAVEOF NO ONE to promote the replica at IP 192.168.1.11 to master.
Redis
Hint
Use the exact Redis CLI command string to promote the replica.
4
Reconfigure other replicas to follow new master
Create a list called replica_follow_commands containing the Redis CLI commands to make the replica at IP 192.168.1.12 follow the new master at IP 192.168.1.11. The command should be redis-cli -h 192.168.1.12 SLAVEOF 192.168.1.11 6379.
Redis
Hint
Put the exact command string inside a list called replica_follow_commands.
Practice
(1/5)
1. What is the main purpose of performing a manual failover in a Redis cluster?
easy
A. To upgrade Redis to a new version automatically
B. To delete all data from the Redis cluster
C. To switch the Redis master to a backup to keep the service running
D. To backup Redis data to an external storage
Solution
Step 1: Understand failover purpose
Failover is used to switch the master node to a backup node when the master fails or needs maintenance.
Step 2: Identify the correct purpose
The goal is to keep the Redis service running without interruption by promoting a backup to master.
Final Answer:
To switch the Redis master to a backup to keep the service running -> Option C
Quick Check:
Failover = switch master to backup [OK]
Hint: Failover means switching master to backup to avoid downtime [OK]
Common Mistakes:
Confusing failover with data backup
Thinking failover upgrades Redis automatically
Assuming failover deletes data
2. Which command syntax is correct to trigger a manual failover on a Redis cluster node?
easy
A. redis-cli --failover cluster
B. redis-cli failover --cluster
C. redis-cli cluster --failover node
D. redis-cli --cluster failover
Solution
Step 1: Recall the correct command format
The correct syntax to trigger manual failover is using the cluster option with failover and the node ID.
Step 2: Match the syntax
Only redis-cli --cluster failover <node-id> matches the official Redis command format.
Final Answer:
redis-cli --cluster failover <node-id> -> Option D