+ All Categories
Home > Documents > why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Date post: 28-Jul-2015
Category:
Upload: narijayu
View: 48 times
Download: 1 times
Share this document with a friend
Popular Tags:
59
Why Cluster? Exploring some of the decentralizing tools in Asterisk 1.4 and beyond
Transcript
Page 1: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Why Cluster?Exploring some of the decentralizing

tools in Asterisk 1.4 and beyond

Page 2: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Overview• We'll look at some of the currently

available tools in Asterisk we can use for clustering, in addition to making you aware of the tools that can further be used in our quest for a distributed federation of servers in future versions of Asterisk -- right around the corner!

Page 3: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Overview• A high level overview of topologies and

technologies we can use right now to start building distributed systems, but we don't have time to look at every nut and bolt

Page 4: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Overview• Will be from the view of my personal

experience in building a distributed virtual PBX system for an Internet Telephony Service Provider, and any tools I am familiar with that may be of a benefit to you (and me), in the future

• Clustering comes in many flavours, and a "drop in" solution is not yet possible

Page 5: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Why do I want to cluster?• Lets you scale up the number of calls

simply by adding another node (server)• If a server dies, the rest of the cluster will

take over the load

Page 6: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

"#$%&'(')*#+!,-*(*.#/

0 !"#$%&'()*+,+-.()*+,+-(()*!!"#$#%#&'(

0 /0123456+!"#$#%#&')#%&$*#+$,-.)/#0'*(

0 4/741!!,.1-*2#$,-.)34'*0)&0&$'2(

