Skip to content

imyelmo/vagrant-haproxy-keepalived

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vagrant-haproxy-keepalived

Demo of HAProxy high availability using Vagrant.

This project sets up the following VMs on a private network in VirtualBox:

  • haproxy1 (192.168.2.9)
  • haproxy2 (192.168.2.10)
  • web1 (192.168.2.11)
  • web2 (192.168.2.12)

The HAProxy servers are themselves made redundant via keepalived, with virtual IP 192.168.2.2.

Prerequisites

  1. Install Vagrant
  2. Install Virtualbox
  3. Either clone this repo, or download the zip file and extract it to an empty directory.

Getting started

Determining the active HAProxy

keepalived is an implementation of the VRRP (Virtual Router Redundancy Protocol) protocol to make IPs highly available - a so called VIP (Virtual IP).

You can check which HAProxy server is currently handling requests to the virtual IP 192.168.2.2 by checking the server's ip addresses:

$ vagrant ssh haproxy1 -c "echo haproxy1; ip addr | grep 192.168.2.2/32"
haproxy1
    inet 192.168.2.2/32 scope global eth1
Connection to 127.0.0.1 closed.
$ vagrant ssh haproxy2 -c "echo haproxy2; ip addr | grep 192.168.2.2/32"
haproxy2
Connection to 127.0.0.1 closed.

Scenarios to investigate

Try turning various servers on and off, and visit any of the URLs to see what the results are. As HAProxy services are turned on and off, also check the active HAProxy.

Examples:

  • vagrant ssh web1 -c "sudo service apache2 stop"
  • vagrant ssh web1 -c "sudo service apache2 start"
  • vagrant ssh haproxy1 -c "sudo service haproxy stop"
  • vagrant ssh haproxy1 -c "sudo service haproxy start"

Shutting down

  • vagrant halt turns off vms
  • vagrant destroy destroys all traces of the VMs, but leaves the cached images
  • vagrant box remove ... removes the downloaded image file.

About

Vagrant haproxy keepalived

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%