High availability is a characteristic of a system which aims to ensure an agreed level of operational performance, usually uptime, for a higher than normal period.
Make a High Availability cluster out of any pair of VitalPBX servers. VitalPBX can detect a range of failures on one VitalPBX server and automatically transfer control to the other server, resulting in a telephony environment with minimal down time.
Example:
Prerequisites
In order to install VitalPBX in high availability you need the following:
a.- 3 IP addresses
b.- Install VitalPBX on two servers with similar characteristics
c.- At the time of installation leave the largest amount of space on the hard drive to store the variable data on both servers
Installation
We are going to start by installing VitalPBX on two servers
a.- When starting the installation go to: INSTALLATION DESTINATION (Custom partitioning selected) b.- Select: I will configure partitioning And press the button Done c.- Select the root partition: / Change the capacity to: Desired Capacity: 20GB We need enough space for the operating system and its applications in the future; then click Modify button Select disk and press the buttons Select Update Settings d.- Finally, we press the button: Done And press the button Accept Changes
And continue with the installation.
Configurations
We will configure in each server the IP address and the host name. Go to the web interface to: Admin>System Settinngs>Network Settings.
First, change the Hostname, remember to press the Check button.
Disable the DHCP option and set these values
Name | Master | Slave |
---|---|---|
Hostname | vitalpbx1.local | vitalpbx2.local |
IP Address | 192.168.30.10 | 192.168.30.20 |
Netmask | 255.255.248.0 | 255.255.248.0 |
Gateway | 192.168.24.1 | 192.168.24.1 |
Primary DNS | 8.8.8.8 | 8.8.8.8 |
Secondary DNS | 8.8.4.4 | 8.8.4.4 |
Create Disk
Now we connect through ssh to each of the servers.
a.- Initialize the partition to allocate the available space on the hard disk. Do these on both servers.
[root@vitalpbx1-2 ~]# fdisk /dev/sda Command (m for help): n Select (default e): p Selected partition x (take note of the assigned partition number as we will need it later) [Enter] [Enter] Command (m for help): w [root@vitalpbx1-2 ~]# reboot
Install Dependencies
Install the necessary dependencies on both servers
[root@vitalpbx1-2 ~]# yum -y install drbd90-utils kmod-drbd90 corosync pacemaker pcs
Script
Now copy and run the following script:
[root@vitalpbx1 ~]# cd / [root@vitalpbx1 ~]# wget https://raw.githubusercontent.com/VitalPBX/vitalpbx_ha/master/vital_ha.sh [root@vitalpbx1 ~]# chmod +x vital_ha.sh [root@vitalpbx1 ~]# ./vital_ha.sh
Set these values, remember the Floating IP Mask must be 2 digit format and the Disk is that you created in the step “Create Disk”:
IP Master.......... > 192.168.30.10 IP Slave........... > 192.168.30.20 Floating IP........ > 192.168.30.30 Floating IP Mask... > 21 Disk (sdax)........ > sda4 hacluster password. > mypassword Are you sure to continue with these settings? (yes,no) > yes Are you sure you want to continue connecting (yes/no)? yes root@192.168.30.20's password: The root password from Slave Server
At the end of the installation, you have to see the following message
************************************************************ * VitalPBX Cluster OK * ************************************************************ virtual_ip (ocf::heartbeat:IPaddr2): Started vitalpbx1.local Master/Slave Set: DrbdDataClone [DrbdData] Masters: [ vitalpbx1.local ] Slaves: [ vitalpbx2.local ] DrbdFS (ocf::heartbeat:Filesystem): Started vitalpbx1.local mysql (ocf::heartbeat:mysql): Started vitalpbx1.local asterisk (ocf::heartbeat:asterisk): Started vitalpbx1.local fail2ban (service:fail2ban): Started vitalpbx1.local vpbx-monitor (service:vpbx-monitor): Started vitalpbx1.local *** Done ***
Now check if drbd has finished synchronizing the discs
[root@vitalpbx1 ~]# drbdadm status drbd0 role:Primary disk:UpToDate vitalpbx2.local role:Secondary peer-disk:UpToDate [root@vitalpbx1 ~]#
If it shows the previous message it means that everything is fine and we can continue, otherwise we have to wait for it to finish synchronizing.
Now, reboot the server1 and wait for status change in server2.
[root@vitalpbx1 ~]# reboot [root@vitalpbx2 ~]# pcs status
Then reboot the server2, connect to server1 and wait for status change in server1.
[root@vitalpbx2 ~]# reboot [root@vitalpbx1 ~]# pcs status
Test
To execute the process of changing the role, we recommend using the following command:
[root@vitalpbx1 /]# bascul ************************************************************ * Change the roles of servers in high availability * * WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING * *All calls in progress will be lost and the system will be * * be in an unavailable state for a few seconds. * ************************************************************ Are you sure to switch from vitalpbx1.local to vitalpbx2.local? (yes,no) >
This action converts the vitalpbx1.local to Slave and vitalpbx2.local to Master. If you want to return to default do the same again.
Turn on and turn off
When you have to turn off the servers, when you turn it on always start with the Master, wait for the Master to start and then turn on the Slave.
Update
To update VitalPBX to the latest version just follow the following steps:
1.- From your browser, go to the IP address 192.168.30.30
2.- Update VitalPBX from the interface
3.- Execute the following command in Master console
[root@vitalpbx1 /]# bascul
4.- From your browser, go to the IP address 192.168.30.30 again
5.- Update VitalPBX from the interface
6.- Execute the following command in Master console
[root@vitalpbx1 /]# bascul
CONGRATULATIONS, you have installed and tested the high availability in VitalPBX
?
Also available in GitHub
To see the step-by-step manual:
Manual step-by-step