2016-09-05 5 views
0

우분투 14.04를 실행하는 가상 서버가 3 대 있습니다. 한 서버에서 Kamailio와 다른 별표를 설치했습니다. 나는 Kamailio 서버가로드 밸런서로 작동하고 들어오는 호출을 별표 서버 (라운드 로빈)로 전달하기를 원합니다.여러 별표 서버에 대한 부하 분산 장치로 Kamailio

하나의 별표 (*)를 사용하여 먼저 테스트하고 싶다면 더 많은 성능을 위해 더 추가 할 수 있습니다.

내가 이렇게 내 SIP 공급자 자격 증명을 추가 : 내 별표에 sip.conf 파일을 변경

INSERT INTO dispatcher (setid,destination,flags,priority,attrs,description) VALUES (1,"sip:10.1.1.3:5060",0,0,"","Asteriskl-I"); 

:이 같은 디스패처 테이블에 별표 (*) 서버를 추가 한 다음

kamctl add test testpasswd 

서버가 내 kamailio 서버에 연결되어 작동하는 것 같습니다.

내 kamailio.cfg 파일은 다음과 같다 : 내 SIP 공급자에게 직접 내 별표 박스를 연결하면

#!KAMAILIO 
 
# 
 
# sample config file for dispatcher module 
 
# - load balancing of VoIP calls with round robin 
 
# - no TPC listening 
 
# - don't dispatch REGISTER and presence requests 
 
# 
 
# Kamailio (OpenSER) SIP Server v3.2 
 
#  - web: http://www.kamailio.org 
 
#  - git: http://sip-router.org 
 
# 
 
# Direct your questions about this file to: [email protected] 
 
# 
 
# Refer to the Core CookBook at http://www.kamailio.org/dokuwiki/doku.php 
 
# for an explanation of possible statements, functions and parameters. 
 
# 
 
# Several features can be enabled using '#!define WITH_FEATURE' directives: 
 
# 
 
# *** To run in debug mode: 
 
#  - define WITH_DEBUG 
 
# 
 

 
####### Global Parameters ######### 
 

 
#!define WITH_DEBUG 
 

 
#!ifdef WITH_DEBUG 
 
debug=4 
 
log_stderror=yes 
 
#!else 
 
debug=2 
 
log_stderror=no 
 
#!endif 
 

 
memdbg=5 
 
memlog=5 
 

 
log_facility=LOG_LOCAL0 
 

 
fork=yes 
 
children=4 
 

 
/* comment the next line to enable TCP */ 
 
disable_tcp=yes 
 

 
/* uncomment the next line to disable the auto discovery of local aliases 
 
    based on revers DNS on IPs (default on) */ 
 
auto_aliases=no 
 

 
/* add local domain aliases */ 
 
# alias="mysipserver.com" 
 

 
port=5060 
 

 
/* uncomment and configure the following line if you want Kamailio to 
 
    bind on a specific interface/port/proto (default bind on all available) */ 
 
# listen=udp:127.0.0.1:5060 
 

 
sip_warning=no 
 

 
####### Modules Section ######## 
 

 
#set module path 
 
mpath="/usr/local/lib64/kamailio/modules/" 
 

 
# loadmodule "db_mysql.so" 
 
loadmodule "mi_fifo.so" 
 
loadmodule "kex.so" 
 
loadmodule "tm.so" 
 
loadmodule "tmx.so" 
 
loadmodule "sl.so" 
 
loadmodule "rr.so" 
 
loadmodule "pv.so" 
 
loadmodule "maxfwd.so" 
 
loadmodule "textops.so" 
 
loadmodule "siputils.so" 
 
loadmodule "xlog.so" 
 
loadmodule "sanity.so" 
 
# loadmodule "ctl.so" 
 
loadmodule "mi_rpc.so" 
 
loadmodule "acc.so" 
 
loadmodule "dispatcher.so" 
 

 

 
# ----------------- setting module-specific parameters --------------- 
 

 

 
# ----- mi_fifo params ----- 
 
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo") 
 

 

 
# ----- rr params ----- 
 
# add value to ;lr param to cope with most of the UAs 
 
