centos8双网卡聚合

《centos8双网卡聚合》

网卡聚合的模式:

网卡聚合的有7中模式,balance-rr,active-backup,balance-xor,broadcast,802.3ad,balance-tlb,balance-alb。模式的代号从0开始到6结束。其工作模式可以分为两类:多主型工作模式和主备型工作模式。分别解释一下模式:

0.balcancec-rr
This mode is based on Round-robin policy and it is the default mode. This mode offers fault tolerance and load balancing features. It transmits the packets in Round robin fashion that is from the first available slave through the last.
该模式基于轮询策略,为默认模式。这种模式提供了容错和负载平衡特性。它以轮询的方式传输数据包,从第一个可用的slave到最后一个可用的slave。
1.active-backup
This mode is based on Active-backup policy. Only one slave is active in this band, and another one will act only when the other fails. The MAC address of this bond is available only on the network adapter part to avoid confusing the switch. This mode also provides fault tolerance.
该模式基于Active-backup策略。在这个频带中只有一个slave是活跃的,另一个只有在另一个失败时才会起作用。为避免交换机混淆,此bond的MAC地址仅在网卡部分可用。该模式还提供了容错功能。
2.balance-xor
This mode sets an XOR (exclusive or) mode that is the source MAC address is XOR’d with destination MAC address for providing load balancing and fault tolerance. Each destination MAC address the same slave is selected.
该模式设置源MAC地址与目的MAC地址异或(exclusive or)模式,以提供负载均衡和容错功能。每个目的MAC地址选择相同的slave。
3.broadcast
This method is based on broadcast policy that is it transmitted everything on all slave interfaces. It provides fault tolerance. This can be used only for specific purposes.
该方法基于广播策略,即在所有从接口上传输所有内容。它提供了容错功能。这只能用于特定的目的。
4.802.3ad
This mode is known as a Dynamic Link Aggregation mode that has it created aggregation groups having same speed. It requires a switch that supports IEEE 802.3ad dynamic link. The slave selection for outgoing traffic is done based on a transmit hashing method. This may be changed from the XOR method via the xmit_hash_policy option.
这种模式称为动态链路聚合模式,即创建速率相同的聚合组。需要一台支持ieee802.3 ad动态链路的交换机。传出流量的从选是基于一种传输哈希方法来完成的。这可以通过xmit_hash_policy选项从XOR方法更改。
5.balance-tlb  <<<<<
This mode is called Adaptive transmit load balancing. The outgoing traffic is distributed based on the current load on each slave and the incoming traffic is received by the current slave. If the incoming traffic fails, the failed receiving slave is replaced by the MAC address of another slave. This mode does not require any special switch support.
这种模式称为自适应传输负载均衡。流出的流量根据每个slave的当前负载进行分配,流入的流量由当前slave接收。如果进入的流量失败,则用另一个slave的MAC地址替换失败的slave。该模式不需要任何特殊的交换机支持。
6.balance-alb  <<<<<<
This mode is called adaptive load balancing. This mode does not require any special switch support.
这种模式称为自适应负载均衡。该模式不需要任何特殊的交换机支持。

配置mode=6的双网卡聚合

根据业务情况,只能选择mode=6的balance-alb模式,这种模式不依赖于交换机,同时能够将2个1000Mbps的网卡聚合到总流量为2000Mbps

配置虚拟网卡bond0

//进入/etc/sysconfig/network-scripts目录,在该目录下新建一个名为ifcfg-bond0的文件,里面内容为:
#cd /etc/sysconfig/network-scripts/
#vi ifcfg-bond0
BOOTPROTO=static
NAME=bond0
DEVICE=bond0
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=6 miimon=100" #指定绑定类型为6及链路状态监测间隔时间
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=114.114.114.114
//网卡0设置 此网卡为100M
TYPE=Ethernet
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE=stable-privacy
IPV6_PRIVACY="no"
NAME=enp2s0
UUID=c2d1b694-cfcd-4290-b53d-4d1fb60becdd
DEVICE=enp2s0
ONBOOT="yes"
#IPADDR="192.168.0.90"
#PREFIX="24"
#GATEWAY="192.168.0.1"
#DNS1="114.114.114.114"
MASTER="bond0"
USERCTL="no"
SLAVE="yes"
//网卡1设置 此网卡为1000M
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="yes"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
IPV6_PRIVACY="no"
NAME="enp1s0"
UUID="44e8e2dc-9451-43a5-8b5f-e9ce47adde11"
DEVICE="enp1s0"
ONBOOT="yes"
ETHTOOL_OPTS="autoneg off speed 100 duplex full"
#IPADDR="192.168.0.91"
#PREFIX="24"
#GATEWAY="192.168.0.1"
#DNS1="114.114.114.114"
MASTER="bond0"
USERCTL="no"
SLAVE="yes"

重启顺序

#nmcli c reload
#nmcli c up bond0  //启动
#nmcli c down enp1s0
#nmcli c up enp1s0 //这时的bond0的速率为 enp1s0
#nmcli c down enp2s0
#nmcli c up enp2s0 //这时的bond0的速率为 enp1s0+enp2s0
#nmcli c up bond0  //最后再启动一次!!!

//查看速率
[root@localhost ~]# ethtool bond0
Settings for bond0:
	Supported ports: [ ]
	Supported link modes:   Not reported
	Supported pause frame use: No
	Supports auto-negotiation: No
	Supported FEC modes: Not reported
	Advertised link modes:  Not reported
	Advertised pause frame use: No
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 1100Mb/s
	Duplex: Full
	Port: Other
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: off
	Link detected: yes


#[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 70:e2:4c:68:03:ad brd ff:ff:ff:ff:ff:ff
3: enp2s0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 70:e2:4c:68:03:ae brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 70:e2:4c:68:03:ae brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global noprefixroute bond0
       valid_lft forever preferred_lft forever
点赞

发表评论

邮箱地址不会被公开。 必填项已用*标注