Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can keepalived(nopreempt) proactively give up the VIP when the Master is not faulty and then turn it into a backup? #2552

Open
wanshangfeng opened this issue Feb 25, 2025 · 5 comments

Comments

@wanshangfeng
Copy link

wanshangfeng commented Feb 25, 2025

I have a scenario where I need to use Keepalived(nopreempt) to detect my application service. When my application service goes down, I need to actively give up the VIP and change the state from Master to Backup.

@wanshangfeng wanshangfeng changed the title Can keepalived proactively give up the VIP when the Master is not faulty and then turn it into a backup? Can keepalived(nopreempt) proactively give up the VIP when the Master is not faulty and then turn it into a backup? Feb 25, 2025
@pqarmitage
Copy link
Collaborator

It doesn't work quite as you describe it but there are probably ways of achieving what you want.

When you state "to detect my application service", I assume you mean that the process stops running. If that is the case, then you want to use a track_process. You can use that to reduce the priority of the VRRP instance (specify a weight for the track_process that is greater than the difference in the VRRP priorities between the master and backup) and assuming that the backup then has higher priority than the system that was master, and provided that nopreempt is NOT configured, then what was the backup will take over as master and the master will revert to backup.

If you have to use preempt, then the only way that the backup can take over as master is if the original master goes to fault state (that is what preempt means). You can make this happen if the track_process has a weight of 0.

There are options such as a track_script but which will work best for you really requires more information about exactly what is happening on your systems and what you want to achieve.

@wanshangfeng
Copy link
Author

wanshangfeng commented Feb 26, 2025

It doesn't work quite as you describe it but there are probably ways of achieving what you want.

When you state "to detect my application service", I assume you mean that the process stops running. If that is the case, then you want to use a track_process. You can use that to reduce the priority of the VRRP instance (specify a weight for the track_process that is greater than the difference in the VRRP priorities between the master and backup) and assuming that the backup then has higher priority than the system that was master, and provided that nopreempt is NOT configured, then what was the backup will take over as master and the master will revert to backup.

If you have to use preempt, then the only way that the backup can take over as master is if the original master goes to fault state (that is what preempt means). You can make this happen if the track_process has a weight of 0.

There are options such as a track_script but which will work best for you really requires more information about exactly what is happening on your systems and what you want to achieve.

I get it, Thank you very much.

How to monitor keepalived status switching information if I don't have a smtp server? Can I push keepalived log information out automatically?

@pqarmitage
Copy link
Collaborator

You can use notify scripts. Either just a simple notify script which will be called every time the vrrp instance changes state, or the separate notify_master, notify_backup, notify_fault scripts. There is an alternative option of using a notify_fifo. The details are all in the keepalived.conf(5) man page.

@wanshangfeng
Copy link
Author

You can use notify scripts. Either just a simple notify script which will be called every time the vrrp instance changes state, or the separate notify_master, notify_backup, notify_fault scripts. There is an alternative option of using a notify_fifo. The details are all in the keepalived.conf(5) man page.
Thank you ,I know this. I want to use a monitoring platform to monitor the state switching of keepalived by pushing out the syslog of keepalived. Can keepalived achieve this?

@pqarmitage
Copy link
Collaborator

I don't know what you mean by "pushing out the syslog of keepalived", and I can't see why you would want to monitor the syslog when there are already ways of receiving notification of vrrp instance state changes, as I set out above and you are apparently aware of.

keepalived currently logs, via syslog, vrrp instance state changes. Is there anything more that your need keepalived to do? If for some reason the keepalived syslog entries are insufficient for you, you could use a notify script to write syslog entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants