<div dir="ltr"><div><div><div>Hi Moaci,<br><br></div>If you want to provide Kamailio HA in two different datacenters, BGP will be the best tool to achieve that.<br></div>Passing keepalived packets throught VXLAN could be a solution, but if you have any packet loss or bugs in VXLAN implementation in linux kernel, your service will be down.<br><br></div>I have tested a setup in lab using ExaBGP, and please find steps bellow:<br><ul><li>Same IP address configured on loopback address of kamilio host</li><li>Kamailio listen on loopback and on physical nic</li><li>Diffusing kamailio service using DNS (A entry -> @loopback)</li><li>Configure bgp router to created the following comportement (using bgp communities):</li><ul><li>Community 65000:1, this server is master, and request must be routed to him</li><li>Community 65000:2, this server is slave, router must wait removal of community master to insert this route on routing table (using bgp localpref)<br></li></ul><li>Using sipsak to send "ping" request to kamailio (physical nic):</li><ul><li>If sipsak return 0 and server is master, ask to exabgp to announce loopback address with bgp community master.</li><li>If sipsak return 0 and server is slave, ask to exabgp to announce loopback address with bgp community slave.</li><li>If sipsak return 1, ask to exabgp to remove bgp announces</li></ul></ul><p><br></p><p>With this setup, kamailio public address will be announced in two datacenter, and without using any L2 keepalived technologies (ucarp, vrrp ...).</p><p>SipSak check if sip service is available on node, and if kamailio is not running, loopback address will be removed from routing table. If the entiere node fail (hardware failure), loopback address will be removed too, due to BGP keepalived not recieved by PE router. You can ajust BGP timers to make HA convergence faster. In my lab, i have set bgp keepalive to 5s and timeout to 15s. So if my kamailio host failed, maximum 15s without any sip service.</p><p>You can have more than 2 node: create many bgp community (so priorities) as you want, announce loopback address on many datacenter you want. Full flexibility and agility.</p><p>More informations: <a href="https://vincent.bernat.im/en/blog/2013-exabgp-highavailability.html">https://vincent.bernat.im/en/blog/2013-exabgp-highavailability.html</a><br></p><p><br></p><p>My lab is running since 3 weeks, and no "crash" or any bgp flapping.</p><p>Regards.</p></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-07 22:06 GMT+02:00 Moacir Ferreira <span dir="ltr"><<a href="mailto:moacirferreira@hotmail.com" target="_blank">moacirferreira@hotmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">Sorry... It is a long answer.<br><br>Keepalived is a kind of VRRP (RFC5798) like implementation. It is being used all over and it is distributed as a standard package in, for example, CentOS. So no compiling issues, you get upgrades, fixes, etc., in a very simple way.<br><br>I got <a href="http://blog.unicsolution.com/2015/01/kamailio-high-availability-with.html" target="_blank">this nice blog on Kamailio HA</a>, and I will start my tests from it. Now, for MySQL my test bed is already prepared and I am suing MariaDB Galera. I will have 2 MySQL servers, synchronizing the databases in between them all the time. Each MySQL server will have Kamailio on it where Kamailio server 1 will use the MySQL on server 1; Kamailio server 2 will use the MySQL on server two. However, while the MySQL services will be up and running on both servers and so synchronized, Kamailio will run only on server 1 over the VIP address. Should it fail, the keepalived script will then kill local Kamailio instance and start the Kamailio on server 2 (the same it will do if the complete server fails). Please notice that this is crucial to prevent brain split where both Kamailios could "think" they were the master. As the databases will be synchronized the service interruption should be quite short.<br><br>Now, the VIP solution rely on a L2 connectivity in between (or amongst) involved servers and, to be really redundant, the servers should be geographically distant. So, if the above initial tests work, my next step will separating the two Kamailio servers using a L3 router and, using iproute2, create a VxLAN tunnel in between the 2 emulated remote sites. This would eliminate the need of buying a L2 extension in between the two involved datacenters.<br><br>While it solves the problem of a "small" system, if I were providing SIP services to the Internet my approach would be another one: I would have 2 Kamailios, using the same public IP address and use BGP to flip from one location to another. In this case there would be no Kamailio VIP interface but still I would use keepalived to monitor the services and drop the local BGP connection so forcing the Internet to reach my second server in another location. In this case your ISP would set their BGP local preference to reach your Kamailio to the main site; should the main site fails, BGP would use the second path to reach your server that, in fact, would be another Kamailio instance using the same IP of the main one. While this puts more complexity on the design, it would also prevent the brain split and the geographical distance limitation would be just how far your ISP could go.<br><br>If anyone is interested on this kind of techniques just drop into this thread and we keep the discussion going.<br><br>You could help me a lot responding to a question that I have regarding all this is: How Kamailio would behave if I have one active Kamailio writing in the database and a second "live" Kamailio using the same database but not receiving any connection/request. Would this jeopardize the way Kamailio works?<br><br>Cheers,<br>Moacir<br><br><div><hr>To: <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>From: <a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a><br>Date: Tue, 7 Jun 2016 09:01:23 +0200<br>Subject: Re: [SR-Users] High availability<br><br>
  
    
  
  
    Just to mention that ucarp can be a very basic alternative to
      corosync/pacemaker to manage the virtual ip. A simple app, but
      usually keeps working...<br>
    Cheers,<br>
      Daniel<br>
    <br>
    <br>
    <div>On 06/06/16 02:21, Fred Posner wrote:<br>
    </div>
    <blockquote>
      
      <div>If it's just 2 servers, consider as Juha said,
        corosync/pacemaker with drbd. </div>
      <div><br>
      </div>
      <div><span style="background-color:rgba(255,255,255,0)">Fred Posner</span>
        <div><span style="background-color:rgba(255,255,255,0)">direct:
            +1 (224) 334-FRED (3733)</span></div>
      </div>
      <div><br>
        On Jun 5, 2016, at 5:26 PM, Moacir Ferreira <<a href="mailto:moacirferreira@hotmail.com" target="_blank"></a><a href="mailto:moacirferreira@hotmail.com" target="_blank">moacirferreira@hotmail.com</a>>
        wrote:<br>
        <br>
      </div>
      <blockquote>
        <div>
          
          <div dir="ltr">Hi,<br>
            <br>
            Sorry... I should have mentioned before. You guys are
            thinking on the standard Internet SIP calls' behavior while
            I am trying to use Kamailio on a large "industrial" project.
            This said:<br>
            <br>
            Assuming that the end-point is "smart", the DNS method is
            functional but it would take quite a while before the UA
            (phone) recovers from the previous name/IP binding it has in
            cache;<br>
            SRV is good for a "smart" UA that, unfortunately, is not the
            case;<br>
            Same for the phone units as they are industrial "Help
            Points" and so quite "dummy".<br>
            <br>
            While I never tested it, I thought I could use two Kamailio
            servers with a mysql cluster like mariadb-galera where, for
            Kamailio functions, one server would be "active" and another
            "passive" server. Then use keepalived for monitoring the
            "active" Kamailio and starting the "passive" server if the
            active Kamailio fails. Without any testing, tests that I
            think I should have done before putting questions in here,
            my questions are:<br>
            <br>
            Suppose that  I have two Kamailio servers, one "active" and
            another one "passive" (not running) where the mysql
            databases are synchronized in between two servers using
            MySQL Galera. Using keepalived I would monitor the active
            Kamailio instance. Should it fails, start the "passive"
            Kamailio instance using the same MySQL database that were
            supposed to be synchronized. Would this new Kamailio
            instance be able to find a called number? Why this question?
            As long as I understand, Kamailio will always challenge the
            UA for authentication before making a call, so if this
            second server gets a call request it would just challenge
            and authenticate the caller. The "key point" would be having
            this new Kamailio instance aware about the called
            destinations. So, delivering a MySQL database, with the
            latest data the active Kamailio had, to this new Kamailio
            instance would be enough to allow it find the called party?<br>
            <br>
            Anyway, can you guys comment on my "thoughts"? Is it
            possible? Am I missing something? Would you suggest another
            approach for such scenario?<br>
            <br>
            Cheers!<br>
            Moacir <br>
            <br>
            <div>
              <hr>Date: Sun, 5 Jun 2016 21:07:41 +0200<br>
              From: <a href="mailto:chabert.loic.74@gmail.com" target="_blank">chabert.loic.74@gmail.com</a><br>
              To: <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
              Subject: Re: [SR-Users] High availability<br>
              <br>
              <p dir="ltr">Hello Bill,</p>
              <p dir="ltr">I have made kamailio ha using exabgp with
                loopbacks.</p>
              <p dir="ltr">Check <a href="https://github.com/Exa-Networks/exabgp" target="_blank">https://github.com/Exa-Networks/exabgp</a></p>
              <p dir="ltr">With bgp, kamailio cluster can be splited on
                severals datacenters.</p>
              <p dir="ltr">Regards.</p>
              <div>Le 5 juin 2016 20:53, "Bill"
                <<a href="mailto:bill@novatrope.us" target="_blank">bill@novatrope.us</a>>
                a écrit :<br>
                <blockquote style="border-left:1px #ccc solid;padding-left:1ex">
                  <div> Hi Moacir<br>
                    <br>
                    We have only found three ways to handle failover.<br>
                    1. Change the DNS entry whenever a failure is
                    detected.<br>
                    2. Use SRV records to display an alternate route.<br>
                    3. Use the failover mechanism in the phone itself<br>
                    <br>
                    1. works, but it may take some time for your ua's to
                    become aware of the change<br>
                    2. never have been able to get this to work as
                    advertised.<br>
                    3. Works pretty well depending on the phone. (We use
                    mostly Yealink's and they seem to handle the
                    failover pretty well.)<br>
                    <br>
                    Hope this helps<br>
                    <br>
                    <div>On 06/05/2016 07:41 AM, Moacir Ferreira wrote:<br>
                    </div>
                    <blockquote>
                      <div dir="ltr">Hi,<br>
                        <br>
                        I got two questions regarding high availability:<br>
                        <br>
                        1 - Should my Kamailio server fail, I would like
                        another Kamailio "box/server" to take over with
                        minimum services disruption. What is the
                        "community" advice for such environment?<br>
                        <br>
                        2 - Should my main PSTN gateway fail, what would
                        be the best mechanism to redirect calls to a
                        second PSTN gateway?<br>
                        <br>
                        Cheers!<br>
                        Moacir<br>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <br>
                      <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
                    </blockquote>
                    <br>
                  </div>
                  <br>
                  _______________________________________________<br>
                  SIP Express Router (SER) and Kamailio (OpenSER) -
                  sr-users mailing list<br>
                  <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
                  <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
                  <br>
                </blockquote>
              </div>
              <br>
              _______________________________________________
              SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
              mailing list
              <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
              <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></div>
          </div>
        </div>
      </blockquote>
      <blockquote>
        <div><span>_______________________________________________</span><br>
          <span>SIP Express Router (SER) and Kamailio (OpenSER) -
            sr-users mailing list</span><br>
          <span><a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a></span><br>
          <span><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></span><br>
        </div>
      </blockquote>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <pre>-- 
Daniel-Constantin Mierla
<a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a> - <a href="http://www.kamailio.org" target="_blank">http://www.kamailio.org</a>
<a href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
  

<br>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></font></span></div>                                           </div></div>
<br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>