安装并配置opensips作为freeswitch的负载均衡器

时间:2019-11-29 10:42:53

标签: freeswitch opensips

我正在尝试通过以下链接将opensips配置为freeswitch的负载均衡器,但是按照那里提到的步骤,那里写的过程似乎很老,并且遇到很多问题。

https://freeswitch.org/confluence/display/FREESWITCH/Enterprise+deployment+OpenSIPS

有人可以分享这种情况的确切配置示例,我可以在最新的ubuntu版本中进行了解。谢谢

1 个答案:

答案 0 :(得分:0)

我们可以根据资源的可用性以多种方式使用 opensips 或 kamailio 作为 sip 负载均衡器和高可用性服务。我写了一个分步指南here

enter image description here

安装 openSIPS:

按照 this guide 安装 openSIPS 2.4 并使用以下配置编辑 opensips.cfg 。

如果您没有配置高可用性并仅在 openSIPS 上本地托管 mysql 数据库,那么您可能需要使用 localhost 或 127.0.0.1

并更改数据库凭据和 SIP 侦听地址。

vi /etc/opensips/opensips.cfg

log_level=4

sip_warning=0

log_stderror=no

log_facility=LOG_LOCAL2

log_name="opensips"

debug_mode=yes

children=4

dns_try_ipv6=no

auto_aliases=no

#advertised_address="12.135.59.0"

mhomed=1

listen=udp:10.128.0.1:5060

mpath="/usr/lib64/opensips/modules"

loadmodule "db_mysql.so"

loadmodule "signaling.so"

loadmodule "sl.so"

loadmodule "tm.so"

loadmodule "rr.so"

loadmodule "uri.so"

loadmodule "dialog.so"

loadmodule "maxfwd.so"

loadmodule "textops.so"

loadmodule "mi_fifo.so"

loadmodule "dispatcher.so"

loadmodule "load_balancer.so"

loadmodule "sipmsgops.so"

loadmodule "proto_udp.so"

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

modparam("dialog", "db_mode", 1)

#change database credentials below

#if this is the only openSIPS node in network and you are using HighAvailability use mysql database host as localhost or 127.0.0.1

modparam("dialog", "db_url", "mysql://abc:123@11.11.11.11/opensips") modparam("rr", "enable_double_rr", 0)

modparam("rr", "append_fromtag", 1)

modparam("tm", "fr_timer", 2)

#change database credentials below

modparam("dispatcher", "db_url", "mysql://abc:123@11.11.11.11/opensips")

modparam("dispatcher", "ds_ping_method", "OPTIONS")

modparam("dispatcher", "ds_ping_interval", 5)

modparam("dispatcher", "ds_probing_threshhold", 2)

modparam("dispatcher", "ds_probing_mode", 1)

modparam("load_balancer", "db_url", "mysql://abc:123@11.11.11.11/opensips")

modparam("load_balancer", "probing_method", "OPTIONS")

modparam("load_balancer", "probing_interval", 5)

route{



        if (!mf_process_maxfwd_header("10")) {



                sl_send_reply("483","Too Many Hops");



                exit;



        }





        if (!has_totag()) {



                record_route();



        }



        else {



                loose_route();



                t_relay();



                exit;



        }



        if (is_method("CANCEL")) {



                if (t_check_trans())



                        t_relay();



                exit;



        }



        if (is_method("INVITE")) {



                if (!load_balance("1","pstn","1")) {

log("sreekanth invite method\n");

                        send_reply("503","Service Unavailable");



                        exit;



                }



        }



        else if (is_method("REGISTER")) {



                if (!ds_select_dst("1", "4")) {



                        send_reply("503","Service Unavailable");



                        exit;



                }



        }



        else {



                send_reply("405","Method Not Allowed");



                exit;



        }



        if (!t_relay()) {



                sl_reply_error();



        }

}

现在我们需要在opensips数据库的loadbalance和dispatch表中插入条目

插入 opensips.load_balancer (id, group_id, dst_uri, resources, probe_mode, {{1 }}) VALUES ('1', '1','sip:10.10.10.5','vm=100;conf=100;transc=100;pstn=500','1','FS1');

插入 description.opensips (load_balancer, id, group_id, dst_uri, resources, {{1 }}) VALUES ('2', '1','sip:10.10.10.4','vm=100;conf=100;transc=100;pstn=500','1','FS2');

并在调度表中插入记录。

插入probe_mode.description (opensips, dispatcher, id, setid, destination, {{1 }}, socket, state, weight) VALUES ('1', '1','sip:10.10.10.5:5060','','0', '1 ', '1','','FS1');

插入priority.attrs (description, opensips, dispatcher, id, setid, {{1 }}, destination, socket, state) VALUES ('1', '1','sip:10.10.10.4:5060','','0', '1 ', '1','','FS2');

配置 Freeswitch:

在 freeswitch /etc/freeswitch/vars.xml 中将域更改为 opensips 域名。并重新加载 freeswitch