Sometimes it is necessary to have an exact copy of a VitalPBX server in another remote datacenter.
For these we have created a script that performs this function automatically.
The objective of this implementation is to guarantee that if something happens to the main server, the remote can continue with the work of the main server.
Note:
Because this is a deployment in two remote sites, it is not possible to have the automatic toggle facility as it is done in the High Availability configuration with the floating IP.
The VitalPBX team does not provide support for systems in an Replica environment because it is not possible to determine the environment where it has been installed.
In order to install VitalPBX in replica, you need the following:
a.- 2 IP addresses.
b.- Install VitalPBX Version 4.0 in two servers with similar characteristics.
c.- Lsyncd.
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 press the Check button.
Disable the DHCP option and set these values
Name | Master | Standby |
---|---|---|
Hostname | voip01.domain.com | voip02.domain.com |
IP Address | 192.168.10.61 | 192.168.10.62 |
Netmask | 255.255.255.0 | 255.255.255.0 |
Gateway | 192.168.10.1 | 192.168.10.1 |
Primary DNS | 8.8.8.8 | 8.8.8.8 |
Secondary DNS | 8.8.4.4 | 8.8.4.4 |
Install the necessary dependencies in Server Master
root@voip01.domain.com ~# apt -y install wget lsyncd
Create key in Server Master
root@voip01.domain.com ~# ssh-keygen -f /root/.ssh/id_rsa -t rsa -N '' >/dev/null root@voip01.domain.com ~# ssh-copy-id root@192.168.10.62 Are you sure you want to continue connecting (yes/no)? yes [email protected]'s password: (remote server root’s password) Number of key(s) added: 1 Now try logging into the machine, with: "ssh '[email protected]'" and check to make sure that only the key(s) you wanted were added. root@voip01.domain.com ~#
Now copy and run the following script
root@voip01.domain.com ~# mkdir /usr/share/vitalpbx/replica root@voip01.domain.com ~# cd /usr/share/vitalpbx/replica root@voip01.domain.com ~# wget https://raw.githubusercontent.com/VitalPBX/vitalpbx_replica_v4/master/vpbxreplica.sh root@voip01.domain.com ~# chmod +x vpbxreplica.sh root@voip01.domain.com ~# ./vpbxreplica.sh ************************************************************ * Welcome to the VitalPBX high availability installation * * All options are mandatory * ************************************************************ IP Master................ > 192.168.10.61 IP Standby............... > 192.168.10.62 ************************************************************ * Check Information * * Make sure you have internet on both servers * ************************************************************ Are you sure to continue with this settings? (yes,no) > yes
Then, to see the slave’s status, run the command below.
root@voip02.domain.com ~# mysql -uroot -e "SHOW SLAVE STATUS\G;"
If everything is correct you should see the following values in Yes
Slave_IO_Running: Yes Slave_SQL_Running: Yes
If the Master server fails and we want to use the Replica, it is necessary to execute the following command so that the Asterisk SQLite database is copied and restarted.
root@voip02.domain.com ~# vpbxstart