test IPVS

Primary tabs

intoximeter

introduction

Switch servers on and off. Use ipvsadm to check how the IPVS load balancer is distributing work between them. When ldirectord, the server manager, can no longer talk to a server, it tells IPVS to make that server quiescent.

IPVS knows a weight for each server. Weight is an integer specifying the capacity of a server relative to the others in the pool. If I tell IPVS one server has a weight of 2 and another is 1, IPVS assumes the first server has twice the capacity of the second one. Setting a weight of zero makes a server quiescent. The server will receive no new requests but still serves the existing ones. This is handy for when shutting down a server. This command makes the server on ics02 quiescent.

ifw01:~# ipvsadm -e -t 200.0.0.10:80 -r 192.168.3.2:80 -m -w 0
ifw01:~# 

test IPVS

Check everything is normal.

  1. Open a CLI on the host ifw01.
  2. Use su to switch to the root account.
  3. check IPVS.
    ifw01:~# ipvsadm -L
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  mail.planetlarg.com:www rr
      -> ics01-web01.planetlarg.com:w Masq    1      0          1
      -> ics03-web01.planetlarg.com:w Masq    1      0          0
      -> ics02-web01.planetlarg.com:w Masq    1      0          0
    ifw01:~#
      
    All the weights are 1.

Turn off the web servers on ics02 and ics03.

  1. Open a CLI on the host ics02.
  2. Use su to switch to the root account.
  3. switch off apache2.
    ics02:~# /etc/init.d/apache2 stop
    Stopping web server: apache2 ... waiting ..
    ics02:~#
      
    All the weights are 1.
  4. Open a CLI on the host ics03.
  5. Use su to switch to the root account.
  6. switch off apache2.
    ics03:~# /etc/init.d/apache2 stop
    Stopping web server: apache2 ... waiting .
    ics03:~#
      

Has IPVS noticed?

  1. Focus on the ifw01 CLI.
  2. check IPVS.
    ifw01:~# ipvsadm -L
    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  ns1.planetlarg.com:www rr
      -> ics01-web01.planetlarg.com:w Masq    1      0          0
      -> ics03-web01.planetlarg.com:w Masq    0      0          0
      -> ics02-web01.planetlarg.com:w Masq    0      0          0
    ifw01:~#
      
    Weight of zero means "do not use".

Turn on the web servers on ics02 and ics03.

  1. Open a CLI on the host ics02.
  2. Use su to switch to the root account.
  3. switch off apache2.
    ics02:~# /etc/init.d/apache2 start
    Starting web server: apache2.
    ics02:~#
      
    All the weights are 1.
  4. Open a CLI on the host ics03.
  5. Use su to switch to the root account.
  6. switch off apache2.
    ics03:~# /etc/init.d/apache2 start
    Starting web server: apache2.
    ics03:~#
      

troubleshoot

wrong user
issalarg@ifw01:~$ /sbin/ipvsadm -L
Can't initialize ipvs: Permission denied (you must be root)
Are you sure that IP Virtual Server is built in the kernel or as module?
issalarg@ifw01:~$