On Wed, 19 Aug 2009, ABBAS SHAKEEL wrote:

> Rsync looks really great !

Yep. Something I wish I learned about earlier in my career :)

> How you are get CDR records etc from the remote servers for reporting 
> purpose ..... I was thinking to have one centralized database ? but your 
> comments let me think about distributed database ?

I like having a database at each datacenter for autonomy and performance.

Periodically, the master database executes a script with the following 
snippet (error checking and irrelevant details removed for brevity):

# for each host
         for     HOST in ${HOST_LIST}
         do

${DATE} "+%T Mark the records on ${HOST} to be collected."
                 mysql\
                         ${USER_AUTH}\
                         --databa...@database_database@\
                         --execute="update cdrs set disposition = 'COLLECTING'"\
                         --execute=" where disposition is NULL;"\
                         --host=${HOST}\
                         ${END_OF_LIST}

${DATE} "+%T Dump the marked records from ${HOST}."
                 mysqldump\
                         ${USER_AUTH}\
                         --databases @database_datab...@\
                         --host=${HOST}\
                         --no-create-info\
                         --skip-opt\
                         --tables cdrs\
                         --where="disposition = 'COLLECTING'"\
                         >/tmp/${HOST}.sql\
                         ${END_OF_LIST}

${DATE} "+%T Load the records from ${HOST} into our database."
                 mysql\
                         ${USER_AUTH}\
                         --databa...@database_database@\
                         --host=localhost\
                         </tmp/${HOST}.sql\
                         ${END_OF_LIST}

${DATE} "+%T Compressing the dump file from ${HOST}."
                 gzip /tmp/${HOST}.sql
                 mv /tmp/${HOST}.sql.gz /tmp/${HOST}.sql.gz-${TIMESTAMP}

${DATE} "+%T Delete the collected records from ${HOST}."
                 mysql ${USER_AUTH}\
                         --databa...@database_database@\
                         --execute="delete from cdrs where disposition = 
'COLLECTING';"\
                         --host=${HOST}\
                         ${END_OF_LIST}

${DATE} "+%T Set the disposition on this host."
                 mysql ${USER_AUTH}\
                         --database=${DATABASE_DATABASE}\
                         --execute="update cdrs set disposition = 'COLLECTED'"\
                         --execute=" where disposition = 'COLLECTING';"\
                         --host=localhost\
                         ${END_OF_LIST}

# end of hosts loop
         done

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwa...@sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000

_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

AstriCon 2009 - October 13 - 15 Phoenix, Arizona
Register Now: http://www.astricon.net

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to