Buenas pessoal!

Neste post vou explicar como fazemos bonding, ou seja, como fazemos várias interfaces de rede ( eths ) trabalharem como apenas uma ou como fazer interfaces de backup.

Obs: este post está focado para sistemas operacionais baseados em RedHat 😉

Vamos ao conceito:

Bonding vem de encontro a necessidade dos ambientes computacionais de aumentar o throughput da rede e trazer maior disponibilidade dos servidores.

Existem 7 modos de trabalho no bonding:

  • Modo 0 (balanceamento) : envia os pacotes ( no modo Round-robin ), de forma sequencial, pelas interfaces de rede configurada. Este modo traz traz tolerância a falhas e balanceamento de carga entre as interfaces. Obs: cuidado ao usar este modo, pois o switch pode se perder ao receber pacotes com um mesmo MAC em diferentes portas! ( passei por um problema assim esses dias ;( )
  • Modo 1 (backup) : Apenas uma interface fica ativa no bonding por vez. Se a interface cair, o bond seleciona outra interface para trabalhar.
  • Modo 2 (balanceamento xor) : baseando-se no MAC de origem, mantém uma mesma NIC escrava recebendo os pacotes. Este modo traz tolerância a falhas e balanceamento de carga entre as interfaces.
  • Modo 3 (broadcast) [ modo v1d4l0k4 ] : manda os pacotes para todas as NICs associadas. Este modo traz traz tolerância a falhas.
  • Modo 4 (Dynamic link aggregation) : Segue o padrão 802.3ad. Mas o switch tem que suportar este padrão também!
  • Modo 5 (balanceamento tlb) : Adaptive transmit load balancing, ou seja, os pacotes e as NICs são usadas conforme sua carga. ( as NICs compartilham o MAC )
  • Modo 6 (balanceamento alb) : É a soma de Adaptive transmit load balancing e Adaptive receive load balancing.

COMO CONFIGURAR UMA INTERFACE BOND?

Primeiramente vamos configurar os módulos para reconhecer a interface nova:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”W3Jvb3RAb2VsMSAvXSMgZWNobyAtZSAiYWxpYXMgYm9uZDAgYm9uZGluZ25vcHRpb25zIGJvbmQwIG1vZGU9MSBtaWltb249MTAwIiA+PiAvZXRjL21vZHByb2JlLmQvZGlzdC5jb25mIApbcm9vdEBvZWwxIC9dIyB0YWlsIC1uIDIgL2V0Yy9tb2Rwcm9iZS5kL2Rpc3QuY29uZiAKYWxpYXMgYm9uZDAgYm9uZGluZzsKb3B0aW9ucyBib25kMCBtb2RlPTEgbWlpbW9uPTEwMA==” hover_enabled=”0″]W3Jvb3RAb2VsMSAvXSMgZWNobyAtZSAiYWxpYXMgYm9uZDAgYm9uZGluZ25vcHRpb25zIGJvbmQwIG1vZGU9MSBtaWltb249MTAwIiA+PiAvZXRjL21vZHByb2JlLmQvZGlzdC5jb25mIApbcm9vdEBvZWwxIC9dIyB0YWlsIC1uIDIgL2V0Yy9tb2Rwcm9iZS5kL2Rpc3QuY29uZiAKYWxpYXMgYm9uZDAgYm9uZGluZzsKb3B0aW9ucyBib25kMCBtb2RlPTEgbWlpbW9uPTEwMA==[/et_pb_dmb_code_snippet]

Observe que colocamos uma linha informando que existe uma interface de bonding chamada bond0 e na outra linha configuramos o seu modo de trabalho ( mode=1 ).
O parâmetro miimon=100 significa o tempo ( em millis ) de verificação do estado do link.

Agora que nossa máquina já conhece uma interface bond, vamos configurar uma.

Crie um arquivo chamado /etc/sysconfig/network-scripts/ifcfg-bond0 e nele coloque o seguinte conteúdo:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”REVWSUNFPWJvbmQwCkJPT1RQUk9UTz1kaGNwCk9OQk9PVD15ZXMKTUFTVEVSPXllcw==” hover_enabled=”0″]REVWSUNFPWJvbmQwCkJPT1RQUk9UTz1kaGNwCk9OQk9PVD15ZXMKTUFTVEVSPXllcw==[/et_pb_dmb_code_snippet]

