叁叁肆

这个世界会好吗

453篇博客

玩转Openvwitch第六站:Port和Bond

叁叁肆2018-11-06 16:36

此文已由作者刘超授权网易云社区发布。

欢迎访问网易云社区,了解更多网易技术产品运营经验。


有关Interface,就不得不提Bond


Bond将设备用多个连接在一起,形成一个虚拟的连接,从而实现高可用性以及高吞吐量


很多别名:LACP Trunk, Bond, Etherchannel


LACP (Link Aggregation Control Protocol)





bond_mode

  • active-backup: 一个连接是active,其他的backup,当active失效的时候,backup顶上

  • balance-slb: 流量安装源MAC和output VLAN进行负载均衡

  • balance-tcp:必须在支持LACP协议的情况下才可以,可根据L2, L3, L4进行负载均衡


我们做个实验测试Bond



ovs-vsctl add-bond ubuntu_br bond0 first_br second_br

ovs-vsctl add-bond helloworld bond1 first_if second_if


ovs-vsctl set Port bond0 lacp=active

ovs-vsctl set Port bond1 lacp=active



查看Bond



查看LACP


root@popsuper1982:/home/openstack# ovs-appctl lacp/show

---- bond0 ----

        status: active negotiated

        sys_id: 2a:96:0e:c7:85:49

        sys_priority: 65534

        aggregation key: 7

        lacp_time: slow


slave: first_br: current attached

        port_id: 7

        port_priority: 65535

        may_enable: true


        actor sys_id: 2a:96:0e:c7:85:49

        actor sys_priority: 65534

        actor port_id: 7

        actor port_priority: 65535

        actor key: 7

        actor state: activity aggregation synchronized collecting distributing


        partner sys_id: 72:d2:d3:59:8c:41

        partner sys_priority: 65534

        partner port_id: 3

        partner port_priority: 65535

        partner key: 3

        partner state: activity aggregation synchronized collecting distributing


slave: second_br: current attached

        port_id: 8

        port_priority: 65535

        may_enable: true


        actor sys_id: 2a:96:0e:c7:85:49

        actor sys_priority: 65534

        actor port_id: 8

        actor port_priority: 65535

        actor key: 7

        actor state: activity aggregation synchronized collecting distributing


        partner sys_id: 72:d2:d3:59:8c:41

        partner sys_priority: 65534

        partner port_id: 4

        partner port_priority: 65535

        partner key: 3

        partner state: activity aggregation synchronized collecting distributing

---- bond1 ----

        status: active negotiated

        sys_id: 72:d2:d3:59:8c:41

        sys_priority: 65534

        aggregation key: 3

        lacp_time: slow


slave: first_if: current attached

        port_id: 3

        port_priority: 65535

        may_enable: true


        actor sys_id: 72:d2:d3:59:8c:41

        actor sys_priority: 65534

        actor port_id: 3

        actor port_priority: 65535

        actor key: 3

        actor state: activity aggregation synchronized collecting distributing


        partner sys_id: 2a:96:0e:c7:85:49

        partner sys_priority: 65534

        partner port_id: 7

        partner port_priority: 65535

        partner key: 7

        partner state: activity aggregation synchronized collecting distributing


slave: second_if: current attached

        port_id: 4

        port_priority: 65535

        may_enable: true


        actor sys_id: 72:d2:d3:59:8c:41

        actor sys_priority: 65534

        actor port_id: 4

        actor port_priority: 65535

        actor key: 3

        actor state: activity aggregation synchronized collecting distributing


        partner sys_id: 2a:96:0e:c7:85:49

        partner sys_priority: 65534

        partner port_id: 8

        partner port_priority: 65535

        partner key: 7

        partner state: activity aggregation synchronized collecting distributing


默认情况下bond_mode是active-backup模式,一开始active的是first_br和first_if


从192.168.100.100 ping 192.168.100.102,以及192.168.100.101 ping 192.168.100.103,都是从first_if通过



如果把first_if设成down,则包的走向会变


ip link set first_if down


发现second_if开始有流量,京first_if变成down, 192.168.100.100和192.168.100.101似乎没有收到影响


second_br和second_if变成active



重启first_if,但是second_br和second_if仍然是active

ip link set first_if up



把bond_mode设为balance-slb

  • ovs-vsctl set Port bond0 bond_mode=balance-slb

  • ovs-vsctl set Port bond1 bond_mode=balance-slb

  • 同时192.168.100.100 ping 192.168.100.102,192.168.100.101 ping 192.168.100.103, 已经分流了


把bond_mode设为balance-tcp

  • ovs-vsctl set Port bond0 bond_mode=balance-tcp

  • ovs-vsctl set Port bond1 bond_mode=balance-tcp

  • 同时在192.168.100.100上:netperf -H 192.168.100.102 -t UDP_STREAM -- -m 1024

  • 在192.168.100.101上: netperf -H 192.168.100.103 -t UDP_STREAM -- -m 1024


免费体验云安全(易盾)内容安全、验证码等服务

11.1—11.15云计算基础服务全场5折起

更多网易技术、产品、运营经验分享请点击