modparam("rr", "enable_full_lr", 1) 
 
# do not append from tag to the RR (no need for this script) 
 
modparam("rr", "append_fromtag", 0) 
 

 

 
# ----- acc params ----- 
 
modparam("acc", "log_flag", 1) 
 
modparam("acc", "failed_transaction_flag", 3) 
 
modparam("acc", "log_extra", 
 
     "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si") 
 

 
# ----- tm params ----- 
 
modparam("tm", "fr_timer", 2000) 
 
modparam("tm", "fr_inv_timer", 40000) 
 

 
# ----- dispatcher params ----- 
 
# modparam("dispatcher", "db_url", 
 
#  "mysql://kamailio:[email protected]/kamailio") 
 
modparam("dispatcher", "table_name", "dispatcher") 
 
modparam("dispatcher", "flags", 2) 
 
modparam("dispatcher", "dst_avp", "$avp(AVP_DST)") 
 
modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)") 
 
modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)") 
 

 
####### Routing LogiC######## 
 

 

 
# main request routing logic 
 

 
route { 
 

 
     # per request initial checks 
 
     route(REQINIT); 
 

 
     # handle requests within SIP dialogs 
 
     route(WITHINDLG); 
 

 
     ### only initial requests (no To tag) 
 

 
     # CANCEL processing 
 
     if (is_method("CANCEL")) 
 
     { 
 
       if (t_check_trans()) 
 
         t_relay(); 
 
       exit; 
 
     } 
 

 
     t_check_trans(); 
 

 
     # record routing for dialog forming requests (in case they are routed) 
 
     # - remove preloaded route headers 
 
     remove_hf("Route"); 
 
     if (is_method("INVITE|SUBSCRIBE")) 
 
       record_route(); 
 
     #if (is_method("INVITE")) 
 
     #{ 
 
     #  ds_select_domain("1","4"); 
 
     #  #sl_send_reply("300","Redirect"); 
 
     #  #t_relay(); 
 
     #  exit; 
 
     #} 
 

 
     # account only INVITEs 
 
     if (is_method("INVITE")) 
 
     { 
 
       setflag(1); # do accounting 
 
     } 
 

 
     # handle presence related requests 
 
     route(PRESENCE); 
 

 
     # handle registrations 
 
     route(REGISTRAR); 
 

 
     if ($rU==$null) 
 
     { 
 
       # request with no Username in RURI 
 
       sl_send_reply("484","Address Incomplete"); 
 
       exit; 
 
     } 
 

 
     # dispatch destinations 
 
     route(DISPATCH); 
 

 
     route(RELAY); 
 
} 
 

 

 
route[RELAY] { 
 
     if (!t_relay()) { 
 
       sl_reply_error(); 
 
     } 
 
     exit; 
 
} 
 

 
# Per SIP request initial checks 
 
route[REQINIT] { 
 
     if (!mf_process_maxfwd_header("10")) { 
 
       sl_send_reply("483","Too Many Hops"); 
 
       exit; 
 
     } 
 

 
     if(!sanity_check("1511", "7")) 
 
     { 
 
       xlog("Malformed SIP message from $si:$sp\n"); 
 
       exit; 
 
     } 
 
} 
 

 
# Handle requests within SIP dialogs 
 
route[WITHINDLG] { 
 
     if (has_totag()) { 
 
       # sequential request withing a dialog should 
 
       # take the path determined by record-routing 
 
       if (loose_route()) { 
 
         if (is_method("BYE")) { 
 
           setflag(1); # do accounting ... 
 
           setflag(3); # ... even if the transaction fails 
 
         } 
 
         route(RELAY); 
 
       } else { 
 
         if (is_method("SUBSCRIBE") && uri == myself) { 
 
           # in-dialog subscribe requests 
 
           route(PRESENCE); 
 
           exit; 
 
         } 
 
         if (is_method("ACK")) { 
 
           if (t_check_trans()) { 
 
             # non loose-route, but stateful ACK; 
 
             # must be ACK after a 487 or e.g. 404 from upstream server 
 
             t_relay(); 
 
             exit; 
 
           } else { 
 
             # ACK without matching transaction ... ignore and discard. 
 
             exit; 
 
           } 
 
         } 
 
         sl_send_reply("404","Not here"); 
 
       } 
 
       exit; 
 
     } 
 
} 
 

 
# Handle SIP registrations 
 
