龙空技术网

Redhat 上Team and bonding对比

lypflash 54

前言:

此时兄弟们对“redhat select”大概比较关心,大家都想要了解一些“redhat select”的相关内容。那么小编也在网上网罗了一些关于“redhat select””的相关知识,希望各位老铁们能喜欢,朋友们快快来学习一下吧!

一. Redhat Team 和 bonding的区别

在b网卡绑定选项上可以根据操作系统来选择,team模式是 CentOS7 加上的,如果是 CentOS7及以上系统可选用team模式绑定,支持更多拓展性以及更节省资源。另外如果是要做桥接网络的话,目前测试只能使用bond模式,team模式无法桥接

bond只能是双网卡绑定,team不需要手动加载相应内核模块和有更强的拓展性,最高可以绑定8块网卡。其他参数区别

Feature

Bonding

Team

broadcast Tx policy

Yes

Yes

round-robin Tx policy

Yes

Yes

active-backup Tx policy

Yes

Yes

LACP (802.3ad) support

Yes (active only)

Yes

Hash-based Tx policy

Yes

Yes

User can set hash function

No

Yes

Tx load-balancing support (TLB)

Yes

Yes

LACP hash port select

Yes

Yes

load-balancing for LACP support

No

Yes

Ethtool link monitoring

Yes

Yes

ARP link monitoring

Yes

Yes

NS/NA (IPv6) link monitoring

No

Yes

ports up/down delays

Yes

Yes

port priorities and stickiness (“primary” option enhancement)

No

Yes

separate per-port link monitoring setup

No

Yes

multiple link monitoring setup

Limited

Yes

lockless Tx/Rx path

No (rwlock)

Yes (RCU)

VLAN support

Yes

Yes

user-space runtime control

Limited

Full

Logic in user-space

No

Yes

Extensibility

Hard

Easy

Modular design

No

Yes

Performance overhead

Low

Very Low

D-Bus interface

No

Yes

multiple device stacking

Yes

Yes

zero config using LLDP

No

(in planning)

NetworkManager support

Yes

Yes

1.1 bond模式介绍

一、bond模式 mode=0(balance-rr)(平衡轮循环策略) 链路负载均衡,增加带宽,支持容错,一条链路故障会自动切换正常链路。交换机需要配置静态链路聚合。 特点:传输数据包顺序是依次传输(即:第1个包走eth0,下一个包就走eth1….一直循环下去,直到最后一个传输完毕),此模式提供负载平衡和容错能力;但是我们知道如果一个连接或者会话的数据包从不同的接口发出的话,中途再经过不同的链路,在客户端很有可能会出现数据包无序到达的问题,而无序到达的数据包需要重新要求被发送,这样网络的吞吐量就会下降。

mode=1(active-backup)(主-备份策略) 这个是主备模式,只有一块网卡是active,另一块是备用的standby,所有流量都在active链路上处理。 特点:只有一个设备处于活动状态,当一个宕掉另一个马上由备份转换为主设备。mac地址是外部可见得,从外面看来,bond的MAC地址是唯一的,以避免switch(交换机)发生混乱。此模式只提供了容错能力;由此可见此算法的优点是可以提供高网络连接的可用性,但是它的资源利用率较低,只有一个接口处于工作状态,在有 N 个网络接口的情况下,资源利用率为1/N,连接交换机的两个端口不需要做LACP(链路聚合)。

mode=2(balance-xor)(平衡策略) 表示XOR Hash负载分担,和交换机的聚合强制不协商方式配合。(需要xmit_hash_policy,需要交换机配置port channel) 特点:基于指定的传输HASH策略传输数据包。缺省的策略是:(源MAC地址 XOR 目标MAC地址) % slave数量。其他的传输策略可以通过xmit_hash_policy选项指定,此模式提供负载平衡和容错能力。

mode=3(broadcast)(广播策略) 表示所有包从所有网络接口发出,这个不均衡,只有冗余机制,但过于浪费资源。此模式适用于金融行业,因为他们需要高可靠性的网络,不允许出现任何问题。需要和交换机的聚合强制不协商方式配合。 特点:在每个slave接口上传输每个数据包,此模式提供了容错能力。

