Linux Virtual Server Setup

Fore June

  • Introduction
  • Lab 1 -- Building Linux Kernel
  • Lab 2 -- Installing LVS Admin. Package
  • Lab 3 -- Setting Up Linux Virtual Server
  • Lab 4 -- Setting Up LVS/Tunnel Cluster
  • Lab 5 -- Building a Web Server Cluster
  • Lab 6 -- Installing Heartbeat and Ldirector
  • Lab 7 -- Configuring Heartbeat and Ldirector
  • Lab 3 Setting Up Linux Virtual Server


    Prepearation

    1. Read the articles about using IP Tunneling to increase the scalability of a virtual server at the sites: http://www.linuxvirtualserver.org/VS-IPTunneling.html
      http://www.linuxvirtualserver.org/docs/arp.html
      Also read the related sites discussed in the articles.

      The principle behind virtual server via IP tunneling is that the director sends requests to real servers through IP tunnel. When a user accesses an lvs cluster, a packet destined for virtual IP ( VIP ) address ( the IP address of the director ) is received by the director. The director then examines the packet's destination address and port. If they are matched for the virtual service, a real server is chosen from the cluster according to a connection scheduling algorithm, and the connection information is saved in a hash table. The director then encapsulates the packet within an IP datagram and forwards it to the chosen server. When an incoming packet belongs to this connection and the chosen real server can be found in the hash table, the packet will be again encapsulated and forwarded to that real server. Upon receiving the encapsulated packet, the real server decapsulates the packet, processes the request and returns the result directly to the user according to its own routing table. After a connection terminates or timeouts, the connection record will be removed from the hash table.

      Note that real servers can have any real IP address in any network; they can be geographically distributed, but they must support IP encapsulation protocol. Their tunnel devices are all configured up so that the system can decapsulate the received encapsulation packets properly, and the VIP address must be configured on non-arp devices or any alias of non-arp device. Moreover, the system can be configured to redirect packets destined for the VIP address to a local socket. We shall start our experiment by redirecting packets to a local socket. That is, your machine will be both the director ( load balancer ) and the real machine.

    2. Check if you have installed LVS successfully by the command #/sbin/ipvsadm If lvs has been installed properly, you should see something like IP Virtual Server version 1.0.0 (size=65536)
      Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port    Forward Weight ActiveConn InActConn


      Setting Up The Director

    3. The director is your load balancer. First, change your IP address to one in the format 192.168.1.xxx which are reserved IP addresses used for local networks. As an example let use use the IP 192.168.1.175 as the real IP of the director and and IP 192.168.1.176 to be the virtual IP ( VIP ). You may change real IP via the command # setup Choose the network configuration option. Reboot after changing the network settings or restart the network by the command # /sbin/service network restart.
    4. Check the IP configuration with the command, $ /sbin/ifconfig You should see the IP of your machine, which should be 192.168.1.175. This is the real IP of your machine. You need another IP, which is the virtual IP ( VIP ) of the cluster. The VIP must be different from the real of your machine. In our example, it is 192.168.1.176. Set up the VIP with the command # /sbin/ifconfig eth0:0 192.168.1.176 netmask 255.255.255.255 broadcast 192.168.1.176 up Recheck the IP configuration with the ifconfig command again.
    5. Now setup your machine as a director for telnet and ssh by the commands, # /sbin/ipvsadm -A -t 192.168.1.176:telnet -s wlc -p
      #/sbin/ipvsadm -A -t 192.168.1.176:ssh -s wlc -p
      Then check if you have done that successfully by # /sbin/ipvsadm You should see something like
      IP Virtual Server version 1.0.0 (size=65536)
      Prot LocalAddress:Port Scheduler Flags
        -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
      TCP  your_hostname:telnet wlc persistent 360
      TCP  your_hostname:ssh wlc persistent 360
      
      You do not have to but if you want, you can clear the setup by #/sbin/ipvsadm -C and check the status again by /sbin/ipvsadm. Of course if you have cleared the setup, you have to repeat the above step to set it up again.

    6. After you have setup the director of the cluster in the previous step, you may add the local node to it. Recall that your VIP address is 192.168.1.176 and the real IP 192.168.1.175. You can issue the following commands to add your node: /sbin/ipvsadm -a -t 192.168.1.176:telnet -r 192.168.1.175 -i -w 3
      /sbin/ipvsadm -a -t 192.168.1.176:ssh -r 192.168.1.175 -i -w 3
      Check the LVS cluster status by /sbin/ipvsadm. Telnet or ssh into 192.168.1.176 and check the status again with /sbin/ipvsadm. Congratulations! You have successfully setup a Linux cluster.
    << Prev  Next >>