Red Hat Training

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

Capítulo 3. Configurando o LVS

O LVS consiste em dois grupos básicos: os roteadores LVS e os servidores reais. Para previnir um único ponto de falha, cada grupo deve conter pelo menos dois sistemas membros.
O grupo de roteador LVS deve consistir em dois sistemas idênticos ou bem similar executando a Red Hat Enterprise Linux. Um irá atuar como roteador LVS ativo enquanto que o outro permanecerá no modo standby ativo, desta forma eles precisam ter capacidades bem parecidas.
Antes de escolher e configurar o hardware para o grupo do servidor real, você deve decidir qual dos três tipos de topologia LVS a ser usado.

3.1. A rede LVS-NAT

A topologia NAT permite uma notável latitude em se utilizar o hardware existente, porém é limitada em sua habilidade de manusear cargas volumosas, devido ao fato de que todos os pacotes que entram e saem do cluster passam pelo roteador LVS.
Layout da Rede
A topologia para o LVS utilizando o roteamento NAT é a mais fácil de ser configurada, de uma perspectiva do layout da rede, devido ao cluster precisar apenas de um ponto de acesso à rede pública. Os servidores reais passam todas as solicitações de volta através do roteador LVS, desta forma eles estarão na própria rede privada.
Hardware
A topologia NAT é a mais flexível em termos de hardware, devido aos servidores reais não precisarem estar nas máquinas Linux para funcionar corretamente. Numa topologia NAT, cada servidor real apenas precisa de um NIC uma vez que isto estará apenas respondendo ao roteador LVS. Por outro lado, os roteadores LVS precisam de dois NICs cada para rotear o tráfego entre duas redes. Devido a esta topologia criar uma rede de afunilamento no roteador LVS, o Ethernet gigabit NICs pode ser implantado em cada roteador LVS para aumentar a largura da banda que os roteadores LVS podem suportar. Caso o Ethernet gigabit seja implantado nos roteadores LVS, qualquer conexão de troca dos servidores reais aos roteadores LVS devem ter pelo menos dois portais Ethernet gigabit para identificar a carga eficientemente.
Software
Devido a topologia NAT requerer o uso de iptables para algumas configurações, pode existir um número regulado de configuração de software fora da Piranha Configuration Tool. Particularmente, os serviços FTP e o uso das marcas firewall requerem uma configuração extra manual dos roteadores LVS à apropriada solicitação de roteador.

3.1.1. Interfaces da Rede Configurada pelo LVS com 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
O /etc/sysconfig/network-scripts/ifcfg-eth1 para a interface NAT privada no roteador LVS pode ser similar a:
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 Seção 4.4, “GLOBAL SETTINGS and Seção 4.6.1, “A Subseção do SERVIDOR VIRTUAL.
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

Certifique-se que cada interface no nó de backup serve a mesma rede com a interface no nó primário. Por exemplo, se o eth0 conectar a mesma rede pública no nó primário, isto deverá também se comunicar a rede pública no nó de backup.

3.1.2. Roteadores em Servidores Reais

O mais importante é lembrar que quando configurando as interfaces da rede de servidores reais numa topologia NAT, a porta de ligação deve ser ajustada para o endereço IP flutuante do roteador LVS. Neste exemplo, o endereço será 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

Atenção

Caso um servidor real tiver mais de uma interface de rede configurada com a linha GATEWAY=, a primeira a aparecer chegará à saída. Portanto, caso os dois eth0 e eth1 sejam configurados e o eth1 for usado para LVS, os servidores reais talvez não roteiem as solicitações apropriadamente.
É recomendável desligar as interfaces da rede externa configurando ONBOOT=no nos scripts da rede, com o diretório /etc/sysconfig/network-scripts/ ou garantindo que a porta de comunicação está corretamente adaptada na rede, da qual será a primeira a aparecer.

3.1.3. Ativando os Roteadores NAT em Roteadores 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 Seção 2.5, “Ligando Pacote de Encaminhamento” 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 Seção 3.4, “Serviços de Portal Múltiplo 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 Capítulo 4, Configurando os roteadores LVS com a Piranha Configuration Tool.

Atenção

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 Seção 4.4, “GLOBAL SETTINGS and Seção 4.6.1, “A Subseção do SERVIDOR VIRTUAL.
When finished, start the pulse service as shown in Seção 4.8, “Iniciando o LVS”. Once pulse is up and running, the active LVS router will begin routing requests to the pool of real servers.