Below are instructions for setting up A2Billing with a MySQL Master/Slave database. In this configuration the A2Billing database is replicated to a standby/slave server. Whilst it would require a manual failover to the standy server, the configuration is pretty simple and easy to manage.
It also walks through setting up A2Billing load balancing across multiple Asterisk servers. This relies on Asterisk/A2Billing being configured to use RealTime, which it is by default on the SysAdminMan template.
All 3 servers used were built using the SysAdminMan VPS template. You will need to change IP addresses throughout the instructions to match your server IPs. The test servers used are –
While the instructions are quite long the outline of what is happening is –
Open MySQL ports in the firewall
Edit /etc/my.cnf and under the [mysqld] section ensure the following settings are set –
Restart MySQL
Create a MySQL user to allow replication from the Standby server
Dump the mya2billing database and copy it to the Slave server
Make a note of the database log file and position. You will need these later on. Do this while the Master database is not being updated.
Make a note of the existing A2Billing database password being used. We will use it later.
Open ports in the firewall for MySQL
Edit /etc/my.cnf and under the [mysqld] section ensure the following settings are changed/set –
Create a fresh database and assign some permissions in case we need to failover to using this as the primary.
Set the slave replication settings. You will need to change the settings below to reflect the IP of the Master plus the log file and position settings you noted earlier
Import the mya2billing database and restart MySQL
Check that the replication looks ok. Ensure – Slave_IO_State: Waiting for master to send event.
Next we need to tell A2Billing and Asterisk to use the mya2billing MySQL database on the Master database server.
Grant permissions to be allow secondary Asterisk/A2Billing servers to connect.
Edit /etc/a2billing.conf and ensure the following are changed.
Edit /etc/asterisk/res_config_mysql.conf and ensure the following are changed under the [mya2billing] context.
Edit /etc/a2billing.conf and ensure the following are changed.
Edit /etc/asterisk/res_config_mysql.conf and ensure the following are changed under the [mya2billing] context.
Remember that anything that you don’t change via A2Billing you will need to do on all three servers. If it’s changed in A2Billing then it will be stored in the database, and accessible by all 3 servers.
Common things that you may need to do on all 3 servers are –
And that’s replication set up. If everything has worked correctly you should be able to create your rates, customers, trunks etc. If you then create a SIP account you should be able to point a SIP phone to any of the 3 servers and make a call.
See some ideas in Part 2 for simple load balancing.
1 comment. Leave new
Hello,
i have configured master/slave mysql servers as described in your tutorial, replication works fine in some tables but in cc_card table this replication didn’t work i have this error: access denied; you need the super privilege for this operation on query. Default database mya2billing. Query update cc_ratecard …..
I have add all privileges to replication_user but still the same error message