Growing with A2Billing

A2Billing is a very flexible billing platform for Asterisk that is driven by a MySQL database. This database stores 99% of the A2Billing configuration including all of the rates, customers and system settings. In fact the only thing not stored in the database are the configuration details for MySQL itself.

There are a few different options for scaling out with A2Billing but one of the simplest comes from the fact that the A2Billing MySQL database does not need to be stored on the same machine as Asterisk (the server that is handling the call/audio). What this means is that you can start out with a single A2Billing server and when you need to add more call capacity you can deploy another A2Billing server, pointing to the database on the original machine.

This gives you 2 servers running Asterisk/A2Billing, but with one place to manage all of the customers, rates, call plans etc.

To achieve this you need to be running Asterisk RealTime (http://sysadminman.net/blog/2011/asterisk-realtime-and-a2billing-what-is-it-1737) and then just modify the MySQL connection details on the second server to point to the database on the original server in /etc/a2billing.conf –

[database]
hostname = remoteserver-ip
dbtype = mysql
port = 3306
user = DBUSER
password = DBPASS
dbname = DB

You will then need to add database access permissions on the server running MySQL. You will also need to open port 3306 on the database server, but just allow access to the additional A2Billing server.

I have several customers sucsessfully running the above configuration using the SysAdminMan template.

13 thoughts on “Growing with A2Billing

  1. Kkhan

    Thanks a lot for all these small guides you have written. All the time you have spent on writing these guidelines have saved time and money of so many people around the globe and we all appreciate all your hard work.

    Now about the above scenario I have the following questions:
    1) Will this method be good if the main a2billing/SQL Server is in another geographical location /country for redundancy purposes?
    2) What if I don’t want to have a2billing installed on all my servers, but just asterisk. Is it possible that asterisk machines from different locations be linked to the remote a2billing server? In that case where will I put the database config as I will not have a2billing.conf on each machine?
    3) Currently I am not using realtime on my main a2billing machine. Is it mandatory to have it on? In that case all I have to do is switch it on under “system settings” inside a2billing GUI? or do I have to do some extra steps as well?

  2. matt Post author

    Hi there,

    I’m glad you find the posts useful.

    1 – It could be useful for redundancy, although unless you are mirroring the MySQL database then you still just have one central place with all of your A2Billing configuration.
    2 – If you just have Asterisk on the server you could pass the call to A2Billing via a SIP trunk. If you want A2Billing to actually process the call on the server you would need a2billing installed on there (although not the database as that can obviously be on a different server)
    3 – If you want to use multiple a2billing servers that have SIP/IAX customers configured then you really want to be using real time as then all of the SIP users can be kept up to date on all of the a2billing servers, without it you would have to manually copy the SIP config files around and apply them.

    You do have to configure the realtime files in Asterisk, as well as enable it in the a2billing GUI.

  3. Kkhan

    Thanks for your reply Matt. I still need some more clarification on the following:

    2)
    a)Is it right that if want to bill the call it has to be processed by a2billing? If yes then I should install a2billing on every server but use the database of only the main server. BUT if I use a2billing without database on each VPS wouldn’t that be resource hungry?
    b) What are the chances of call completion if the main database server goes down? Will it be possible that calls may still be completed but without billing?
    c) In asterisk + a2billing (without database) scenario do I have to create trunks within asterisk/freepbx and use them or can I just mention the ip of my carrier inside a2billing GUI under “trunks”? which method is preferable?

    3)Please point me to the configuration example of realtime setup within FREEPBX/asterisk

    btw I am still using dedicated server from your friend in the US you recommended me 2 years ago. Thanks ๐Ÿ™‚

  4. matt Post author

    2a – Yes, if you want to bill the call it has to be processed by a2billing, but that could be a SIP trunk for another Asterisk server. It depends on the number of concurrent calls and the type of customers. If you want your customers to be able to make calling card and sip calls then you would have to have a2billing on each server. However, if they are just SIP customers you could just set the Asterisk to pass the call to a2billing on a different server as a trunk.

    If you have a few large volume SIP customers you would could have the central a2biling server and pass the calls over a trunk. If you have many low volume sip customers then probably better to have a2billing on each server (with a central MySQL database)

    2b – If you have a2billing on each server then if MySQL is not available the call will not get processed. If you are just passing the call to a2billing over a trunk from Asterisk it may be possible to have a backup trunk.

    2c – Not too sure exactly what you mean here. I think you would –

    Create a SIP customer in ABilling on your billing server
    Create a trunk on your asterisk/freepbx server. This trunk would use the a2billing SIP customer credentials. The call would then be processed/billed by a2billing.

    3 – I’ve not written a guide for it myself but something like this – http://forum.asterisk2billing.org/viewtopic.php?f=33&t=8505

    Glad you’re still getting on well with the server ๐Ÿ™‚

  5. Kkhan

    Thanks a lot Matt, people like you have made it possible for open source community to grow
    and yes, I am still with Scott and have upgraded my server 3 times till now ๐Ÿ™‚

  6. Hafee

    I appreciate to Matt efforts.I am testing my a2billing sytem with aterisk on my pc. I want to use my system only for calling cards users using soft phone (only outbound gateway). How I can enable only sip call and disable other all options like DID options? Do I need dahdi tools and asteriskโ€™s sample config files to install? Which software is best for two servers load balancing traffic distribution between two servers each having A2b+asterisk and one database connected with both?

  7. matt Post author

    You can disable options in the a2billing customer portal by going to A2Billing CUSTOMER, Groups. In there you can change what options the customer can see in the interface.

    You probably strictly don’t need Dahdi for pure SIP but I think it can help with timing.

    For load balancing between 2 A2Billing/Asterisk servers you could use something simple like DNS round robin, so that alternate customer connect to different Asterisk servers (which would have a single A2Billing database and use Asterisk Realtime).

    That’s not very sophisticated load balancing as it doesn’t take in to account the current load on the server, but it is easy to set up.

    For more active load balancing you would need something like OpenSIPS sat in front of the Asterisk servers to spread the load. Much more complicated to set up than DNS round robin!

  8. Fritz

    Good day,
    I need help recovering a password on a Asterisk platform, can someone help me on how to recover it.

    do appreciate your help.

    truly

    Fritz

  9. Glauco

    Matt:

    Can you show how to connect to the a2billing database using odbc? Have you a php script that does it? I am trying to update the a2B database using the IVR and by accesing the db. Is there a better way?

    Thanks for your great effort.

  10. matt Post author

    Hi Glauco.

    The database is just a MySQL database to you can access it with any language, such as PHP. Not too sure what you’re trying to do but you could have a IVR entry that called a PHP script to update the database. It’s not something I’ve done.

  11. Glauco

    Thanks Matt..That is exactly what I am trying to do…..have an IVR entry that calls a php script to search and update the a2b database. I read in your blog about the automated report script your friend sent to you..that could be the beginning but I don’t know how to incorporate something similar through the IVR.

    Thanks for your site..I have learned much from it and have had fun.. Thanks!!!

Comments are closed.