Install and Configure Linux Virtual Server (LVS) for Load Balancing

1 hour
  • 6 Learning Objectives

About this Hands-on Lab

Linux Virtual Server (LVS) is a highly available and highly scalable virtual server that is built on a cluster of actual servers using a load balancer. This approach allows the service that is being provided to appear as a single Linux server. In this hands-on lab, you are tasked with setting up LVS in order to provide a virtual service for two Apache HTTP servers.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Load the IPVS kernel module.

Load in the IPVS kernel module.

Install the IPVS administration utility package.

Use yum to install the IPVS administration package.

Enable packet forwarding and non-local IP address binding.

Add the IP forward and IP nonlocal bind directives to /etc/sysctl.conf.

Start up the `ipvsadm` service and ensure that it persists through reboot.

Create the ipvsadm configuration file and enable and start the ipvsadm service.

Configure the virtual service and specify the scheduling algorithm.

Add the virtual service and specify the scheduling algorithm.

Add the real servers to the virtual service and specify a packet forwarding method.

Add real-server1 and real-server2 to the virtual service.

Additional Resources

The operational team in charge of the web servers has created two new Apache HTTP servers in preparation for a marketing campaign. You have been tasked with setting up a Linux Virtual Server to serve as a single access point and load balancer for potential clients. The Apache servers are already configured and running on real-server1 and real-server2 on port 80 on both hosts. You must install and configure LVS on the lvs-server. The virtual service that you create should use, listen on port 80, and use round robin as its scheduling algorithm. Once the virtual service is created, add real-server1 and real-server2 as real servers to the virtual service using NAT as the IP load balancing method.

Important notes:

  • /etc/sysconfig/ipvsadm must be manually created for RHEL/CentOS (this is required for the service to start).
  • Once you have completed all the tasks, you can test the virtual service by running curl This will return the index.html and should alternate between real-server1 and real-server2.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?