mode=4(802.3ad)(IEEE 802.3ad 动态链接聚合) 表示支持802.3ad协议,和交换机的动态链路方式配合(需要xmit_hash_policy),标准要求所有设备在聚合操作时,要在同样的速率和双工模式,而且,和除了balance-rr模式外的其它bonding负载均衡模式一样,任何连接都不能使用多于一个接口的带宽。 特点:创建一个聚合组,它们共享同样的速率和双工设定。根据802.3ad规范将多个slave工作在同一个激活的聚合体下。 外出流量的slave选举是基于传输hash策略,该策略可以通过xmit_hash_policy选项从缺省的XOR策略改变到其他策略。需要注意的是,并不是所有的传输策略都是802.3ad适应的,尤其考虑到在802.3ad标准43.2.4章节提及的包乱序问题。不同的实现可能会有不同的适应性。 必要条件: 条件1:ethtool支持获取每个slave的速率和双工设定 条件2:switch(交换机)支持IEEE 802.3ad Dynamic link aggregation 条件3:大多数switch(交换机)需要经过特定配置才能支持802.3ad模式

mode=5(balance-tlb)(适配器传输负载均衡) 是根据每个slave的负载情况选择slave进行发送,接收时使用当前轮到的slave。该模式要求slave接口的网络设备驱动有某种ethtool支持;而且ARP监控不可用。 特点:不需要任何特别的switch(交换机)支持的通道bonding。在每个slave上根据当前的负载(根据速度计算)分配外出流量。如果正在接受数据的slave出故障了,另一个slave接管失败的slave的MAC地址。 必要条件: ethtool支持获取每个slave的速率

mode=6(balance-alb)(适配器适应性负载均衡) 在5的tlb基础上增加了rlb(接收负载均衡receive load balance),不需要任何switch(交换机)的支持。接收负载均衡是通过ARP协商实现的。 必要条件: 条件1:ethtool支持获取每个slave的速率; 条件2:底层驱动支持设置某个设备的硬件地址,从而使得总是有个slave(curr_active_slave)使用bond的硬件地址,同时保证每个bond 中的slave都有一个唯一的硬件地址。如果curr_active_slave出故障,它的硬件地址将会被新选出来的 curr_active_slave接管。 其实mode=6与mode=0的区别:mode=6,先把eth0流量占满,再占eth1,….ethX;而mod=0的话,会发现2个口的流量都很稳定,基本一样的带宽。而mode=6,会发现第一个口流量很高,第2个口只占了小部分流量。

1.2 team模式介绍

链路聚合与双网卡绑定几乎相同,可以实现多网卡绑定主从荣誉,负载均衡,提高网络访问流量。但链路聚合与双网卡绑定技术(bond)不同点就在于,双网卡绑定只能使用两个网卡绑定,而链路聚合最多可将8个网卡汇聚同时做绑定,此聚合模式称之为team,team模式是有CentOS 7 才出现的。 team 模式种类 1、broadcast - 广播容错 2、roundrobin - 平衡轮询 3、activebackup - 主备模式 4、loadbalance - 负载均衡

二. bond设定2.1bond配置——案例 —手工修改命令方式

以下配置经过验证

网卡配置

=================以下为在redhat7.9下配置

有其他未使用的网卡配置需要移除或者 ONBOOT=NO,否则会影响bond网卡启动

注意事项

1.有其他未使用的网卡配置需要移除或者 ONBOOT=NO,否则会影响bond网卡启动,也就是绑定的网卡,需要去掉onboot2. bond好像跟NetworkManager服务有冲突,建议关闭systemctl disable NetworkManagersystemctl stop NetworkManager

第一块网卡

**坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑MASTER,SLAVE   必须大写坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑**# vim /etc/sysconfig/network-scripts/ifcfg-em1DEVICE=em1TYPE=EthernetBOOTPROTO=noneNM_CONTROLLED=noONBOOT=yesMASTER=bond0SLAVE=yes

第二块网卡

