If you’ve ever looked into high-availability, you are well aware that there are probably one hundred different solutions. In this article we will show you our no nonsense solution using software called UCARP. Using this simpler approach you will have a pair of hosts each of which is prepared to take over a single Virtual IP Address (VIP) – this is what ucarp allows you to do. The premise behind ucarp is each host will have their own IP address, but each of them will also be able to grab a “floating” VIP. This address is the one that will provide high-availability. In our example below I have two hosts running a MariaDB Galera Cluster, lets call them GC01
& GC02
respectively. Using ucarp you’d then configure an IP address which would be live on only one host at a time. This shared IP address is then the address that MariaDB would listen on. So without further ado, first we will need to install ucarp using the following command.
apt-get install ucarp
Once installed, you will want to edit the /etc/network/interfaces
on each server to include the new VIP address. Below are the respective server interfaces files. Please take note, that the new interface is called eth0:ucarp
on each server.
GC01 – MariaDB Galera Cluster Node A
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 ucarp-vid 2 ucarp-vip 192.168.1.2 ucarp-password M@r1a ucarp-advskew 10 ucarp-advbase 1 ucarp-master yes auto eth0:ucarp iface eth0:ucarp inet static address 192.168.1.2 netmask 255.255.255.255
GC02 – MariaDB Galera Cluster Node B
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.105 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 ucarp-vid 2 ucarp-vip 192.168.1.2 ucarp-password M@r1a ucarp-advskew 20 ucarp-advbase 1 ucarp-master no auto eth0:ucarp iface eth0:ucarp inet static address 192.168.1.2 netmask 255.255.255.255
Above, you will notice that on the primary interface we have added our ucarp entries. Most of these are pretty self explanatory, however it is important to note that the ucarp-vid
setting must be unique to each group of servers. It is also important to note that ucarp-master yes
may only be defined on one server per group. For a detailed explanation of each setting, please refer to the Ubuntu ucarp manpage.
Hi,
great and helpful article. It works fine running ucarp manually. But how to start ucarp automatically at boot? I’m wondering if I have to write my own init scripts. Running Ubuntu 14.04.3 and ucarp 1.5.2-1
Best Regards,
Endu
Give this a try. In the command line run the following command:
Works fine, thanks. 🙂 Decided to run ucarp with the if-up and if-down-scripts. 🙂
Fixed. Why choosing such a complicated solution if you can use the if-up.d or if-down.d-scripts?! Feel free to remove my latest comment. 🙂