|
Dual Server Operation in DataTechLabs ArrowBilling |
|
Friday, 20 April 2007 |
This Howto describes principles of Dual-Server setup opreation with Data Tech Labs Arrow Billing. The purpose of Dual Server setup is to provide live copy of database. This database can be used as backup when primary database becomes unavailable, crashed or corrupted. The other use of Secondary database is to provide report generation which may otherwise take too much time on Primary database and therefore block it for call processing activities. Table of Contents Replication Overview Data Tech Labs Dual Server operation fully relies on MySQL's built-in replication feature. It is strongly recommended to read MySQL Replication Overview before setting up replication.
show top Setting up Dual Server In order to use Dual Server feature, please make sure that replication is set up and running properly. Below is a brief replication setup procedure. For details, please refer to MySQL manual. Replication Setup Note that there will be downtime while you take copy of your Primary database. You MUST shut down MySQL server before doing it. These are the step to create replication of Billing database with minimum possible downtime: - Edit the my.cnf file on the master server:
--master my.cnf:
[mysqld] server-id = 1 log-bin replicate-do-db = billing
- Stop MySQL server on master
- Copy all Billing database tables from MySQL home directory billing/ subdirectory
- Start MySQL server. From this point forward there will be no downtime and primary server works as Replication Master.
- On the master server grant replication permission to slave host:
mysql> GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO repl@"slave.host" IDENTIFIED BY 'password';
- Pack copied directory and send to Slave server
- Stop MySQL server on slave
- Unpack and copy (by replacing) all files from master server into same position of slave server
- Make sure file owner is MySQL (normally mysql:mysql)
- Edit the my.cnf file on the slave:
-slave my.cnf:
[mysqld] server-id = 2 replicate-do-db = billing
- Start mysql on slave.
- Tell slave how to connect to master and restart slave process:
mysql> CHANGE MASTER to MASTER_HOST='master.host’,MASTER_PORT=3306, MASTER_USER='repl',MASTER_PASSWORD='password',MASTER_LOG_FILE='',MASTER_LOG_POS=4;
mysql> STOP SLAVE; #--If already started
mysql> START SLAVE;
- The slave should now be running
- Grant access to Master to read reports from slave (required permissions: select, drop, create):
mysql> GRANT SELECT, DROP, CREATE ON billing.* to reportreader@"master.host" IDENTIFIED BY 'newpassword';
show top Checking Replication To see if replication is running, issue following command on Slave: mysql> SHOW SLAVE STATUS\G
The output should look like this: *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: master.host Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 221307609 Relay_Log_File: localhost-relay-bin.000001 Relay_Log_Pos: 221307652 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: billing Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 221307609 Relay_Log_Space: 221307652 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 1 row in set (0.00 sec)
Pay attention to the following lines: Slave_IO_Running: Yes Slave_SQL_Running: Yes ............. Seconds_Behind_Master: 0
Both Slave_IO_Running and Slave_SQL_Running must be "Yes". It indicates that replication is running properly. Seconds_Behind_Master shows how many seconds Slave is behind Master. Normally if Master and Slave are on same network, it is close to zero seconds. Higher values can happen in cases when Slave is extremely busy (generating large report for example).
show top Configuring Billing Settings controlling Dual Server Operation are located in billing.ini configuration file. Following lines must be modified: billing.ini:
/* ==== DATABASE ==== */ $use_slave_db = 1;
$slavedbhost = "slave.host"; $slavedbuser = "reportreader"; $slavedbpass = "newpassword"; $slavedbname = "billing";
These setting should mach with grants issued on Slave in step 14, chapter "Replication Setup".
show top Maintenance of Dual Server Setup Dual Server Setup needs more administator attention than singe server setup does. Following tasks should be performed regulary: - Check if replication is running by issing SHOW SLAVE STATUS\G query.
- Slave maintains log of queries between fetching them from master and executing on its own server. This log is not purged automatically and can grow very fast and take a lot of disk space. You should regulary check these files and remove older ones. DO NOT remove current file(s) which are in use by Slave. As a rule of thumb remove log files ONLY if Replication is running fine and there is no significant value of Seconds_Behind_Master. In this case it is usually safe to remove all but 2 most recent files. As extra precausion check file modification times before deleting. Make sure you delete oldest files only. Files are located in MySQL data directory and look like following:
-rw-rw---- 1 mysql mysql 254199046 Mar 31 05:58 localhost-relay-bin.000002 -rw-rw---- 1 mysql mysql 29 Mar 30 13:29 localhost-relay-bin.index
NOTE: Do Not remove or modify relay-bin.index file! - Similar log is maintained on master. It is called bin-log. It keeps records of all queries executed on master. Slave reads this log and repeats exactly same steps. It is also not cleaned up automatically. Same guidelines as with cleaning Slave's relay-log apply. Files are located in MySQL data directory and look like following:
-rw-rw---- 1 mysql mysql 299782934 Mar 30 17:18 mysql-bin.000001 -rw-rw---- 1 mysql mysql 265698071 Mar 31 11:18 mysql-bin.000002 -rw-rw---- 1 mysql mysql 38 Mar 30 17:12 mysql-bin.index
NOTE: Do Not remove or modify mysql-bin.index file! show top Troubleshooting Dual Server Setup Common symptoms indicating problems with replication are following: - Data in Reports (Call detail, Traffic, etc.) has not updated, i.e. there is no data for most recent time (minutes, hours) despite the fact that traffic is present. This indicates that replication is broken and needs to be restored.
- When attempting to generate reports, the message "Reports Server is unavailable" appears. This shows that master server is unable to connect to slave due to one of the following:
- Slave server has stopped or crashed;
- There is no granted privilege for master to select from slave;
In both cases first thing to do is to reconfigure master to use its primary database for report reading. This is temporary solution only, as it may significantly increase load on master and even block normal call processing in peak times. In some cases you may consider do not allow report generation at all rather than have degraded performance of master server. To disable report reading from slave, please edit billing.ini file on master: billing.ini:
$use_slave_db = 1;
Now you can check replication: Case 1: Reports are not updating for some time - Check Slave status with SHOW SLAVE STATUS\G query. Depending on status output, there can be several reasons:
- Slave is lagging behind master:
Slave_IO_Running: Yes, Slave_SQL_Running: Yes Seconds_Behind_Master: (some very large number) Appearently Slave is stuck with execution of some very large query (maybe report spanning over several months). Check processlist of Slave server: mysql> SHOW PROCESSLIST; If you notice some query which is executing abnormally long time, it is probably good and safe to kill it by: kill <process_id> - Slave has stopped its SQL thread:
Slave_IO_Running: Yes, Slave_SQL_Running: No Last_Error: Error '(error description follows...) SQL Thread has stopped due to some SQL error. This may happen if data between master and slave is not consistent. The causes can be: manual data modification on slave, errors on master, crashes of master tables etc... If the Last_Error description has following format: Duplicate entry '1449968' for key 1'... it shows that record which we trying to insert already exists on slave. If you are sure of it, you can possibly tell slave to skip this particular query and start again: mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER =1; mysql> START SLAVE; mysql> SHOW SLAVE STATUS\G You can repeat this procedure several times until slave is up and running. However there are case when it cannot help. That is indication of serious problem of current replcation setup and may require advanced debugging or setting up new replcation. Please see MySQL documentation for Replication troubleshooting. - Slave has stopped its I/O thread:
Slave_IO_Running: No, Slave_SQL_Running: Yes Slave has stopped Input/Output thread due to being unable to read Masters bin log. This mostly happens when master bin-log files get corrupted by loss of power in master. This is difficult issue to fix and needs advanced experience. Please see MySQL documentation for Replication troubleshooting. show top Case 2: When clicking any Reports, message is displayed "Reports Server is Unavailable" - Check if slave server is running, and if MySQL is running
- Check connection to slave MySQL server from master using credentials supplied in billing.ini file:
master# mysql -h slave.host -u reportreader -pnewpassword billing Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3890 to server version: 4.1.18
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show tables; If access is not available, please check grants on slave and settings in masters billing.ini file - If there is access from command line, but web interface still shows "Reports Server is Unavailable", please enable error logging in billing.ini file:
billing.ini:
$report_sql_errors = 1;
$report_php_errors = 1; and refresh web page. It will display possible error message. Possible errors are : For More information on this problem please see MySQL online documentation. show top
|
|
|
The next current release of ArrowBilling series 1 is version 1.8.7. It is one of the last ArrowBilling versions before launch of series 2 later this month. Please read Release Notes for more information. |
|
Read more...
|
|
Intermediate release of ArrowBilling version 1.8.6 focuses on carrier-related features. It can do post-time reprocessing of postpaid CDRs, alert of low ASR/ACD and many more. Please read Release Notes for more information. |
Starting from January 2010 DataTechLabs ArrowBilling is available in several options: 1) Standard version (full unlimited license) and 2) DTLite version (free download edition) The new, DTLite version has all the features of Standard version software, and is available for free download at our Download area. It is distributed as VMware image, and therefore can be installed as "virtual" computer on top of any existing Windows or Linux server without disturbing any other applications. |
|
Read more...
|
|
Intermediate release of ArrowBilling version 1.8.5 features addition of several new features, including support for Brekeke SIP Server , Web and ANI callback, and lot of other improvements and fixes. Please read Release Notes for more information. |
|
Read more...
|
|
Hosted Billing and Switch customers now can enjoy latest addition to our services porfolio: ANI Callback. With this service you will be able to provide cost-effective telephony solutions to areas where VoIP is unavailable for any reason. |
|
Read more...
|
|