# vim /etc/sysconfig/network-scripts/ifcfg-em2DEVICE=em2TYPE=EthernetBOOTPROTO=noneNM_CONTROLLED=noONBOOT=yesMASTER=bond0SLAVE=yes

配置绑定bond0网卡

# vim /etc/sysconfig/network-scripts/ifcfg-bond0DEVICE=bond0TYPE=bondBOOTPROTO=staticNM_CONTROLLED=noONBOOT=yesIPADDR=10.10.1.112NETMASK=255.255.255.0GATEWAY=10.10.1.1DNS1=114.114.114.114DNS2=8.8.8.8

内核加载bond模块

# modprobe bonding# lsmod |grep bondbonding               149864  0

配置链路检测时间

# vim /etc/modprobe.d/bonding.confalias bond0 bondingoptions bonds mode=0 miimon=100写进配置文件, miimon链路检测时间,毫

查看bond状态

# cat /proc/net/bonding/bond0Bonding Mode: load balancing (round-robin)MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: em1MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 34:73:5a:9a:82:64Slave queue ID: 0Slave Interface: em2MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 34:73:5a:9a:82:65Slave queue ID: 0

修改bond模式,并再次生效

**修改BOND模式**[root@mesdb01 ~]# cat /etc/modprobe.d/bonding.confalias bond0 bondingoptions bond0 mode=4 miimon=100**重新加载bond**[root@mesdb01 ~]# modprobe -r bonding**重新启动网卡**systemctl restart network**查看bond0,已经成为802.3ad**[root@mesdb01 ~]# cat /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: IEEE 802.3ad Dynamic link aggregationTransmit Hash Policy: layer2 (0)MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0802.3ad infoLACP rate: slowMin links: 0Aggregator selection policy (ad_select): stableSystem priority: 65535System MAC address: 00:0c:29:a6:46:c0Active Aggregator Info:        Aggregator ID: 1        Number of ports: 1        Actor Key: 9        Partner Key: 1        Partner Mac Address: 00:00:00:00:00:00Slave Interface: ens37MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:c0Slave queue ID: 0Aggregator ID: 1Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu:    system priority: 65535    system mac address: 00:0c:29:a6:46:c0    port key: 9    port priority: 255    port number: 1    port state: 205details partner lacp pdu:    system priority: 65535    system mac address: 00:00:00:00:00:00    oper key: 1    port priority: 255    port number: 1    port state: 3Slave Interface: ens38MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:caSlave queue ID: 0Aggregator ID: 2Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu:    system priority: 65535    system mac address: 00:0c:29:a6:46:c0    port key: 9    port priority: 255    port number: 2    port state: 197details partner lacp pdu:    system priority: 65535    system mac address: 00:00:00:00:00:00    oper key: 1    port priority: 255    port number: 1    port state: 3
2.2bond配置——案例 —nmcli命令方式

以下配置经过验证,资料来源

<;<;

2.2.1 配置网卡配置bond

环境介绍:

ens37 ens38两个网卡,然后配置bond0 ,mode=active stnadby,

IP地址为192.168.0.101/24 GW:192.168.0.1