Depois disso, reconfigure as interfaces de rede que você deseja deixar como escravas e deixe-as parecido com:

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”W3Jvb3RAb2VsMSAvXSMgbW9yZSAvZXRjL3N5c2NvbmZpZy9uZXR3b3JrLXNjcmlwdHMvaWZjZmctZXRoMApERVZJQ0U9ImV0aDAiCkJPT1RQUk9UTz0ibm9uZSIKT05CT09UPSJ5ZXMiClNMQVZFPXllcwpNQVNURVI9Ym9uZDAKW3Jvb3RAb2VsMSAvXSMgbW9yZSAvZXRjL3N5c2NvbmZpZy9uZXR3b3JrLXNjcmlwdHMvaWZjZmctZXRoMQpERVZJQ0U9ImV0aDEiCkJPT1RQUk9UTz0iZGhjcCIKT05CT09UPSJ5ZXMiClNMQVZFPXllcwpNQVNURVI9Ym9uZDA=” hover_enabled=”0″]W3Jvb3RAb2VsMSAvXSMgbW9yZSAvZXRjL3N5c2NvbmZpZy9uZXR3b3JrLXNjcmlwdHMvaWZjZmctZXRoMApERVZJQ0U9ImV0aDAiCkJPT1RQUk9UTz0ibm9uZSIKT05CT09UPSJ5ZXMiClNMQVZFPXllcwpNQVNURVI9Ym9uZDAKW3Jvb3RAb2VsMSAvXSMgbW9yZSAvZXRjL3N5c2NvbmZpZy9uZXR3b3JrLXNjcmlwdHMvaWZjZmctZXRoMQpERVZJQ0U9ImV0aDEiCkJPT1RQUk9UTz0iZGhjcCIKT05CT09UPSJ5ZXMiClNMQVZFPXllcwpNQVNURVI9Ym9uZDA=[/et_pb_dmb_code_snippet]

Pronto 🙂

COMO FICOU?

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”W3Jvb3RAb2VsMSB+XSMgc2VydmljZSBuZXR3b3JrIHJlc3RhcnQKU2h1dHRpbmcgZG93biBpbnRlcmZhY2UgYm9uZDA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbICBPSyAgXQpTaHV0dGluZyBkb3duIGludGVyZmFjZSBldGgyOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsgIE9LICBdClNodXR0aW5nIGRvd24gbG9vcGJhY2sgaW50ZXJmYWNlOiAgICAgICAgICAgICAgICAgICAgICAgICAgWyAgT0sgIF0KQnJpbmdpbmcgdXAgbG9vcGJhY2sgaW50ZXJmYWNlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbICBPSyAgXQpCcmluZ2luZyB1cCBpbnRlcmZhY2UgYm9uZDA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsgIE9LICBdCkJyaW5naW5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ICAgICAgICAgIGNvbGxpc2lvbnM6MCB0eHF1ZXVlbGVuOjEwMDAgCiAgICAgICAgICBSWCBieXRlczo0NTg0NSAoNDQuNyBLaUIpICBUWCBieXRlczozOTcyNSAoMzguNyBLaUIpCgpldGgxICAgICAgTGluayBlbmNhcDpFdGhlcm5ldCAgSFdhZGRyIDA4OjAwOjI3OjA3OkQxOkVFICAKICAgICAgICAgIFVQIEJST0FEQ0FTVCBSVU5OSU5HIFNMQVZFIE1VTFRJQ0FTVCAgTVRVOjE1MDAgIE1ldHJpYzoxCiAgICAgICAgICBSWCBwYWNrZXRzOjQ4MzYgZXJyb3JzOjAgZHJvcHBlZDoxMiBvdmVycnVuczowIGZyYW1lOjAKICAgICAgICAgIFRYIHBhY2tldHM6MzA5OCBlcnJvcnM6MCBkcm9wcGVkOjAgb3ZlcnJ1bnM6MCBjYXJyaWVyOjAKICAgICAgICAgIGNvbGxpc2lvbnM6MCB0eHF1ZXVlbGVuOjEwMDAgCiAgICAgICAgICBSWCBieXRlczoxOTUyNTU0ICgxLjggTWlCKSAgVFggYnl0ZXM6NDQzOTM5ICg0MzMuNSBLaUIp” hover_enabled=”0″]W3Jvb3RAb2VsMSB+XSMgc2VydmljZSBuZXR3b3JrIHJlc3RhcnQKU2h1dHRpbmcgZG93biBpbnRlcmZhY2UgYm9uZDA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbICBPSyAgXQpTaHV0dGluZyBkb3duIGludGVyZmFjZSBldGgyOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsgIE9LICBdClNodXR0aW5nIGRvd24gbG9vcGJhY2sgaW50ZXJmYWNlOiAgICAgICAgICAgICAgICAgICAgICAgICAgWyAgT0sgIF0KQnJpbmdpbmcgdXAgbG9vcGJhY2sgaW50ZXJmYWNlOiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbICBPSyAgXQpCcmluZ2luZyB1cCBpbnRlcmZhY2UgYm9uZDA6ICAgICAgICAgICAgICAgICAgICAgICAg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