Updated on 2024-05-17 GMT+08:00

LVS Load Balancing Test

Objectives

LVS can evenly forward requests to two backend server nodes.

Prerequisites

  1. The LVS environment of the test cluster has been configured.
  2. The web test service has been deployed on the primary and standby backend nodes.

    Install the httpd service on the [root@centos01 ~]# yum -y install httpd <!--Install the httpd service.-->

    [root@centos01 ~]# echo "www.test01.com" > /var/www/html/index.html

    [root@centos01 ~]# chmod 777 /var/www/html/index.html <!--Start the httpd service.-->

    [root@centos01 ~]# systemctl start httpd <!--Start the httpd service.-->

    Set the [root@centos01 ~]# systemctl enable httpd<!--Enable httpd to automatically start upon system boot.-->

    Install the httpd service on the [root@centos02 ~]# yum -y install httpd <!--Install the httpd service.-->

    [root@centos02 ~]# echo "www.test02.com" > /var/www/html/index.html <!-- Create a website home page and write the test data. Write different content to the two backend nodes for clear display of test results.-->

    [root@centos02 ~]# chmod 777 /var/www/html/index.html <!--Start the httpd service.-->

    [root@centos02 ~]# systemctl start httpd <!--Start the httpd service.-->

    Set the [root@centos02 ~]# systemctl enable httpd<!--Enable httpd to automatically start upon system boot.-->

Test Methods

  1. Run the curl 192.168.0.27 (VIP) command for multiple times on nodes that can communicate with each other through the VIP.
  2. View the response result. The web application content of the two backend nodes is randomly displayed (www.test01.com or www.test02.com).
  3. Use the browser to access an EIP (http://x.x.x.x) bound to the VIP for multiple times.
  4. View the response result. The web application content of the two backend nodes is randomly displayed (www.test01.com or www.test02.com).