route[REGISTRAR] { 
 
     if(!is_method("REGISTER")) 
 
       return; 
 
     #sl_send_reply("404", "No registrar"); 
 
     #t_relay(); 
 
     if(!ds_select_dst("1", "4")) 
 
     { 
 
       sl_send_reply("404", "No registrar"); 
 
       exit; 
 
     } 
 
     forward(); 
 

 
     exit; 
 
} 
 

 
# Presence server route 
 
route[PRESENCE] { 
 
     if(!is_method("PUBLISH|SUBSCRIBE")) 
 
       return; 
 

 
     sl_send_reply("404", "Not here"); 
 
     exit; 
 
} 
 

 
# Dispatch requests 
 
route[DISPATCH] { 
 
     # round robin dispatching on gateways group '1' 
 
     if(!ds_select_dst("1", "4")) 
 
     { 
 
       send_reply("404", "No destination"); 
 
       exit; 
 
     } 
 
     xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n"); 
 
     t_on_failure("RTF_DISPATCH"); 
 
     return; 
 
} 
 

 
# Sample failure route 
 
failure_route[RTF_DISPATCH] { 
 
     if (t_is_canceled()) { 
 
       exit; 
 
     } 
 
     # next DST - only for 500 or local timeout 
 
     if (t_check_status("500") 
 
         or (t_branch_timeout() and !t_branch_replied())) 
 
     { 
 
       if(ds_next_dst()) 
 
       { 
 
         t_on_failure("RTF_DISPATCH"); 
 
         route(RELAY); 
 
         exit; 
 
       } 
 
     } 
 
}

은 완벽하게 작동합니다. 그러나 kamailio 서버와 kamailio 서버를 SIP 공급자에 연결하면 그렇지 않습니다.

나는 몇 시간 동안 인터넷 검색을하고 많은 일을 시도했으며 실제로 다음에 시도 할 수있는 것에 대해 전혀 몰랐습니다 ... 누군가가 나를 도울 수 있다면 매우 행복 할 것입니다!

은 대단히 감사 안부

kamctl add test testpasswd

+0

당신이 정확히 어떤 문제 : 당신은 어떻게 설정해야 사용자 이름을 사용하는 Kamailio에 SIP 트렁크/암호 인증을 자세한 정보를 원하시면 링크를

확인? kamailio와 함께 제공되는 기본 디스패처 구성은 ok 및 nat 및 기타 기능 (매우 특수한 지식 집합이 필요함)을 추가하지 않는 한 괜찮습니다. 왜 몇 시간 동안 google을하셨습니까? 당신은 (tcpdump 또는 무언가를 사용하여) sip 디버깅을하고 설정이 올바른지 확인해야합니다. – arheops

+0

방화벽이 있으니 안되니? – arheops

답변

0

I added my SIP provider credentials like this: - 이것은 잘못된 것입니다.

http://lists.sip-router.org/pipermail/sr-users/2015-September/090001.html

+0

안녕하세요 os11k, 답변 해 주셔서 대단히 감사합니다! 이 인증을 사용하여 구성하려고했습니다. kamailio.cfg가 다음과 같이 나타납니다. http://pastebin.com/H6R8mZ0g 컴파일되지만 번호로 전화를 걸면 여전히 작동하지 않습니다. 어떤 생각? – simplex

+0

나는 이것을 uac 모듈과 함께 시도했지만 작동시키지 못한다. 나는이 정보를 가지고 : SIP 공급자 : 이름 비밀번호 도메인 어떻게 내 kamailio.cfg이 같아야를? uac 모듈을 사용하여 10 가지 변형을 시도했습니다. 또는 어떻게 내 kamailio 서버를 내 SIP 공급자에 등록 할 수 있습니까? – simplex

+0

확인 : http://www.kamailio.org/docs/modules/4.4.x/modules/uac.html#idp23591108 uacreg 테이블에 레코드를 추가해야한다고 나와 있습니다. – os11k