网卡的链路聚合就是将多块网卡连接起来,当-块网卡损坏,网络依旧可以正常运行,可以有效的防止因为网卡损坏带来的损失,同时也可以提高网络访问速度。
bond:最多可以添加两块网卡
team:最多可以添加八块网卡
bond的常用的2种模式:
bond0(balance-rr)
bond1(active-backup)
team可以实现以下模式的聚合链路:
这七种模式分别是:
802.3ad balance-alb balance-tlb broadcast active-backup balance-rr balance-xor
[root@localhost ~]# nmcli de
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet disconnected --
eth2 ethernet disconnected --
lo loopback unmanaged --
//绑定物理网卡,事先必须断开物理网卡的连接
[root@localhost ~]# nmcli connection add type bond con-name bond0 ifname bond0 mode balance-rr ipv4.method manual ipv4.addresses 192.168.174.150/24 ipv4.gateway 192.168.174.2 ipv4.dns 8.8.8.8
Connection 'bond0' (b038c7fb-e1f8-4436-b6d6-8ab6f6177cd4) successfully added.
[root@localhost ~]# ip addr show bond0
5: bond0:
link/ether 6a:82:e0:bc:f4:e9 brd ff:ff:ff:ff:ff:ff
inet 192.168.174.150/24 brd 192.168.174.255 scope global noprefixroute bond0
valid_lft forever preferred_lft forever
//查看bond0网络接口状态
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
bond0 b038c7fb-e1f8-4436-b6d6-8ab6f6177cd4 bond bond0
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# nmcli connection add type bond-slave con-name slave1 ifname eth1 master bond0
Connection 'slave1' (a188a30f-4aea-43ff-82b2-b9cd6ebf076a) successfully added.
[root@localhost ~]# nmcli connection add type bond-slave con-name slave2 ifname eth2 master bond0
Connection 'slave2' (38072c0c-ca0b-4cc8-b762-15d277b74f26) successfully added.
//查看bond-slave查看网络接口状态
[root@localhost ~]# nmcli connection
NAME UUID TYPE DEVICE
bond0 b038c7fb-e1f8-4436-b6d6-8ab6f6177cd4 bond bond0
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
slave1 a188a30f-4aea-43ff-82b2-b9cd6ebf076a ethernet --
slave2 38072c0c-ca0b-4cc8-b762-15d277b74f26 ethernet --
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# nmcli connection up slave1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@localhost ~]# nmcli connection up slave2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:fa:c0:fa
Slave queue ID: 0
Slave Interface: eth2
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:fa:c0:04
Slave queue ID: 0
[root@localhost ~]# nmcli device disconnect eth0
[root@localhost ~]# ip addr show
1: lo:
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:fa:c0:f0 brd ff:ff:ff:ff:ff:ff
inet 192.168.174.139/24 brd 192.168.174.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::a101:bf00:d10e:9788/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
4: eth2:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
5: bond0:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
inet 192.168.174.140/24 brd 192.168.174.255 scope global dynamic noprefixroute bond0
valid_lft 1542sec preferred_lft 1542sec
inet 192.168.174.150/24 brd 192.168.174.255 scope global secondary noprefixroute bond0
valid_lft forever preferred_lft forever
inet6 fe80::97b0:2962:6eab:49fc/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@localhost ~]# nmcli connection add type bond con-name bond1 ifname bond1 mode active-backup ipv4.method manual ipv4.addresses 192.168.174.160/24 ipv4.gateway 192.168.174.2 ipv4.dns 8.8.8.8
Connection 'bond1' (79fb7f29-4da5-46eb-8915-0d14b20d7e16) successfully added.
[root@localhost ~]# ip addr show bond1
6: bond1:
link/ether 3e:5e:4f:a1:31:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.174.160/24 brd 192.168.174.255 scope global noprefixroute bond1
valid_lft forever preferred_lft forever
/ /查看bond1网卡连接状态
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
bond1 79fb7f29-4da5-46eb-8915-0d14b20d7e16 bond bond1
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# nmcli connection add type bond-slave con-name slave1 ifname eth1 master bond1
Connection 'slave1' (fdb0b4af-604c-4a56-b3ba-0c72d7172807) successfully added.
[root@localhost ~]# nmcli connection add type bond-slave con-name slave2 ifname eth2 master bond1
Connection 'slave2' (80abf4ac-348a-4f8a-8df8-4f1dc45db4c1) successfully added.
[root@localhost ~]# cat /proc/net/bonding/bond1
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:fa:c0:fa
Slave queue ID: 0
Slave Interface: eth2
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:fa:c0:04
Slave queue ID: 0
测试
//停掉eth1,查看配置文件状态
[root@localhost ~]# nmcli device disconnect eth1
成功断开设备 "eth1"。
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth2
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29💿6a:2f
Slave queue ID: 0
//停掉eth2,查看配置文件状态
[root@localhost ~]# nmcli device connect eth1
成功用 "eth154935406-3bcd-4d24-b58c-4e9f86c2999b" 激活了设备 ""。
[root@localhost ~]# nmcli device disconnect eth2
成功断开设备 "eth2"。
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29💿6a:25
Slave queue ID: 0
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet disconnected --
eth2 ethernet disconnected --
lo loopback unmanaged --
//创建之前,必须断开网卡的连接
[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"roundrobin"}}' ipv4.method manual ipv4.addresses 192.168.174.150/24 ipv4.gateway 192.168.174.2 ipv4.dns 8.8.8.8
Connection 'team0' (b2a9d127-0ef4-479a-89c0-77137db2d825) successfully added.
//查看team0网卡设备的状态
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
team0 team connected team0
eth1 ethernet disconnected --
eth2 ethernet disconnected --
lo loopback unmanaged --
[root@localhost ~]# nmcli connection add type team-slave con-name slave1 ifname eth1 master team0
Connection 'slave1' (e88752fb-bad8-4e30-8374-c087e34fc9b9) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name slave2 ifname eth2 master team0
Connection 'slave2' (fe58bc8d-97e4-4390-8490-8d898fcb7c8b) successfully added.
[root@localhost ~]# nmcli connection
NAME UUID TYPE DEVICE
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
team0 b2a9d127-0ef4-479a-89c0-77137db2d825 team team0
slave1 7b2d11d2-a939-4cb4-a751-73cfe52f6872 ethernet --
slave2 05a4815e-5a22-40ca-a917-ee25a6286c6e ethernet --
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# nmcli connection up slave1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@localhost ~]# nmcli connection up slave2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@localhost ~]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)
[root@localhost ~]# ip addr
1: lo:
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:fa:c0:f0 brd ff:ff:ff:ff:ff:ff
inet 192.168.174.139/24 brd 192.168.174.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::a101:bf00:d10e:9788/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
4: eth2:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
10: team0:
link/ether 00:0c:29:fa:c0:fa brd ff:ff:ff:ff:ff:ff
inet 192.168.174.150/24 brd 192.168.174.255 scope global noprefixroute team0
valid_lft forever preferred_lft forever
inet6 fe80::7277:ccf3:77f3:262f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@localhost ~]# teamdctl team0 state
setup:
runner: roundrobin
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
[root@localhost ~]# nmcli connection add type team con-name team1 ifname team1 config '{"runner":{"name":"activebackup"}}' ipv4.method manual ipv4.addresses 192.168.174.190/24 ipv4.gateway 192.168.174.2 ipv4.dns 8.8.8.8
Connection 'team1' (f315f9cb-8b13-4372-8163-ec41a30c44af) successfully added.
//查看team1网卡状态
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
team1 team connected team1
eth1 ethernet disconnected --
eth2 ethernet disconnected --
lo loopback unmanaged --
[root@localhost ~]# nmcli connection
NAME UUID TYPE DEVICE
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
team1 f315f9cb-8b13-4372-8163-ec41a30c44af team team1
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# nmcli connection add type team-slave con-name slave1 ifname eth1 master team1
Connection 'slave1' (063127d0-88d2-41bf-988c-9c79a31f9b32) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name slave2 ifname eth2 master team1
Connection 'slave2' (ecc6d36f-5d92-44b7-979b-b835b8b7facc) successfully added.
[root@localhost ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
team1 team connected team1
eth1 ethernet connected slave1
eth2 ethernet connected slave2
lo loopback unmanaged --
[root@localhost ~]# nmcli connection
NAME UUID TYPE DEVICE
eth0 f7036e05-ee1b-4ceb-94cc-0845ace9f4c1 ethernet eth0
team1 f315f9cb-8b13-4372-8163-ec41a30c44af team team1
slave1 063127d0-88d2-41bf-988c-9c79a31f9b32 ethernet eth1
slave2 ecc6d36f-5d92-44b7-979b-b835b8b7facc ethernet eth2
Wired connection 1 a761ff76-b76c-307e-939b-cbe2ecc41bc7 ethernet --
Wired connection 2 f70e7fbb-52d0-3cb3-bc6c-7e937553ac06 ethernet --
[root@localhost ~]# teamdctl team1 state
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eth1
[root@localhost ~]# teamdctl team1 config dump > /root/team.conf (dump:下载)
[root@localhost ~]# ls
anaconda-ks.cfg team.conf
[root@localhost ~]# vim team.conf
{
"device": "team1",
"mcast_rejoin": {
"count": 1
},
"notify_peers": {
"count": 1
},
"ports": {
"eth1": {
"link_watch": {
"name": "ethtool"
}
},
"eth2": {
"link_watch": {
"name": "ethtool"
}
}
},
"runner": {
"name": "roundrobin" //将acticebackup换成roundrobin
}
}
[root@localhost ~]# nmcli connection modify team1 team.config /root/team.conf
[root@localhost ~]# nmcli connection down team1;nmcli connection up team1
Connection 'team1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/21)
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/24)
[root@localhost ~]# teamdctl team1 state
setup:
runner: roundrobin //改完后就回发生改变
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
手机扫一扫
移动阅读更方便
你可能感兴趣的文章