##################**查看相关网卡**[root@mesdb01 network-scripts]# ip a s2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:b6 brd ff:ff:ff:ff:ff:ff    inet 192.168.0.181/24 brd 192.168.0.255 scope global ens33       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fea6:46b6/64 scope link       valid_lft forever preferred_lft forever3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:ca brd ff:ff:ff:ff:ff:ff[root@mesdb01 network-scripts]# nmcli c sNAME   UUID                                  TYPE      DEVICEens33  fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33ens37  5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38  2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --##################**添加bond0**nmcli connection add con-name bond0 ifname bond0 type bond mode 1或者nmcli connection add con-name bond0 type bond ifname bond0 mode active-backup[root@mesdb01 network-scripts]# nmcli connection add con-name bond0 ifname bond0 type bond mode 1Connection 'bond0' (dbfece7f-7793-43c0-8d2d-6209a8ccd289) successfully added.######**查看一下**[root@mesdb01 network-scripts]# nmcli connectionNAME   UUID                                  TYPE      DEVICEbond0  dbfece7f-7793-43c0-8d2d-6209a8ccd289  bond      bond0ens33  fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33ens37  5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38  2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 network-scripts]# nmcli connection show bond0####################添加ens37 ens38到bond0[root@mesdb01]# nmcli connection add type ethernet slave-type bond con-name bond0-ens37 ifname ens37 master bond0[root@mesdb01]# nmcli connection add type ethernet slave-type bond con-name bond0-ens38 ifname ens38 master bond0[root@mesdb01 network-scripts]# nmcli c sNAME         UUID                                  TYPE      DEVICEbond0        dbfece7f-7793-43c0-8d2d-6209a8ccd289  bond      bond0ens33        fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33bond0-ens37  af11a162-ab49-491b-a327-a22f22c5c8aa  ethernet  ens37bond0-ens38  7a14377c-b17c-46ce-96a9-908c5b6adedc  ethernet  ens38ens37        5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38        2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --####################bond0设置IP地址$ nmcli connection modify bond0 ipv4.addresses "192.168.0.102/24" $ nmcli connection modify bond0 ipv4.gateway "192.168.0.1"$ nmcli connection modify bond0 ipv4.dns "8.8.8.8, 8.8.4.4"$ nmcli connection modify bond0 ipv4.method manual       ##################让修改IP地址生效,需要down再UP[root@mesdb01 network-scripts]# nmcli co down bond0Connection 'bond0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/21)[root@mesdb01 network-scripts]# nmcli co up bond0Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/24)nmcli device disconnected bond0nmcli device connected bond0

2.2.2 修改网卡配置bond

######################**修改bond模式**nmcli connection modify bond0 bond.options "mode=balance-rr"nmcli connection modify bond0 bond.options "mode=802.3ad"nmcli connection modify bond0 bond.options "mode=active-backup"ornmcli connection modify bond0 bond.options "mode=0nmcli connection modify bond0 bond.options "mode=4"nmcli connection modify bond0 bond.options "mode=1"nmcli connection modify bond0 bond.options "mode=active-backup,miimon=1000"#############有以下几种模式[root@mesdb01 network-scripts]# nmcli connection add -helpbond:         [mode balance-rr (0) | active-backup (1) | balance-xor (2) | broadcast (3) |                        802.3ad    (4) | balance-tlb   (5) | balance-alb (6)]                  [primary <ifname>]                  [miimon <num>]                  [downdelay <num>]                  [updelay <num>]                  [arp-interval <num>]                  [arp-ip-target <num>]                  [lacp-rate slow (0) | fast (1)]#######**#####使配置生效**[root@mesdb01 network-scripts]# nmcli co down bond0Connection 'bond0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/21)[root@mesdb01 network-scripts]# nmcli co up bond0Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/24)[root@mesdb01 ~]# cat /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)**Bonding Mode: fault-tolerance (active-backup)**Primary Slave: NoneCurrently Active Slave: ens37MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens37MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:c0Slave queue ID: 0Slave Interface: ens38MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:ca

2.2.3 删除bond网卡

