2

I'm using Keepalived to manage two Redis instances in a master/slave configuration. I'm experiencing a situation where, if Keepalived is terminated on the Master box (the one with the higher priority), the Backup server takes over as the master. When Keepalived is restarted on the higher priority box, however, the Backup server immediately cedes Master status over to the higher priority box, which effectively flushes the Redis cache.

I tried adding the nopreempt directive to my keepalived.conf, but this behavior is still happening.

The below is the keepalived.conf from the Backup (lower priority) server.

global_defs{
        router_id redis_server_2
}

vrrp_script chk_redis {
        script "killall -0 redis-server"
        interval 5
}

vrrp_instance VI_1{
        interface eth0
        virtual_router_id 100
        priority 200
        advert_int 1
        state BACKUP
        nopreempt
        track_script {
                chk_redis
        }

        virtual_ipaddress {
                10.19.105.229
        }

        notify_master "/usr/bin/sudo /var/lib/redis/redis.sh -m"

        notify_backup "/usr/bin/sudo /var/lib/redis/redis.sh -s"

        notify_fault "/usr/bin/sudo /var/lib/redis/redis.sh -k"

1 Answer 1

2

Okay, I solved it after thinking about it for a few minutes.

Under VRRP_instance V1 on the higher priority box, I had the following:

    state MASTER

Now, nopreempt wasn't being honored because the higher priority box was starting as master. The lower priority box saw a master with a higher priority and switched to slave mode. By changing that line to

    state BACKUP

the higher priority box starts as the slave, sees a master with a higher priority, and remains slave. Done and done.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .