Opensips load balancing cluster

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Opensips load balancing cluster

mark morreny
Hi,
 
I am working on setting up a cluster of opensips server.  Opensips is writing the urs_loc info in the location table of mysql.  Let's say usc-a registers with opensips-A and usc-b registers with opensips-B, when usc-a calls usc-b, opensips would say that the user is not found.  Both usc-a and usc-b data is in the location identified by the different opensips's ip.  Does anyone know how to make the two opensips to share the registration infoation?
 
Thanks,
Mark

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Opensips load balancing cluster

Gustavo Mistrinelli
Hi Mark, I'm sending below code to meet your request.
On each server you need to put it code inside REGISTER method and replace LOCAL_IP, PAIR_IP with your real information
When one OpenSIPS receive a REGISTER save it in memory and database and then send it to the other pair OpenSIPS.

...
# Register method

  if ( !(src_ip=="PAIR_IP" && src_port==5060) ) {
    # Register is for me
    if (!save("location")) {
      sl_reply_error();
      exit;
    }
    add_sock_hdr("Local-Sock");
    force_send_socket( "LOCAL_IP");
    t_replicate("sip:PAIR_IP:5060"); # send to the other sip server
  } else {
    # it's a replicated REGISTER
    # set the flag for retrieving sock_info from header
    # save contact, but only in cache
    save("location","0x01");
  };

I hope my can undertand my explanation and code.

Cheers,

Gustavo

On Fri, Nov 28, 2008 at 12:36 AM, mark morreny <[hidden email]> wrote:
Hi,
 
I am working on setting up a cluster of opensips server.  Opensips is writing the urs_loc info in the location table of mysql.  Let's say usc-a registers with opensips-A and usc-b registers with opensips-B, when usc-a calls usc-b, opensips would say that the user is not found.  Both usc-a and usc-b data is in the location identified by the different opensips's ip.  Does anyone know how to make the two opensips to share the registration infoation?
 
Thanks,
Mark

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Gustavo Mistrinelli

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Opensips load balancing cluster

Gustavo Mistrinelli
Hi mark,  the entire solution that I sent needs to save registration to database, then when one opensips bring up load at start up all registration saved on database to memory.
Both opensips must connect to the same database, then you need MySQL server located on another server, then you will be thinking about MySQL HA problem.. but it's another topic :)

Best,

Gustavo

On Tue, Dec 2, 2008 at 10:18 AM, mark morreny <[hidden email]> wrote:
Hi,

This solution will work for me but it may not solve the whole problem.  Let's say when the server is bought back up, it will start off with no registration information.  When the B2BUA sends it the INVITE request, it would then reply User Not Found, even that user is already registered with the other opensips servers. 

Is there a solution for this problem?

Alternatively, maybe I can write the location into db, but that means each opensips would have to replicate the info in the db for all the users.  This is also not a very nice option either. 

Is there anyway for all the opensips server to share the info in one single db table?  It looks like in the location table, there is a domain field and each opensips only identify the users under its own domain.

Any suggestion will be greatly appreciated.


Thanks,
Mark




On Fri, Nov 28, 2008 at 11:03 AM, Gustavo Mistrinelli <[hidden email]> wrote:
Hi Mark, I'm sending below code to meet your request.
On each server you need to put it code inside REGISTER method and replace LOCAL_IP, PAIR_IP with your real information
When one OpenSIPS receive a REGISTER save it in memory and database and then send it to the other pair OpenSIPS.

...
# Register method

  if ( !(src_ip=="PAIR_IP" && src_port==5060) ) {
    # Register is for me
    if (!save("location")) {
      sl_reply_error();
      exit;
    }
    add_sock_hdr("Local-Sock");
    force_send_socket( "LOCAL_IP");
    t_replicate("sip:PAIR_IP:5060"); # send to the other sip server
  } else {
    # it's a replicated REGISTER
    # set the flag for retrieving sock_info from header
    # save contact, but only in cache
    save("location","0x01");
  };

I hope my can undertand my explanation and code.

Cheers,

Gustavo

On Fri, Nov 28, 2008 at 12:36 AM, mark morreny <[hidden email]> wrote:
Hi,
 
I am working on setting up a cluster of opensips server.  Opensips is writing the urs_loc info in the location table of mysql.  Let's say usc-a registers with opensips-A and usc-b registers with opensips-B, when usc-a calls usc-b, opensips would say that the user is not found.  Both usc-a and usc-b data is in the location identified by the different opensips's ip.  Does anyone know how to make the two opensips to share the registration infoation?
 
Thanks,
Mark

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
Gustavo Mistrinelli




--
Gustavo Mistrinelli

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users