**########### 查看bond**[root@mesdb01 network-scripts]# ip a s2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:b6 brd ff:ff:ff:ff:ff:ff    inet 192.168.0.181/24 brd 192.168.0.255 scope global ens33       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fea6:46b6/64 scope link       valid_lft forever preferred_lft forever3: ens37: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff4: ens38: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff10: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff    inet6 fe80::a0ca:1712:9217:ce68/64 scope link noprefixroute       valid_lft forever preferred_lft forever[root@mesdb01 network-scripts]# nmcli c sNAME              UUID                                  TYPE      DEVICEbond0             0e0f25b5-5009-4aee-a4fa-2c090e59095c  bond      bond0ens33             fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33bond-slave-ens37  bed505ca-7e4b-4f2e-855f-87f35a5f6256  ethernet  ens37bond-slave-ens38  8937f083-805c-40a2-ad65-80409c899fc0  ethernet  ens38ens37             5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38             2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 network-scripts]# cat /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: fault-tolerance (active-backup)Primary Slave: NoneCurrently Active Slave: ens37MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens37MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:c0Slave queue ID: 0Slave Interface: ens38MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:a6:46:caSlave queue ID: 0**####################### bond0 down**[root@mesdb01 network-scripts]# nmcli c down bond0Connection 'bond0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)######################删除bond0[root@mesdb01 network-scripts]# nmcli connection delete bond0Connection 'bond0' (0e0f25b5-5009-4aee-a4fa-2c090e59095c) successfully deleted[root@mesdb01 network-scripts]# ip a s2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:b6 brd ff:ff:ff:ff:ff:ff    inet 192.168.0.181/24 brd 192.168.0.255 scope global ens33       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fea6:46b6/64 scope link       valid_lft forever preferred_lft forever3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:ca brd ff:ff:ff:ff:ff:ff此处已经没有无bond文件[root@mesdb01 network-scripts]# cat /proc/net/bonding/b#####################删除bond相关子网卡[root@mesdb01 network-scripts]# nmcli c sNAME              UUID                                  TYPE      DEVICEens33             fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33bond-slave-ens37  bed505ca-7e4b-4f2e-855f-87f35a5f6256  ethernet  --bond-slave-ens38  8937f083-805c-40a2-ad65-80409c899fc0  ethernet  --ens37             5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38             2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 network-scripts]#[root@mesdb01 network-scripts]#[root@mesdb01 network-scripts]# nmcli connection delete bond-slave-ens37Connection 'bond-slave-ens37' (bed505ca-7e4b-4f2e-855f-87f35a5f6256) successfully deleted.[root@mesdb01 network-scripts]# nmcli connection delete bond-slave-ens38Connection 'bond-slave-ens38' (8937f083-805c-40a2-ad65-80409c899fc0) successfully deleted.[root@mesdb01 network-scripts]# nmcli c sNAME   UUID                                  TYPE      DEVICEens33  fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33ens37  5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38  2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 network-scripts]# nmcli c sNAME   UUID                                  TYPE      DEVICEens33  fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33ens37  5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  --ens38  2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 network-scripts]# nmcli device sDEVICE  TYPE      STATE         CONNECTIONens33   ethernet  connected     ens33ens37   ethernet  disconnected  --ens38   ethernet  disconnected  --lo      loopback  unmanaged     --[root@mesdb01 network-scripts]# ip a s1: 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    inet6 ::1/128 scope host       valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:b6 brd ff:ff:ff:ff:ff:ff    inet 192.168.0.181/24 brd 192.168.0.255 scope global ens33       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fea6:46b6/64 scope link       valid_lft forever preferred_lft forever3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:ca brd ff:ff:ff:ff:ff:ff

2.2.4 附录,其他相关命令

# 查看网络管理状态[root@m01 ~]# nmcli general status					STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    connected  full          enabled  enabled  enabled  enabled [root@m01 ~]# nmcli general hostnamelocalhost.localdomain[root@m01 ~]# nmcli general permissions[root@mesdb01 ~]# ip a s1: 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    inet6 ::1/128 scope host       valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:b6 brd ff:ff:ff:ff:ff:ff    inet 192.168.0.181/24 brd 192.168.0.255 scope global ens33       valid_lft forever preferred_lft forever    inet6 fe80::20c:29ff:fea6:46b6/64 scope link       valid_lft forever preferred_lft forever3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:c0 brd ff:ff:ff:ff:ff:ff    inet6 fe80::6e85:4d62:5fbd:610a/64 scope link noprefixroute       valid_lft forever preferred_lft forever4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:a6:46:ca brd ff:ff:ff:ff:ff:ff    inet6 fe80::7dd1:7025:553e:ec5e/64 scope link noprefixroute       valid_lft forever preferred_lft forever[root@mesdb01 ~]# nmcli device  connect ens37Device 'ens37' successfully activated with '5cbf2502-ea62-4f16-9054-96d8daa13efc'.[root@mesdb01 ~]#[root@mesdb01 ~]# nmcli device statusDEVICE  TYPE      STATE         CONNECTIONens33   ethernet  connected     ens33ens37   ethernet  connected     ens37ens38   ethernet  disconnected  --lo      loopback  unmanaged     --[root@mesdb01 ~]# nmcli c showNAME   UUID                                  TYPE      DEVICEens33  fd1fb7f0-388e-49b5-bf4d-1aa8bd3c2314  ethernet  ens33ens37  5cbf2502-ea62-4f16-9054-96d8daa13efc  ethernet  ens37ens33  01363829-d16c-418c-8a1a-66dee1ec8ad5  ethernet  --ens38  2d85fa2e-ab47-4e6c-83b3-1545c9686551  ethernet  --[root@mesdb01 ~]# nmcli device  connect ens38Device 'ens38' successfully activated with '2d85fa2e-ab47-4e6c-83b3-1545c9686551'.[root@mesdb01 ~]# nmcli device statusDEVICE  TYPE      STATE      CONNECTIONens33   ethernet  connected  ens33ens37   ethernet  connected  ens37ens38   ethernet  connected  ens38lo      loopback  unmanaged  --[root@mesdb01 ~]# nmcli connection up ens33                 ===连接启动[root@mesdb01 ~]#nmcli c reload                              ===重新加载[root@mesdb01 ~]#nmcli c modify ens34 connection.autoconnect yes ===自动来连接[root@mesdb01 ~]#nmcli c delete ens33                         ====删除配置文件

