YsummarY, use Tab ↹, Return/Enter and go back (⌘ + ←) to navigate.

Meet keepalived - High Availability and Load Balancing in One

YouTube Video

This YouTube video demonstrates how to set up Keepalived, a framework for load balancing and high availability, to achieve high availability for services. Key points include:

Keepalived Fundamentals:

  • Virtual Router Redundancy Protocol (VRRP): Keepalived uses VRRP to create a Virtual IP (VIP) or floating IP address. This VIP acts as a gateway, routing traffic to active hosts.
  • Active-Passive Configuration: One node is active (master), while others are passive (backup). The master responds to requests. If the master fails, VRRP communication triggers a failover to a standby host.
  • Load Balancer Configuration (More Advanced): Both nodes have a VIP, and act as load balancers distributing traffic across real servers. This provides higher availability as multiple components can fail simultaneously.

Setup and Configuration (Active-Passive Example):

  • Minimum Requirements: Two servers (any Linux flavor, Ubuntu used in the example). Each needs a dedicated, static or DHCP-reserved IP address.
  • Installation: sudo apt update and sudo apt install keepalived (and potentially libipsec-1).
  • Configuration File (/etc/keepalived/keepalived.conf): The configuration file defines:
    • vrrp_instance: Instance identifier (e.g., vi_1).
    • state: master (for the primary node) or backup (for the secondary).
    • interface: Network interface the VIP will use.
    • virtual_router_id: Unique ID across all nodes (same value on all).
    • priority: Higher number for the master node (determines which becomes master).
    • advert_int: Advertisement interval (how often nodes announce themselves).
    • unicast_src_ip and unicast_peer: IP addresses for unicast communication between nodes (optional, but recommended).
    • authentication: auth_type and auth_pass (password) for secure communication (recommended).
    • virtual_ipaddress: The VIP address.
  • Password Length: Keepalived truncates passwords longer than 8 characters.
  • Enabling and Checking Status: sudo systemctl enable --now keepalived.service and sudo systemctl status keepalived.service.

Testing and Real-World Scenarios:

  • Testing: Pinging the master, backup, and VIP to verify functionality. Shutting down Keepalived on one node to demonstrate failover.
  • Nginx Example: Setting up Nginx on both nodes (using Docker in the video) to demonstrate failover of a real application.
  • High Availability Pi-hole: Using Keepalived to create a high-availability Pi-hole setup with a VIP as the secondary DNS server. Using tools like Gravity Sync to keep configurations synchronized across instances.

Conclusion:

Keepalived is a simple, lightweight solution for achieving high availability and load balancing. The video covers basic active-passive configuration and suggests more advanced use cases, highlighting its flexibility.

Next: Use Docker Swarm! Auto Deploy Script with Highly Available Storage - GlusterFS
Prev: SELinux: Unlock the Linux Security Tool You Didn’t Know You Needed