Asterisk with heartbeat problem

Hello!
I did an integration of heartbeat with Asterisk, and it works well:

  • Server1 and Server2 have Asterisk and Heartbeat up, and the call enters in Server1
  • When I shut down Hearbeat in Server1. Server2 take over control and the call enters in it.
  • When I turn on again Server1, the call enters again in Server1
    All of this works well if i shut down/turn on hearbeat, but if I only shut down Asterisk in Server1 (but heartbeat still on) the call doesn’t enter in Server2. (It doesn’t enter anywhere)
    Is there a way to perform this behaviour? I need that when only the asterisk service on Server1 fails, the call enters in the asterisk service on Server2.
    Thanks,
    Greetings

I apologize, but I’m not familiar with a few things you mention in your post.

When you say heartbeat, what are you referring to? How is your heartbeat mechanism communicating to your upstream to know where to send calls back down?

Thanks,
Matthew Fredrickson

Hello
Heartbeat is a program/mechanism that i had installed in both Server to do the switch of the call routing.
I have a virtual IP, and then two real IPs (one for each server)
The idea is that the call goes to the virtual IP, and then is redirected to Server1 or Server2 (dependen which is active).
It works well, if one node shut down, the other takes control of the stream.
But if it is only asterisk the one which shut down (and not the entire heartbeat node), the call doesn’t goes to the other asterisk.
Thanks for the help,
Greetings

A virtual IP failover is only going to work in scenarios where the heartbeat mechanism fails to communicate with its peers. In the scenario you’re outlining, that hasn’t happened - Asterisk is dead, but the heartbeat continues.

You have two options that I can see:

  1. You could not care about this scenario. That sounds radical, but Asterisk already has lots of ways to automatically restart if the underlying system is in good shape. For example, the safe_asterisk script will already do this. In disaster scenarios, if your system can recover in a few seconds, you usually don’t want to fail over.

  2. You could modify Asterisk and/or the heartbeat mechanism to be aware of each other. This is obviously more involved - an example, however, of doing this can be seen in res_corosync.

Thanks for the help.
Is there somewhere in Heartbeat configuration files on which to configure that when a resource (in this case Asterisk) is down, the other server will take control of that resource?
I only configure the authkeys, ha.cf, and haresources files of heartbeat. Is there another file to configure to make this scenario works?
Thanks again,
Greetings

While I’m by no means an expert on Linux-HA, the closest I can see that it would provide is the respawn option. That probably won’t do what you want, however, as it will simply cause Heartbeat to monitor a process and restart it, as opposed to failing over. That’s essentially the same thing as safe_asterisk.

Again, though, I think you’re viewing this situation incorrectly. If Asterisk can be restarted, you should not fail over to another node. Failing over in a recoverable situation is generally not a good practice - you’ve taken a system out of production when it was perfectly suitable for servicing requests. It is exceptionally rare to have a situation where the hardware/OS is fine and Asterisk cannot recover. Instead, I would rely on safe_asterisk or some process management to ensure that Asterisk is always running, even if it has a fault, and rely on your Heartbeat to handle scenarios where the hardware or the OS has a fault and cannot recover.