# virtual machine will return'kvm' or 'vmware', physical machine will return'none' systemd-detect-virt # KVM may have not previlege to config vip, so may could not config vip in keepalived
install
1 2 3
sudo apt install haproxy keepalived # Debian/Ubuntu # or sudo yum install haproxy keepalived # RHEL/CentOS/Rocky Linux
assume there are two server e.g. 10.225.10.50 and 10.225.10.51, and each bootstrap web service with 13307 port
and i want export both service by same port 13308 with same ip
if server is physical machine, could use haproxy & keepalived strategy
if server is virtural machine, could use
haproxy
both server all should config and bootstrap haproxy
vrrp_instance VI_1 { state MASTER # server1 is MASTER , server2 should be BACKUP interface eth0 # replace eth0 with your real network interface virtual_router_id 51 priority 110 # server1 is 110, server2 should be lower advert_int 1 # Add unicast configuration, ⚠️ server2 would swap ip , src should be 51, peer should be 50 unicast_src_ip 10.225.10.50 # This server's IP unicast_peer { 10.225.10.51 # Peer server's IP } # Add this line to allow traffic to VIP accept authentication { auth_type PASS auth_pass dingo # custome password }