Waiting until the support for slave-read-only
on StackExchange.Redis
, I would like to share my solution to fail-over a node with a minimum write interruption, maintaining data consistency, reducing (eliminating?) possible false write acknowledgment (on the node that is failing). You can lose some write because there's a window where both nodes are slaves. I feel that you can still have some false write ack because you can receive an ack while setting the master as slave and that write could be lost.
redis-slaveof-kvs01.txt
MULTI
SLAVEOF kvs01 6379
CONFIG REWRITE
PUBLISH "__Booksleeve_MasterChanged" "*"
EXEC
redis-slaveof-kvs02.txt
MULTI
SLAVEOF kvs02 6379
CONFIG REWRITE
PUBLISH "__Booksleeve_MasterChanged" "*"
EXEC
redis-slaveof-no-one.txt
MULTI
SLAVEOF NO ONE
CONFIG REWRITE
PUBLISH "__Booksleeve_MasterChanged" "*"
EXEC
and these are the couple of batch that I'm using on windows, but actually I think they work as is in linux too:
redis-failover-to-kvs01.bat
redis-cli -h kvs02 --pipe < redis-slaveof-kvs01.txt
redis-cli -h kvs01 --pipe < redis-slaveof-no-one.txt
redis-failover-to-kvs02.bat
redis-cli -h kvs01 --pipe < redis-slaveof-kvs02.txt
redis-cli -h kvs02 --pipe < redis-slaveof-no-one.txt