Search:  
Gentoo Wiki

HOWTO_setup_a_loadbalancer_with_failover

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

Contents

What is this?

The goal of this howto is to put information somewhere so they don't have to go through what I went through. This document will try and give a general howto for creating a high throughput loadbalancing system using Linux Virtual Server and failover using heartbeat. The Linux Virtual Server will be setup using the Direct Routing method (Virtual Server via Direct Routing). On of the problems I faced is that pretty much all documentation is writen for the 2.0/2.2/2.4 linux kernel. Not much is available for the 2.6 kernel. I found one document about gentoo and the 2.6 kernel, but it used the Linux Virtual Server NAT method.

What's Covered

This HOWTO will go through the steps to configure a base gentoo install and turn it into a load balancer for use with a webserver. The system can be easily changed to handle any network service.

Getting Started

For this howto, we assume you have a very plain gentoo install.

First we'll need to get the kernel source and genkernel if you need it.

$ emerge gentoo-sources genkernel

Next we'll have to get into the kernel configuration

$ genkernel --menuconfig all
Linux Kernel Configuration:
Code maturity level options  --->
 [*] Prompt for development and/or incomplete code/drivers
 [*]   Select only drivers expected to compile clean
Networking --->
  Networking Options -->
   [*] Network packet filtering (replaces ipchains)  --->
   IP: Virtual Server Configuration  --->
    <M> IP virtual server support (EXPERIMENTAL)
    [ ]   IP virtual server debugging           
    (12)  IPVS connection table size (the Nth power of 2)
    ---   IPVS transport protocol load balancing support
    [*]   TCP load balancing support
    [*]   UDP load balancing support
    [ ]   ESP load balancing support
    [ ]   AH load balancing support
    ---   IPVS scheduler           
    <M>   round-robin scheduling   
    <M>   weighted round-robin scheduling
    <M>   least-connection scheduling 
    <M>   weighted least-connection scheduling 
    <M>   locality-based least-connection scheduling
    <M>   locality-based least-connection with replication scheduling
    <M>   destination hashing scheduling
    <M>   source hashing scheduling
    <M>   shortest expected delay scheduling
    <M>   never queue scheduling
    ---   IPVS application helper
    <M>   FTP protocol helper

Next, let the kernel compile. When it's done, fix your grub/lilo config and reboot.

After you've rebooted, you'll need to install the applications. For this we need ipvsadm and heartbeat.

$ echo 'sys-cluster/heartbeat ldirectord' >> /etc/portage/package.use
$ emerge ipvsadm heartbeat

Configuration

Copy the example HA configuration files

$ cd /usr/share/doc/heartbeat-version
$ cp ha.cf haresources /etc/ha.d
File: /etc/ha.d/ha.cf
# comments removed
logfacility     local0
bcast   eth1 
auto_failback on
node lvs1 lvs4
File: /etc/ha.d/haresources
lvs1 172.16.1.80/24/eth0 ldirectord
File: /etc/ha.d/conf/ldirectord.cf
logfile="local0"
virtual = 172.16.1.80:80
        real = 192.168.1.202:80 gate 10
        real = 192.168.1.203:80 gate 10
        #real = 192.168.1.204:80 gate 10
        scheduler = lc
        protocol = tcp
        request = "/test"
        receive = "OK"

References

Linux Virtual Server on Gentoo for Email

Retrieved from "http://www.gentoo-wiki.info/HOWTO_setup_a_loadbalancer_with_failover"

Last modified: Mon, 08 Sep 2008 06:45:00 +0000 Hits: 8,484