nmcli开始绑定

首先bond模式:bond:         [mode balance-rr (0) | active-backup (1) | balance-xor (2) | broadcast (3) |                        802.3ad    (4) | balance-tlb   (5) | balance-alb (6)]# 1. 先备份原有网络配置文件cp /etc/sysconfig/network-scripts/ifcfg-eno* .# 2. 看一下当前有哪些网卡[root@m01 ~]# nmcli connection show NAME   UUID                                  TYPE      DEVICE ens33  16d2cd29-5a42-4d84-91ba-eef9ac8e212a  ethernet  ens33  ens34  73058591-0684-482a-843f-d58630f02a29  ethernet  ens34  # 3. 先创建一个bond类型的网卡,我们采用bond1nmcli connection add con-name bond0 ifname bond0 type bond mode 1nmcli connection add con-name bond0 type bond ifname bond0 mode active-backup# 4. 向新创建的bond1网卡添加两块实体网卡(就是上面看到的ens37、ens38),ens37作为主网卡nmcli connection add  ifname ens37 type ethernet master bond0nmcli connection add type bond-slave ifname ens37 master bond0nmcli connection add type bond-slave ifname ens38 master bond0# 5. 修改bond6的信息:设置静态ip,地址为172.18.2.12,并且设置开机自启动,网关是172.18.2.254nmcli connection modify bond6 ipv4.method manual connection.autoconnect yes ipv4.addresses 172.18.2.12 ipv4.gateway 172.18.2.254# 6. 启动网卡。这时候我们就绑定成功了nmcli connection up bond6#Configure Bonding Optionsnmcli connection modify bond-bond0 primary ens19## Configure IP Address and DNS Settings$ sudo nmcli connection modify bond-bond0 ipv4.method manual$ sudo nmcli connection modify bond-bond0 ipv4.addresses "192.168.1.10/24" $ sudo nmcli connection modify bond-bond0 ipv4.gateway "192.168.1.101"$ sudo nmcli connection modify bond-bond0 ipv4.dns "8.8.8.8, 8.8.4.4"###nmcli connection up bond-bond0nmcli connection modify Bondconn1 bond.options "mode=active-backup"Note: The modes supported are the default Round Robin (balance-rr), Active Backup (active-backup), XOR (balance-xor), Broadcast (broadcast), 802.3ad (802.3ad), Adaptive transmit load balancing (balance-tlb) and Adaptive load balancing (balance-alb).nmcli connection show "Bondconn1"###Delete the Bond Linksnmcli connection delete bond0-if3Delete the Bond Interfacenmcli connection down "Bondconn1"nmcli connection delete "Bondconn1"

修改绑定模式

nmcli connection modify  ifname bond0 mode active-backupnmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp7s0 master bond0nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname enp8s0 master bond0

官方文档

nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=1000"

标签: #redhat select #centos7teambonding #redhat链路聚合