[asterisk-ha-clustering] Load sharing between two asterisk servers

Allan Cassaro allan.cassaro at gmail.com
Mon Jan 14 09:47:32 CST 2008


On Mon,  14 Jan 2008 16:35 +0200, Yehavi Bourvine +972-8-9489444
<YEHAVI at vms.huji.ac.il> wrote:
> > You can use DRBD for keeping a synced AstDB (/var/lib/asterisk/astdb)
> > between both systems. Although you'll need heartbeat for mounting the
> > DRBD partition when the standby machine becomes active.
> >
> > Julián J. M.
>
> But how do you sync AstDB when in Active/Active mode? DRBD is a one way
> replication.
>
> Is there any way of telling Asterisk to use MySQL or ODBC for AstDB? This way I
> can use MySQL two-way synchronization.
>
>                                           Thanks! __Yehavi:

Well, I don't use AstDB. All operations that need a database I use the
"MYSQL" command. Everything is loaded into a remote mysql (cluster)
shared between asterisks boxes.
Yes I know, asterisk put some internal info/control into astdb, but
this never has a trouble for me...
Looking into astdb I only see a lot of devstate and registration
information... not that look so important...

I simulate into mysql the astdb functions, like this:

[logonlogoff]
exten => *0,1,Answer()
exten => *0,n,Wait(1)
; Read password
exten => *0,n,MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME})
exten => *0,n,MYSQL(Query result ${connid} SELECT\ password\ FROM\
voicemail_users\ WHERE\ mailbox\ LIKE\ \'${CALLERID(num)}\')
exten => *0,n,MYSQL(Fetch fetchid ${result} PASSWD)
exten => *0,n,MYSQL(Clear ${result})
; Look state
exten => *0,n,MYSQL(Query result ${connid} SELECT\ value\ FROM\ astdb\
WHERE\ exten\ LIKE\ \'${CALLERID(num)}\'\ AND\ type=\'login\')
exten => *0,n,MYSQL(Fetch fetchid ${result} BLOCKED)
exten => *0,n,MYSQL(Disconnect ${connid})
exten => *0,n,GotoIf($["${BLOCKED}" == ""]?block:unblock)
; Unblock
exten => *0,n(unblock),Read(USRPASSWD,vm-password,6,s,3,8)
exten => *0,n,GotoIf($["${USRPASSWD}" != "${PASSWD}"]?unblock)
exten => *0,n,MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME})
exten => *0,n,MYSQL(Query result ${connid} DELETE\ FROM\ astdb\ WHERE\
exten\=\'${CALLERID(num)}\'\ AND\ type=\'login\')
exten => *0,n,MYSQL(Disconnect ${connid})
exten => *0,n,Playback(unblocked)
exten => *0,n,Hangup
; Block
exten => *0,n(block),MYSQL(Connect connid ${DBHOST} ${DBUSER}
${DBPASS} ${DBNAME})
exten => *0,n,MYSQL(Query result ${connid} DELETE\ FROM\ astdb\ WHERE\
exten\=\'${CALLERID(num)}\'\ AND\ type=\'login\')
exten => *0,n,MYSQL(Query result ${connid} INSERT\ INTO\ astdb\
(exten\,type\,value)\
VALUES(\'${CALLERID(num)}\'\,\'login\'\,\'blocked\'))
exten => *0,n,MYSQL(Disconnect ${connid})
exten => *0,n,Playback(blocked)
exten => *0,n,Hangup

Regards.



More information about the asterisk-ha-clustering mailing list