Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

Capitolo 3. Impostazione del LVS

LVS consiste in due gruppi di base: i router LVS ed i real server. Per evitare il verificarsi di un single point of failure, ogni gruppo dovrebbe avere almeno due sistemi membri.
Il gruppo del router LVS dovrebbe consistere in due sistemi identici o molto simili sui quali viene eseguito Red Hat Enterprise Linux. Uno che funge come router LVS attivo e l'altro in grado di essere in modalità di hot standby, quindi entrambi dovranno avere una capacità quanto più simile possibile.
Prima di selezionare e configurare l'hardware per il gruppo del real server, è necessario determinare quale topologia LVS usare.

3.1. La rete NAT LVS

La topologia NAT vi permette di utilizzare l'hardware esistente in diversi modi, ma risulta essere limitato nella propria abilità di gestire carichi molto grandi, a causa del passaggio di tutti i pacchetti in entrata e in uscita attraverso il router LVS.
Struttura della rete
Da una prospettiva della struttura di rete, la topologia per LVS che utilizza un NAT routing risulta essere quella più semplice da configurare, poichè è necessario solo un punto d'accesso alla rete pubblica. I real server ritornano tutte le richieste attraverso il router LVS in modo da essere nella propria rete privata.
Hardware
La topologia NAT è la più flessibile in relazione all'hardware, poichè i real server non devono essere macchine Linux per poter funzionare correttamente. In una topologia NAT ogni real server avrà bisogno di un solo NIC poichè esso risponderà solo al router LVS. I router LVS, invece, avranno bisogno ciascuno di due NIC per instradare il traffico tra le due reti. Poichè questa topologia crea una limitazione nei confronti del router LVS, è possibile impiegare i NIC gigabit Ethernet su ogni router LVS per migliorare la larghezza di banda che un router LVS è in grado di gestire. Se il gigabit Ethernet viene implementato sui router LVS, qualsiasi interruttore che collega i real server ai router LVS, deve avere almeno due porte gigabit Ethernet per gestire in modo efficiente il carico.
Software
Poichè la topologia NAT richiede l'utilizzo di iptables per alcune configurazioni, potrebbe esser necessario eseguire una ulteriore configurazione esterna al Piranha Configuration Tool. In particolare, i servizi FTP e l'utilizzo dei firewall mark richiedono una configurazione manuale supplementare dei router LVS, per instradare in modo correto tutte le richieste.

3.1.1. Configurazione delle interfacce di rete per LVS con NAT

To set up LVS with NAT, you must first configure the network interfaces for the public network and the private network on the LVS routers. In this example, the LVS routers' public interfaces (eth0) will be on the 192.168.26/24 network (I know, I know, this is not a routable IP, but let us pretend there is a firewall in front of the LVS router for good measure) and the private interfaces which link to the real servers (eth1) will be on the 10.11.12/24 network.
So on the active or primary LVS router node, the public interface's network script, /etc/sysconfig/network-scripts/ifcfg-eth0, could look something like this:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.26.9
NETMASK=255.255.255.0
GATEWAY=192.168.26.254
/etc/sysconfig/network-scripts/ifcfg-eth1 per l'interfaccia NAT privata sul router LVS potrebbe somigliare al seguente:
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.11.12.9
NETMASK=255.255.255.0
In this example, the VIP for the LVS router's public interface will be 192.168.26.10 and the VIP for the NAT or private interface will be 10.11.12.10. So, it is essential that the real servers route requests back to the VIP for the NAT interface.

Importante

The sample Ethernet interface configuration settings in this section are for the real IP addresses of an LVS router and not the floating IP addresses. To configure the public and private floating IP addresses the administrator should use the Piranha Configuration Tool, as shown in Sezione 4.4, «GLOBAL SETTINGS» and Sezione 4.6.1, «La sottosezione SERVER VIRTUALE».
After configuring the primary LVS router node's network interfaces, configure the backup LVS router's real network interfaces — taking care that none of the IP address conflict with any other IP addresses on the network.

Importante

Assicuratevi che ogni interfaccia sul nodo di backup serva la stessa rete dell'interfaccia presente sul nodo primario. Per esempio se eth0 si collega alla rete pubblica sul nodo primario, la stessa deve collegarsi anche alla rete pubblica sul nodo di backup.

3.1.2. Instradamento sui real server

La cosa più importante da ricordare durante la configurazione delle interfacce di rete dei real server in una topologia NAT, è quella d'impostare il gateway per l'indirizzo IP floating NAT del router LVS. In questo esempio, l'indirizzo in questione sarà 10.11.12.10.

Nota

Once the network interfaces are up on the real servers, the machines will be unable to ping or connect in other ways to the public network. This is normal. You will, however, be able to ping the real IP for the LVS router's private interface, in this case 10.11.12.8.
So the real server's /etc/sysconfig/network-scripts/ifcfg-eth0 file could look similar to this:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.11.12.1
NETMASK=255.255.255.0
GATEWAY=10.11.12.10

Avvertimento

Se un real server possiede più di una interfaccia di rete configurata con la riga GATEWAY=, la prima interfaccia usata otterrà il gateway. Per questo motivo se eth0 e eth1 sono configurate, e eth1 viene utilizzata per LVS, i real server potrebbero non indirizzare le richieste in modo corretto.
È fortemente consigliato disabilitare le interfacce di rete estranee tramite l'impostazione di ONBOOT=no, negli script di rete interessati all'interno della directory /etc/sysconfig/network-scripts/, oppure assicuratevi che il gateway sia stato impostato correttamente nella prima interfaccia usata.

3.1.3. Abilitzione del NAT Routing sui router LVS

In a simple NAT LVS configuration where each clustered service uses only one port, like HTTP on port 80, the administrator needs only to enable packet forwarding on the LVS routers for the requests to be properly routed between the outside world and the real servers. See Sezione 2.5, «Abilitazione del Packet Forwarding» for instructions on turning on packet forwarding. However, more configuration is necessary when the clustered services require more than one port to go to the same real server during a user session. For information on creating multi-port services using firewall marks, see Sezione 3.4, «Servizi multi-port e LVS».
Once forwarding is enabled on the LVS routers and the real servers are set up and have the clustered services running, use the Piranha Configuration Tool to configure LVS as shown in Capitolo 4, Configurazione dei router LVS con Piranha Configuration Tool.

Avvertimento

Do not configure the floating IP for eth0:1 or eth1:1 by manually editing network scripts or using a network configuration tool. Instead, use the Piranha Configuration Tool as shown in Sezione 4.4, «GLOBAL SETTINGS» and Sezione 4.6.1, «La sottosezione SERVER VIRTUALE».
When finished, start the pulse service as shown in Sezione 4.8, «Avvio di LVS». Once pulse is up and running, the active LVS router will begin routing requests to the pool of real servers.