Este post vai abordar uma forma que pode ser usada nas versões RHEL,Centos,OEL e etc.Para debian a localização dos arquivos mudam um pouco então vai ficar para outro post.
O conceito é ter duas placas de redes trabalhando como se fosse uma.Em ambiente Oracle RAC é muito utilizado .
A imagem abaxo é provida by Google mesmo :
Tenho um server rodando Openfiler(rpath linux),adicionei 2 placas de rede eth1 e eth2 :
eth1 Link encap:Ethernet HWaddr 08:00:27:F9:6C:D1
inet addr:10.7.7.8 Bcast:10.7.7.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef9:6cd1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:94 errors:0 dropped:0 overruns:0 frame:0
TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9532 (9.3 Kb) TX bytes:4078 (3.9 Kb)
eth2 Link encap:Ethernet HWaddr 08:00:27:36:28:DB
inet addr:10.7.7.9 Bcast:10.7.7.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe36:28db/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:410 errors:0 dropped:0 overruns:0 frame:0
TX packets:255 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:54430 (53.1 Kb) TX bytes:40355 (39.4 Kb)
[root@storage1 proc]# cd /etc/sysconfig/network-scripts/
Precisamos editar os arquivos ifcfg-NIC( ex.ifcfg-eth0) .
Vamos deixa-los desta forma :
DEVICE=eth0 USERCTL=no ONBOOT=yes MASTER=bond0 SLAVE=yes BOOTPROTO=none TYPE=Ethernet
|
Obs.USERCTL é o parametro de controle espeficando que somente o root poderá ter controle sobre o device.
No parametro DEVICE teremos em um arquivo eth1 eno outro eth2 conforme o device correspodente.
Fiz uma cópia dos arquivos via cp mesmo e mv e temos :
-rw-r--r-- 1 root root 155 Aug 11 16:56 ifcfg-eth1.old
-rw-r--r-- 1 root root 38 Aug 11 20:09 ifcfg-eth0
-rw-r--r-- 1 root root 155 Aug 13 19:10 ifcfg-eth1
-rw-r--r-- 1 root root 155 Aug 13 19:10 ifcfg-eth2
[root@storage1 network-scripts]#
[root@storage1 network-scripts]# more ifcfg-eth2
DEVICE=eth2
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
[root@storage1 network-scripts]# more ifcfg-eth1
DEVICE=eth1
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
Agora o detalhe.Vamos criar um arquivo para o novo device bond0 e editá-lo:
[root@storage1 network-scripts]# cp ifcfg-eth1.old ifcfg-bond0
[root@storage1 network-scripts]# more ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
IPADDR=10.7.7.10
NETMASK=255.255.255.0
ONBOOT=yes
USERCTL=no
Arquivos prontos vamos editar o arquivo /etc/modprobe.conf e adcionar as seguintes linhas :
<snip>
alias bond0 bonding
options bond0 miimon=100 mode=1
</snip>
Remover o arquivo desnecessário :
[root@storage1 network-scripts]# rm -rfv ifcfg-eth1.old
removed `ifcfg-eth1.old'
[root@storage1 network-scripts]#
Reiniciar o serviço de rede :
[root@storage1 network-scripts]# service network restart
Shutting down interface bond0: [ OK ]
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down interface eth2: [ OK ]
Shutting down loopback interface: [ OK ]
Removing bonding module: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface bond0: Enslaving eth1 to bond0
Enslaving eth2 to bond0
[ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
[root@storage1 network-scripts]#
Obs.Eu já havia habilitado a bond0,por isso meu output saiu um pouco diferente.
[root@storage1 network-scripts]# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:F9:6C:D1
inet addr:10.7.7.10 Bcast:10.7.7.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef9:6cd1/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:9281 errors:0 dropped:0 overruns:0 frame:0
TX packets:7506 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1340824 (1.2 Mb) TX bytes:1201622 (1.1 Mb)
eth0 Link encap:Ethernet HWaddr 08:00:27:88:81:1E
inet addr:10.7.7.101 Bcast:10.7.7.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe88:811e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4819 errors:0 dropped:0 overruns:0 frame:0
TX packets:4413 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:790732 (772.1 Kb) TX bytes:682460 (666.4 Kb)
eth1 Link encap:Ethernet HWaddr 08:00:27:F9:6C:D1
inet addr:10.7.7.10 Bcast:10.7.7.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:1091 errors:0 dropped:0 overruns:0 frame:0
TX packets:868 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:137663 (134.4 Kb) TX bytes:128429 (125.4 Kb)
eth2 Link encap:Ethernet HWaddr 08:00:27:F9:6C:D1
inet addr:10.7.7.10 Bcast:10.7.7.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:8191 errors:0 dropped:0 overruns:0 frame:0
TX packets:6639 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1203227 (1.1 Mb) TX bytes:1073435 (1.0 Mb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:107 errors:0 dropped:0 overruns:0 frame:0
TX packets:107 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2342 (2.2 Kb) TX bytes:2342 (2.2 Kb)
[root@storage1 network-scripts]# ping bond0
^C
[root@storage1 network-scripts]# ping 10.7.7.10
PING 10.7.7.10 (10.7.7.10) 56(84) bytes of data.
64 bytes from 10.7.7.10: icmp_seq=0 ttl=64 time=0.521 ms
64 bytes from 10.7.7.10: icmp_seq=1 ttl=64 time=0.090 ms
^C
--- 10.7.7.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.090/0.305/0.521/0.216 ms, pipe 2
[root@storage1 network-scripts]#
Vamos testar agora de um outro host se realmente está funcionando:
jccorrea|ubuntudesktop /
$ ping 10.7.7.10
PING 10.7.7.10 (10.7.7.10) 56(84) bytes of data.
64 bytes from 10.7.7.10: icmp_seq=1 ttl=64 time=0.347 ms
64 bytes from 10.7.7.10: icmp_seq=2 ttl=64 time=0.261 ms
^C
--- 10.7.7.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.261/0.304/0.347/0.043 ms
jccorrea|ubuntudesktop /
$ ssh root@10.7.7.10
root@10.7.7.10's password:
Last login: Fri Aug 13 18:42:44 2010 from 10.7.7.1
[root@storage1 ~]#
[root@storage1 ~]# tcpdump -i bond0 -c 15
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond0, link-type EN10MB (Ethernet), capture size 96 bytes
22:24:33.946529 IP 10.7.7.101.ssh > 10.7.7.1.33533: P 473451413:473451525(112) ack 365296259 win 429 <nop,nop,timestamp 3904714 28213627>
22:25:13.982943 IP 10.7.7.1.33533 > 10.7.7.101.ssh: . ack 112 win 23888 <nop,nop,timestamp 28213632 3904714>
22:25:13.982973 IP 10.7.7.101.ssh > 10.7.7.1.33533: P 112:224(112) ack 1 win 429 <nop,nop,timestamp 3904715 28213632>
22:24:33.947043 IP 10.7.7.1.33533 > 10.7.7.101.ssh: . ack 224 win 23888 <nop,nop,timestamp 28213633 3904715>
22:24:33.948205 IP 10.7.7.10.59472 > 172.16.36.1.domain: 48745+ PTR? 1.7.7.10.in-addr.arpa. (39)
22:24:34.484064 IP 10.7.7.1 > 10.7.7.10: ICMP echo request, id 21077, seq 83, length 64
22:24:34.484100 IP 10.7.7.10 > 10.7.7.1: ICMP echo reply, id 21077, seq 83, length 64
22:24:34.868340 IP 10.7.7.1 > 10.7.7.10: ICMP echo request, id 13141, seq 108, length 64
22:24:34.868370 IP 10.7.7.10 > 10.7.7.1: ICMP echo reply, id 13141, seq 108, length 64
22:24:35.484814 IP 10.7.7.1 > 10.7.7.10: ICMP echo request, id 21077, seq 84, length 64
22:24:35.484859 IP 10.7.7.10 > 10.7.7.1: ICMP echo reply, id 21077, seq 84, length 64
22:24:35.867589 IP 10.7.7.1 > 10.7.7.10: ICMP echo request, id 13141, seq 109, length 64
22:24:35.867623 IP 10.7.7.10 > 10.7.7.1: ICMP echo reply, id 13141, seq 109, length 64
22:24:36.483285 IP 10.7.7.1 > 10.7.7.10: ICMP echo request, id 21077, seq 85, length 64
22:24:36.483330 IP 10.7.7.10 > 10.7.7.1: ICMP echo reply, id 21077, seq 85, length 64
15 packets captured
920 packets received by filter
661 packets dropped by kernel
[root@storage1 ~]# ifconfig bond0
bond0 Link encap:Ethernet HWaddr 08:00:27:F9:6C:D1
inet addr:10.7.7.10 Bcast:10.7.7.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef9:6cd1/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:32466 errors:0 dropped:0 overruns:0 frame:0
TX packets:155434 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3919603 (3.7 Mb) TX bytes:39208375 (37.3 Mb)
Obs.Caso não suba corretamente tente :
modprobe bonding
|
Para configurar no Red Hat 5/OEL 5 mudou a localização de um parametro .Agora você coloca o parametro BONDING_OPTS="miimon=100 mode=1" dentro do arquivo /etc/sysconfig/network-scripts/ifcfg-bond0 e no arquivo /etc/modprobe.conf somente deixe a linha alias bond0 bonding .
Tudo deve funcionar Ok.
Uma outra coisa interessante é o parametro mode que pode ser colocado nas versões anteriores no modprobe.conf ou no RHEL 5 no próprio arquivo do device bondn.O default se não espefificar nenhuma parametro é mode=0 ou balance-rr.
“ balance-rr or 0
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.”
Enviar pacotes em order sequencial da primeira placa slave para a ultima.Trabalha com load balancing e tolerancia a falhas.
Para testar o mode tive que pesquisar sobre o rpath Linux e o gerenciador de pacotes chamado conary.Para minha sorte um amigo aqui da empresa ,o André me deu uma força!
Link legal:
Abs,
JC