Setup Active-Passive Cluster with Keepalived & HAProxy (Two raspberry pis)

preview_player
Показать описание
UPDATE:
I made a mistake on 14:24 to the config thanks for everyone for letting me know. All instances should have the same virtual_router_id. So the secondary should have 101 instead of 102. I got lucky and worked because I assigned different priorities. Sorry for the confusion.

Thanks to JR E and Parth Patel for catching the mistake

Keepalived is a routing software written in C that provides simple and robust facilities for loadbalancing and high-availability to Linux systems. In this video we will talk about this technology and implement it along side HAProxy as a high availability (failover)

Chapters
0:00 Intro
2:10 What is failover?
4:30 What are we building
7:20 KeepAlived Example

* What is Keepalived?
* Setup Keepalived with HAProxy
* VRRP/VIP
* Two rapsberrypis with keepalived and haproxy

sudo apt-get install keepalived


vrrp_instance pi1 {
state MASTER
interface eth0
virtual_router_id 101
priority 100
authentication {
auth_type PASS
auth_pass 1234
}
virtual_ipaddress {
192.168.254.100
}
}

vrrp_instance pi2 {
state BACKUP
interface wlan0
virtual_router_id 101
priority 200
authentication {
auth_type PASS
auth_pass 1234
}
virtual_ipaddress {
192.168.254.100
}
}



Red HAT Doc

Stay Awesome,
Hussein
Рекомендации по теме
Комментарии
Автор

I made a mistake on 14:24 to the config thanks for everyone for letting me know. All instances should have the same virtual_router_id. So the secondary should have 101 instead of 102. I got lucky and worked because I assigned different priorities. Sorry for the confusion.


Thanks to JR E and Parth Patel for catching the mistake

hnasr
Автор

Really good stuff man. I came here to watch a vid on KeepAlived and ended up going down the rabbit hole of your video suggestions till I eventually came back to this one and watched it. I'm glad I did that, I definitely understand it well. I love your energy too. Thanks Hussein!

Obsi
Автор

If you have a SMTP Relay running you can also setup keepalived to send mail notifications with just a few more lines directly in the config file.

mx
Автор

Love your energy. I was just smiling each time you said "puppy" again and again. Great content, this works!

ricardohincapie
Автор

@Hussein, first thank you for your content. Second on side your knowledge, also you have nice English, and way how to share your knowledge with us. I am interesting in Nginx and HAProxy, and you gave me good basis to continue exploration. I am moving from Networking to DevOps track, also I have strong experience in Linux, but always I had some issues with Nginx and HAProxy.
Stay safe.
Thank you again.

zeenmc
Автор

You have one seriously easy way to explain the config file. Thank you sir!!

arghyl
Автор

Thank you for the excellent content, simple, objective and functional.

rafael.torquato
Автор

Another great video, thanks!!
1 question around selection of VIP address: if both haproxy are not in same local n/w, which ip to use for VIP? Can we use any public IP as well?

vivekatbitm
Автор

Awesome video man. Exactly what I need for my homelab.

Gunzy
Автор

Awesome video! Please make a health check video too 😁

greg
Автор

Hi Nasser, what about the config. active-active with nginx?

adminshare-krhj
Автор

Nice video ;-) I want to create a VIP for two Active/Passive servers but the problem is the console of this App (Dollar Universe) works with specific 4170 port... Do you know how could I specify to my VIP that works with this port or redirect to this IP_servers:4170 ports???

trollingday
Автор

Just felt the Eureka moment of understanding KeepAlived. Thanks Hussein for it, Can u also give a Tutorial for MariaDB Galera Cluster(4-Nodes) as well ? And how to achieve HA if using MultiMaster(3-Nodes) in a single cluster ?

danydanger
Автор

Hi,

I am from database team.
From db end linux team configured the keepalived with load balanacer with two database servers .
But when we are trying to connect to db any of the master or backup server we are able to connect.


But when the application team using the vip from app to db getting error.
We have opened all required db ports. But no luck.


Do we need to open any specific ports from network rules for this vip (vrrp keepalived)

maheshmahesh-oohf
Автор

Hi,

I am from database team.
From db end linux team configured the keepalived with load balanacer with two database servers .
But when we are trying to connect to db any of the master or backup server we are able to connect.


But when the application team using the vip from app to db getting error.
We have opened all required db ports. But no luck.


Do we need to.opem any specific ports from network rules for this vip (vrrp keepalived)

maheshmahesh-oohf
Автор

Do i need to install HAproxy too ? I have two Linux system with nginx installed in it ...And after configuring keepalived in both the machines, all the settings that you have mentioned, when i am hitting the VIP i am getting a message that this page could not be reached .

ranu__
Автор

Totally new to this High Availability and Switch over. Thanks a lot 👍

palaniappanrm
Автор

Great video, thanks for it. I have a question about Keepalived and VRRP protocol. Is it possible to configure a Virtual IP address between 2(or more) nodes which are in different Geolocation datacenters with different subnets?

artasheskhachatryan
Автор

Can u show the Ifconfig before and after the HA came into picture from P1 & P2 ?

danydanger
Автор

Hi, and thx. Question, when the configuration is done, how to permanently synchronize the lamp software and databases between the servers ?

maximefromspace