0 ($8$19+:+4.08;19+<'8=$1;'!!+'.$*#/,5'")+-.1,64*#$,-.(

0 >?09@"AB9!!784&$),.)$,2'9)"#$#)1*-2)$:');<),.$-)$:')",#/=/#.(

0 1&/!2'3#4

Page 7: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Single Server

Page 8: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Single Server• Handles all features of your PBX system• No redundancy, no fail-over; if the

system goes down, your phones are down

• Typical system would handle 20 phones and 2-4 phone lines

Page 9: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Multi-Server

Page 10: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Multi-Server• Multiple boxes, each one handles one or

more services• Voicemail server, Queue server,

Conferencing server, etc...• Lets you scale a bit better by directing

heavy load applications to dedicated machines

Page 11: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Cluster Topologies• Centralized registration server• Distributed registration server• Hybrid registration server

Page 12: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

5#&-36(*.#/!7#)*+-36-*'&!8#39#3

0 5#&-36(!:'*&-!;'3!3#)*+-36-*'&<!/*+-3*=>-#+!$6((+!-'!2#/*6!+#39#3+

0 ?%'&#+!3#)*+-#3!-'!6!+*&)(#!:'*&-@!6&/!-%6-!+#39#3!$'&-3'(+!/*+-3*=>-*'&!A-%*&B!+';-+C*-$%!D!3'>-#3E

0 56&!=#!'&#!';!+#9#36(!2#-%'/+F!G/#6((H!*)&'3#+!2#/*6!AI:#&8J7<!1+-#3*+B<!K3##+C*-$%FFFE

0 1((!#&/:'*&-+!3#)*+-#3!-'!6!+*&)(#!:(6$#@!+'!!!!!!!&'!&##/!-'!+##B!-%#2!'>-

Page 13: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 14: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 15: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 16: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 17: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 18: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*!"#$%&%#!%'()'

!"#$%&%#!%*!+,-.%&/0/123/4567893*:89;<=

45;9>?@7AB!"#$%&%#!%CAD451E1<@>;F>@A

G,%,%-'()'

G,%,%-*!+,-.%&/0/123/4567893*:89;<=

45;9>?@7ABG,%,%-CAD451E1<@>;F>@A

.&,#H*,-IJ%'()'

.&,#H*,-IJ%/0/123/4567893*:89;<=45;9>?@7AB,-IJ%C'

AD451E1<@>;F>@A

Page 19: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*

!"#$%&%#!%'()'

!"#$%&%#!%*!+,-.%&/0/123/4567893*:89;<=

45;9>?@7AB!"#$%&%#!%CAD451E1<@>;F>@A

L,ML*!7#+'>3$#!M62#

Page 20: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*

!"#$%&%#!%'()'

!"#$%&%#!%'!()*+%&/0/123/4567893*:89;<=

45;9>?@7AB!"#$%&%#!%CAD451E1<@>;F>@A

L*6(:(6&!$'&-#N-!-'!:#3;'32!(''B>:

Page 21: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*

!"#$%&%#!%'()'

!"#$%&%#!%*!+,-.%&/,/123/4567893*:89;<=

45;9>?@7AB!"#$%&%#!%CAD451E1<@>;F>@A

O#*)%-!A.#3'!*+!%*)%#+-!C#*)%-E

Page 22: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*

!"#$%&%#!%'()'

!"#$%&%#!%*!+,-.%&/0/-.//4567893*:89;<=

45;9>?@7AB!"#$%&%#!%CAD451E1<@>;F>@A

"#$%&'(')H!3#+'>3$#!ACD4/74EF6GH!/*6(:(6&!963*6=(#E

Page 23: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

,+*&)!/*6(:(6&!;>&$-*'&+!C*-%!L,ML*

!"#$%&%#!%'()'

!"#$%&%#!%*!+,-.%&/0/123/012345/'645789

0175:;<3=>!"#$%&%#!%?=@01-A-8<:7B:<=

7#+>(-!3#->3&#/!*&!CD4/744F(EHJN62:(#P!

QRL,MLLJ8"S!3#->3&#/!TTU+H+-#2I&#

Page 24: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

DUNDIRESULT() and DUNDIQUERY()

• Unfortunately, in 1.4, we have to query each server individually – but in 1.6, we have solved this with DUNDIQUERY() and DUNDIRESULT()

• DUNDIQUERY() retrieves the data from the servers, and DUNDIRESULT() parses it

Page 25: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

DUNDIQUERY()!JN62:(#

exten => _X.,1,Set(ID=${DUNDIQUERY(${USERNAME},trunk_usage,b)})exten => _X.,n,Set(NUM=${DUNDIRESULT(${ID},getnum)}) exten => _X.,n,NoOp(There are ${NUM} results) exten => _X.,n,Set(X=1) exten => _X.,n,While($[${X} <= ${NUM}]) exten => _X.,n,NoOp(Result ${X} is ${DUNDIRESULT(${ID},${X})}) exten => _X.,n,Set(X=$[${X} + 1]) exten => _X.,n,EndWhile()

Page 26: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 27: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 28: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 29: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 30: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Centralized Advantages• Easier to control where to send calls

based on prior load testing (DUNDi and GROUP_COUNT function)

• May be simpler to administer (hub and spoke topology)

Page 31: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Centralized Disadvantages• It's... well... centralized -- single point of

failure• May be a ceiling on the number of

registrations the server can handle

Page 32: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Distributed registration server• No centralized distribution server• Phones can register to any server in the

cluster• Asterisk seeks out the registration point and

delivers the call• Uses DUNDi and regexten/regcontext methods

(found in sip.conf and iax.conf) to find endpoints

Page 33: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 34: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 35: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 36: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 37: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 38: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Sample Call Flow

Page 39: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Failed Registration Server

Page 40: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Distributed Advantages• No central registration point to fail;

phones can auto-failover• Creates a "self-healing" network by

nature

Page 41: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Distributed Disadvantages• Harder to control number of calls each

server handles• Requires careful network planning in

order to scale• Fully meshed networks are fault tolerant,

but are not (reasonably) scalable

Page 42: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Hybrid registration server• Combine the advantages of distributed and centralized

registration servers• Utilize heartbeat to auto-failover registration server to

another server in the LAN• OR, run a pair of registration servers, balance the

registrations between them, and have the phones fail-over if a server dies

• Still have separate servers handle media and processing of calls based on prior load testing

Page 43: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Hybrid topology

Page 44: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Hybrid Advantages• Get the best of both distributed and

centralized models• Better tolerance to system failure

Page 45: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Hybrid Disadvantages• May be more complicated of a topology

to initially configure and maintain• More technologies involved could

possibly mean more places to break

Page 46: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Clustering Tools• DUNDi• Realtime / UnixODBC

(database integration)• func_odbc• Centralized voicemail: IMAP or ODBC

Page 47: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

DUNDi(Distributed Universal Number Discovery)

• Is utilized to get information from other servers in the cluster

• We then use the returned information in our dialplan to make decisions

• Example: how many calls is a remote box currently handling?

• Another example: Is the Queue() a channel looking for currently available elsewhere in the cluster? If so, we should probably redirect the call

Page 48: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Realtime and UnixODBC• Realtime allows you to place your flatfile configuration files

(e.g. sip.conf) into the database. This allows multiple boxes to read and manipulate the same data as if it were a single system

• Could create a script to pull the data from the database, generate a flatfile and write it to the diskdrive, but this is messy...

• UnixODBC is a database communication abstraction layer that lets Asterisk talk to a single interface, but communicate with multiple databases (MySQL, PostgresSQL, etc...)

Page 49: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

func_odbc• The coolest tool at our disposal – no more AGI• Read and write data from the database directly

from the dialplan• Manipulate and retrieve the same data your

graphical system is using (i.e. one data entry point)

• The power of func_odbc is best described by looking at an example

Page 50: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

;>&$V'/=$!+62:(#0 ;>&$V'/=$F$'&;

[ROUTE]readhandle=asteriskprefix=GETreadsql=SELECT did_source,did_destination,did_dest_address_id FROM ast_did_route WHERE did_number = '${ARG1}'

0 #N-#&+*'&+F$'&;

exten => s,n,Set(HASH(MY_ROUTE)=${GET_ROUTE(${DID})})

exten => s,n,Verbose(1,${HASH(MY_ROUTE,did_source)})

Page 51: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

(I'm cheating a bit...)• svn co

http://svncommunity.digium.com/svn/func_odbc/1.4 /usr/src/func_odbc-1.4

• svn co http://svncommunity.digium.com/svn/app_stack/1.4 /usr/src/app_stack-1.4

• app_stack gives us:– GoSub()– GoSubIf()– Return()– StackPop()

Page 52: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Voicemail• We can centralize our voicemail using

IMAP or ODBC storage• This way, we don't have pieces of

voicemail all over the place, and we don't need to rely on a single server for voicemail -- all servers in the cluster can handle voicemail

Page 53: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

"#$%&%'$(#)!*%+$,&%'

- ./%'%!0%+$,&%'!+&%!(#!1'$%&('2!34546!+#7!8(99!:+2%!:+#;!<0!$/%!$&(=2'!&%>,(&%7!(#!34?!#<!9<#)%&!#%=%''+&;@

A 17+B$(C%!DEF!0<&!GEHD@!%+'(9;!+77!#%8!=<9,:#'!$<!;<,&!DEF!&%=<&7'

A 0,#=I7%C'$+$%@!=,'$<:(J%!7%C(=%!'$+$%!(#0<&:+$(<#!0&<:!$/%!7(+9B9+#

A 1==%''!+99!&%',9$'!0&<:!+!EKLE(!>,%&;!MEKLE"NKOFP!+#7!EKLE"FOQKR.!0,#=$(<#'S

A E;#+:(=!8%()/$!=<#$&<9!(#!EKLE(

Page 54: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

What does the future hold?• Current efforts include a binary encoded

system inside of Asterisk, allowing events to be sent across servers

• The first example of this would be Message Waiting Indication for Voicemail() being distributed across various boxes

Page 55: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

What does the future hold?• Another application would be sharing

device state amongst the cluster• Immediately this would be useful for

sharing presence information, and is a prerequisite for building distributed systems that depend on device states; distributed queues for example

Page 56: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

"#$!%&'&($!)*!+,-.!/012!($023!4,(!'$*'5167

8 4&19:2$;*'0'$<!=01&0>>3!*$'!'#$!2$;59$!*'0'$!,4!0!2$;59$!51!'#$!250>?>01

@ A09B?,('!0;05>0A>$!C#''?<DD*;19,==&15'3E2565&=E9,=D*;1D(&**$>>D0*'$(5*BFGEHD4&19:2$;*'0'$FGEHD

8 I5*'(5A&'$2!2$;59$!*'0'$!/51!2$;$>,?=$1'7

@ J*$*!K?$1L)M!>5A(0(3

@ N5>>!1,'!#0;$!0!A09B?,('!2&$!',!9,=?>$O5'3#''?<DD*;1E2565&=E9,=D*;1D0*'$(5*BD'$0=D(&**$>>D$;$1'*D

Page 57: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

+,-!)*!"#$!%&'&($.

8 PIQ!L20?'5;$!KIRP

@ 9&*',=!9,>&=1*!=02$!$0*3.#''?<DD*;19,==&15'3E2565&=E9,=D*;1D'5>6#=01DA(019#$*DGEHD92(:020?'5;$:,2A9E9

8 S,M&A!D!S,M&A)4!D!M'09BT,?

@1,-!-5'#!0(6&=$1'*.!/U09(,!($?>09$=$1'7GoSub(subCallForward,s,1(${USERNAME}))

#''?<DD*;19,==&15'3E2565&=E9,=D*;1D0??:*'09BDGEV L*'$(5*B!GEV!A09B?,('

#''?<DD*;19,==&15'3E2565&=E9,=D*;1D0??:*'09BDGEH L*'$(5*B!GEH!A09B?,('

Page 58: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

Questions and Discussion

Page 59: why-cluster-an-introduction-to-asterisk-clustering-and-database-integration-astricon-2008

! !

!"#$%&$'(#)"*+%$,"#

!"#$%&'()"*

+,,-.//00012"#$3'()"*14532"#$6(#7#831453,0#,,"9.%2"#$:3'()"*


Recommended