Solution of redis failover, read/write separation, and read load-balance. Total client-independent
- Let your redis master/slave failover automatically
- Switch clients to the new master when failover happens
- read/write separation
- Read traffic load-balance (among slaves or all servers)
- No multi-master problem (compare to legacy HAProxy redis check)
- Total client-independent, doesn't require any client libraries
- Redis
- HAProxy (community edition is enough)
For this part, you can find further instructions at https://redis.io/topics/replication
- Make 3 copies of sentinel.conf. Modify them, replace properties surrounded by angle brackets with real ones.
- Start 3 sentinels
redis-sentinel ./sentinel.conf
- Modify haproxy.cfg, replace properties surrounded by angle brackets with real ones, and make changes accord to comments if needed.
- Start HAProxy
haproxy -f ./haproxy.cfg
just let your clients use HAProxy's 16379 port for writes and 16479 port for reads
Connect to current master, execute command:
DEBUG sleep 10
the failover should happen after 8 secs, then you can visit http://:8888/haproxy?stats to see if HAProxy's stat changes
Make your HAProxy able to failover (keepalived recommended)