[OpenSIPS-Users] Active-Pasive Dialog Replication
    Social Boh 
    social at bohboh.info
       
    Fri Mar 13 17:55:46 EST 2020
    
    
  
Hello,
I'm using Keealived for configuration:
OpensSIPs1 IP 1.2.3.4
OpenSIPs2 IP 5.6.7.8
Virtual IP: 10.11.12.13
OpenSIPs1:
*keepalived.conf*
vrrp_script check_sip {
*script "/etc/keepalived/node01.sh"*
   interval 3
   fall 2
   rise 2
}
vrrp_instance VI_OS {
   state MASTER
   interface eth0
   virtual_router_id 1
   advert_int 1
*notify /etc/keepalived/opensips.sh*
   virtual_ipaddress {
    10.11.12.13 dev eth0
   }
   track_script {
     check_sip
   }
}
each time there is a change in the servers status, keepalived ejecute 
opensips.sh script
*node01.sh*
#!/bin/bash
node01=1.2.3.4
node02=5.6.7.8
*return_code=0*
timeout 2 sipsak -s sip:$node01:5060
exit_status=$?
if [[ $exit_status -eq 0 ]]; then
   echo "sip ping successful to node01 [$node01]"
   exit $return_code
fi
timeout 2 sipsak -s sip:$node02:5060
exit_status=$?
if [[ $exit_status -eq 0 ]]; then
   echo "sip ping successful to node02 [$node02]"
   return_code=1
fi
echo "return code [$return_code]"
exit $return_code
*opensips.sh*
#!/bin/bash
TYPE=$1
NAME=$2
STATE=$3
case $STATE in
         "MASTER") /usr/sbin/opensipsctl fifo dlg_set_sharing_tag_active vip
                   /usr/sbin/opensipsctl fifo nh_enable_ping 1
                   exit 0
                   ;;
         "BACKUP") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags
                   /usr/sbin/opensipsctl fifo nh_enable_ping 0
                   exit 0
                   ;;
         "FAULT")  /usr/sbin/opensipsctl fifo dlg_list_sharing_tags
                   /usr/sbin/opensipsctl fifo nh_enable_ping 0
                   exit 0
                   ;;
         *)        echo "unknown state"
                   exit 1
                   ;;
esac
in this file I move the sharing tag and pinging NAT in the MASTER status 
and remove in BAKCUP and FAULT status
OpenSIPs2:
*keepalived.conf*
vrrp_script check_sip {
   script "/etc/keepalived/node02.sh"
   interval 3
   fall 2
   rise 2
}
vrrp_instance VI_OS {
   state BACKUP
   interface eth0
   virtual_router_id 1
   advert_int 1
   notify /etc/keepalived/opensips.sh
   virtual_ipaddress {
    10.11.12.13 dev eth0
   }
   track_script {
     check_sip
   }
}
*node02.sh*
#!/bin/bash
node01=1.2.3.4
node02=5.6.7.8
*return_code=1*
timeout 2 sipsak -s sip:$node01:5060
exit_status=$?
if [[ $exit_status -eq 0 ]]; then
   echo "sip ping successful to node01 [$node01]"
   exit $return_code
fi
timeout 2 sipsak -s sip:$node02:5060
exit_status=$?
if [[ $exit_status -eq 0 ]]; then
   echo "sip ping successful to node02 [$node02]"
   return_code=0
fi
echo "return code [$return_code]"
exit $return_code
*opensips.sh*
#!/bin/bash
TYPE=$1
NAME=$2
STATE=$3
case $STATE in
         "MASTER") /usr/sbin/opensipsctl fifo dlg_set_sharing_tag_active vip
                   /usr/sbin/opensipsctl fifo nh_enable_ping 1
                   exit 0
                   ;;
         "BACKUP") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags
                   /usr/sbin/opensipsctl fifo nh_enable_ping 0
                   exit 0
                   ;;
         "FAULT")  /usr/sbin/opensipsctl fifo dlg_list_sharing_tags
                   /usr/sbin/opensipsctl fifo nh_enable_ping 0
                   exit 0
                   ;;
         *)        echo "unknown state"
                   exit 1
                   ;;
esac
Then you have to install sipsak and change your iptables configuration.
opensips.cfg
OpenSIPs1:
listen=udp:1.2.3.4:5060
listen=udp:10.11.12.13:5060
#### DIALOG module
loadmodule "dialog.so"
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "default_timeout", 21600)
modparam("dialog", "db_mode", 0)
modparam("dialog", "dlg_sharing_tag", "vip=active")
modparam("dialog", "dialog_replication_cluster", 3)
modparam("dialog", "db_url","mysql://opensips:password@localhost/opensips")
if (is_method("INVITE")) {
                 route(AUTH);
                 create_dialog();
                 set_dlg_sharing_tag("vip");
                 do_accounting("db","cdr");
                 if (isbflagset(NAT)) setflag(NAT);
         }
OpenSIPs2:
listen=udp:5.6.7.8:5060
listen=udp:10.11.12.13:5060
#### DIALOG module
loadmodule "dialog.so"
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "default_timeout", 21600)
modparam("dialog", "db_mode", 0)
modparam("dialog", "dlg_sharing_tag", "vip=backup")
modparam("dialog", "dialog_replication_cluster", 3)
modparam("dialog", "db_url","mysql://opensips:password@localhost/opensips")
same INVITE block
https://blog.voipxswitch.com/2017/12/26/kamailio-high-availability-using-keepalived/
Regards
---
I'm SoCIaL, MayBe
El 13/03/2020 a las 12:20, Sharad Kumar via Users escribió:
> Hi,
>
> Can you show us that how you are creating dialogs ? and where are you 
> setting your sharing tag, like this -
>
> set_dlg_sharing_tag("vip");
>
> Thank you
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200313/18123ca9/attachment.html>
    
    
More information about the Users
mailing list