How to install VitalPBX on High Availability

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.

Read our tutorials and guides on how to implement new tools and technologies for your business with VitalPBX here.

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

NameMasterSlave
Hostnamevitalpbx-master.localvitalpbx-slave.local
IP Address192.168.30.10192.168.30.20
Netmask255.255.248.0255.255.248.0
Gateway192.168.24.1192.168.24.1
Primary DNS8.8.8.88.8.8.8
Secondary DNS8.8.4.48.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@vitalpbx-master ~]#  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): t
Partition number (1-4, default 4): 4 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w [root@vitalpbx-master ~]# 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@vitalpbx-master ~]#  cd /
[root@vitalpbx-master ~]#  wget https://raw.githubusercontent.com/VitalPBX/vitalpbx_ha/master/vital_ha.sh
[root@vitalpbx-master ~]#  chmod +x vital_ha.sh
[root@vitalpbx-master ~]#  ./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 vitalpbx-master.local
Master/Slave Set: DrbdDataClone [DrbdData]
      Masters: [ vitalpbx-master.local ]
      Slaves: [ vitalpbx-slave.local ]
DrbdFS (ocf::heartbeat:Filesystem): Started vitalpbx-master.local
mysql (ocf::heartbeat:mysql): Started vitalpbx-master.local
dahdi (service:dahdi): Started vitalpbx-master.local
asterisk (service:asterisk): Started vitalpbx-master.local
vpbx-monitor (service:vpbx-monitor): Started vitalpbx-master.local
fail2ban (service:fail2ban): Started vitalpbx-master.local
drbd0 role:Primary
      disk:UpToDate
      vitalpbx-slave.local role:Secondary
      peer-disk:UpToDate

************************************************************
*        Before restarting the servers wait for drbd      *
*          to finish synchronizing the disks           *
*  Use the *drbdadm status* command to see its status *
************************************************************
*** Done ***

Now check if drbd has finished synchronizing the discs
[root@vitalpbx-master ~]# drbdadm status
drbd0 role:Primary
  disk:UpToDate
  vitalpbx2.local role:Secondary
    peer-disk:UpToDate

[root@vitalpbx-master ~]#

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 server-master and wait for status change in server-slave.

[root@vitalpbx-master ~]# reboot

[root@vitalpbx-slave ~]# pcs status

Then reboot the server-slave, connect to server-master and wait for status change in server-master.

[root@vitalpbx-slave ~]# reboot

[root@vitalpbx-master ~]# 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 vitalpbx-master.local to Slave and vitalpbx-slave.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.

Next we will show a short video how high availability works in VitalPBX

Update VitalPBX


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@vitalpbx-master /]# 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@vitalpbx-master /]# bascul

Some Useful Commands


  • bascul, is used to change roles between high availability servers. If all is well, a confirmation question should appear if we wish to execute the action.
  • role, shows the status of the current server. If all is well you should return Masters or Slaves.
  • pcs resource refresh –full, to poll all resources even if the status is unknown, enter the following command.
  • pcs cluster unstandby host, in some cases the bascul command does not finish tilting, which causes one of the servers to be in standby (stop), with this command the state is restored to normal.
  • drbdadm status, shows the integrity status of the disks that are being shared between both servers in high availability. If for some reason the status of Connecting or Standalone returns to us, wait a while and if the state remains it is because there are synchronization problems between both servers and you should execute the drbdsplit command.
  • drbdsplit, solves DRBD split brain recovery.

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

Learn more about VitalPBX, our services and how we can help you achieve your goals in our official website.

0
November 21, 2018

Leave a Reply

Your email address will not be published. Required fields are marked *