Difference between revisions of "Building Two-Node Directors/Real Servers using LVS and Keepalived"

From LVSKB
Jump to: navigation, search
(Architecture)
(Instructions)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
This guide is a brief explanation on getting a two node director/real server setup going using LVS and keepalived.
+
This guide is a brief explanation on getting a two node director/[[real server]] setup going using [[LVS]] and [[keepalived]].
 +
 
 +
This is an adaptation of the information at [http://www.ultramonkey.org/2.0.1/topologies/sl-ha-lb-eg.html Ultra Monkey: Streamline High Availablility and Load Balancing] to work with [[keepalived]].
 +
 
 +
It is primarily targeted at RHEL3/4 (RedHat Enterprise Linux).
 +
 
 +
== Goals ==
 +
Setup a two node [[LVS]] cluster with Apache as the virtualised services, with both nodes operating as both directors and [[real server]]s.<br>
 +
Setup healthchecking of services (httpd).<br>
 +
Setup lvs-syncing of connections (ipvsadm sync daemon).<br>
 +
 
 +
== Knowledge Required ==
 +
 
 +
Understanding of Layer 3 [[load balancing]].<br>
 +
Understanding of Linux LVS.<br>
 +
Understanding of Apache configuration.<br>
 +
 
 +
== Components Required ==
 +
 
 +
Base installation of RHEL3/4.<br>
 +
RPM Packages for httpd.<br>
 +
RPM Packages for [[keepalived]].<br>
 +
RPM Packages for [[ipvsadm]].<br>
 +
 
 +
== Instructions ==
 +
Install keepalived and IPVSADM on both servers.
 +
 
 +
On the first server create the file /etc/keepalived/keepalived.conf :
 +
 
 +
global_defs {
 +
  router_id DEV
 +
}
 +
vrrp_instance VI_1 {
 +
    state MASTER
 +
    interface eth0
 +
    virtual_router_id 51
 +
    priority 100
 +
    advert_int 10
 +
    authentication {
 +
        auth_type PASS
 +
        auth_pass 1111
 +
    }
 +
    virtual_ipaddress {
 +
      192.168.6.240
 +
  }
 +
}
 +
virtual_server 192.168.6.240 80 {
 +
    delay_loop 10
 +
    lb_algo rr
 +
    lb_kind DR
 +
    persistence_timeout 5
 +
    protocol TCP
 +
    real_server 192.168.6.4 80 {
 +
        TCP_CHECK {
 +
        }
 +
    }
 +
    real_server 192.168.6.5 80 {
 +
        TCP_CHECK {
 +
        }
 +
    }
 +
  }
 +
}
 +
 
 +
On the second server create the file /etc/keepalived/keepalived.conf :
 +
global_defs {
 +
  router_id DEV
 +
}
 +
vrrp_instance VI_1 {
 +
    state BACKUP
 +
    interface eth0
 +
    virtual_router_id 51
 +
    priority 99
 +
    advert_int 10
 +
    authentication {
 +
        auth_type PASS
 +
        auth_pass 1111
 +
    }
 +
    virtual_ipaddress {
 +
      192.168.6.240
 +
    }
 +
}
 +
virtual_server 192.168.6.240 80 {
 +
    delay_loop 10
 +
    lb_algo rr
 +
    lb_kind DR
 +
    persistence_timeout 5
 +
    protocol TCP
 +
    real_server 192.168.6.5 80 {
 +
        TCP_CHECK {
 +
        }
 +
    }
 +
}
 +
 
 +
On both servers create the file /etc/sysconfig/network-scripts/ifcfg-lo:0
 +
DEVICE=lo:0
 +
IPADDR=192.168.6.240
 +
NETMASK=255.255.255.255
 +
ONBOOT=yes
 +
NAME=loopback
 +
 
 +
In order to avoid warning messages, we explicitly say that our gateway is on eth0.
 +
Add in /etc/sysconfig/network
 +
GATEWAYDEV=eth0
 +
 
 +
Add in /etc/sysctl.conf :
 +
net.ipv4.conf.eth0.arp_ignore = 1
 +
net.ipv4.conf.eth0.arp_announce = 2
 +
# Enables packet forwarding
 +
net.ipv4.ip_forward = 1
 +
 
 +
ifup lo
 +
sysctl -p
  
 
== Architecture ==
 
== Architecture ==
[[Image:sl-ha-lb-eg.jpg]]
+
[[Image:sl-ha-lb-eg.jpg|center]]
 +
 
 +
 
 +
{{lvs-example-stub}}
 +
 
 +
 
 +
[[Category:LVS Examples|Keepalived]]

Latest revision as of 14:40, 27 April 2007

Introduction

This guide is a brief explanation on getting a two node director/real server setup going using LVS and keepalived.

This is an adaptation of the information at Ultra Monkey: Streamline High Availablility and Load Balancing to work with keepalived.

It is primarily targeted at RHEL3/4 (RedHat Enterprise Linux).

Goals

Setup a two node LVS cluster with Apache as the virtualised services, with both nodes operating as both directors and real servers.
Setup healthchecking of services (httpd).
Setup lvs-syncing of connections (ipvsadm sync daemon).

Knowledge Required

Understanding of Layer 3 load balancing.
Understanding of Linux LVS.
Understanding of Apache configuration.

Components Required

Base installation of RHEL3/4.
RPM Packages for httpd.
RPM Packages for keepalived.
RPM Packages for ipvsadm.

Instructions

Install keepalived and IPVSADM on both servers.

On the first server create the file /etc/keepalived/keepalived.conf :

global_defs {
  router_id DEV 
}
vrrp_instance VI_1 {
   state MASTER
   interface eth0
   virtual_router_id 51
   priority 100
   advert_int 10
   authentication {
       auth_type PASS
       auth_pass 1111
   }
   virtual_ipaddress {
      192.168.6.240
  }
}
virtual_server 192.168.6.240 80 {
   delay_loop 10
   lb_algo rr
   lb_kind DR
   persistence_timeout 5
   protocol TCP
   real_server 192.168.6.4 80 {
       TCP_CHECK {
       }
   }
   real_server 192.168.6.5 80 {
       TCP_CHECK {
       }
   }
 }
}

On the second server create the file /etc/keepalived/keepalived.conf :

global_defs {
  router_id DEV
}
vrrp_instance VI_1 {
   state BACKUP
   interface eth0
   virtual_router_id 51
   priority 99
   advert_int 10
   authentication {
       auth_type PASS
       auth_pass 1111
   }
   virtual_ipaddress {
      192.168.6.240
   }
}
virtual_server 192.168.6.240 80 {
   delay_loop 10
   lb_algo rr
   lb_kind DR
   persistence_timeout 5
   protocol TCP
   real_server 192.168.6.5 80 {
       TCP_CHECK {
       }
   }
}

On both servers create the file /etc/sysconfig/network-scripts/ifcfg-lo:0

DEVICE=lo:0
IPADDR=192.168.6.240
NETMASK=255.255.255.255
ONBOOT=yes
NAME=loopback

In order to avoid warning messages, we explicitly say that our gateway is on eth0. Add in /etc/sysconfig/network

GATEWAYDEV=eth0

Add in /etc/sysctl.conf :

net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2
# Enables packet forwarding
net.ipv4.ip_forward = 1
ifup lo
sysctl -p

Architecture

Sl-ha-lb-eg.jpg


LVS.png "Building Two-Node Directors/Real Servers using LVS and Keepalived" is an LVS Example related stub. You can help LVSKB by expanding it