前言:
现在各位老铁们对“centos7 virbr0配置”大体比较注意,我们都需要学习一些“centos7 virbr0配置”的相关知识。那么小编也在网摘上网罗了一些对于“centos7 virbr0配置””的相关资讯,希望你们能喜欢,大家一起来了解一下吧!项目中经常碰到网卡绑定的场景,下面记录一下linux7上通过bond实现网卡的高可用,常见的bond模式如下,我们在项目实施过程总常用到的是mode1(主备)不需要交换机端配置及mode4 (lacp)需要交换机端做响应配置。
bonding的七种工作模式:
bonding技术提供了七种工作模式,在使用的时候需要指定一种,每种有各自的优缺点.balance-rr (mode=0) 默认, 有高可用 (容错) 和负载均衡的功能, 需要交换机的配置,每块网卡轮询发包 (流量分发比较均衡).active-backup (mode=1) 只有高可用 (容错) 功能, 不需要交换机配置, 这种模式只有一块网卡工作, 对外只有一个mac地址。缺点是端口利用率比较低balance-xor (mode=2) 不常用broadcast (mode=3) 不常用802.3ad (mode=4) IEEE 802.3ad 动态链路聚合,需要交换机配置balance-tlb (mode=5) 不常用balance-alb (mode=6) 有高可用 ( 容错 )和负载均衡的功能,不需要交换机配置 (流量分发到每个接口不是特别均衡)
主备方式的绑定步骤:
1、删除原有网卡的profile
### on RHEL7.0 use this:# for connection in $(nmcli -t --fields name,device connection | awk -F ":" '($2 ~ "ens{22,33}") {print $1}') ; do \ nmcli connection delete $connection ; done# nmcli connection reload### on RHEL7.2 use this instead, accounting to a different output syntax of "nmcli":# for connection in $(nmcli -t --fields name,device connection | awk -F ":" '($1 ~ "ens[22,33]") {print $1}') ; do \ nmcli connection delete $connection ; done# nmcli connection reload
或者手动删除,查看当前的连接,本次实验的两块网卡是eno50332208及eno33554984
[root@sourcedb network-scripts]# nmcli connection showNAME UUID TYPE DEVICE virbr0 fc80e2e4-63fa-43ee-9937-016b24bd14c4 bridge virbr0 eno16777736 01698412-b602-401c-bcfc-d7d2d3d83107 802-3-ethernet eno16777736 eno50332208 5b70dc08-5b99-430b-856b-d9706ce17993 802-3-ethernet -- eno33554984 0b978ce7-510a-46ab-8a70-e4567e064683 802-3-ethernet --如果profile不存在可以不执行删除操作。此处执行删除操作# nmcli connection delete eno50332208# nmcli connection delete eno33554984
创建bond(主备模式)
### With a static IP of 192.168.1.10/24 and gateway of 192.168.1.1:# nmcli connection add type bond ifname bond0 con-name bond0 mode active-backup miimon 100 ip4 192.168.1.10/24 gw4 192.168.1.1
添加slave profile,ifname是真实设备名称 con-name可以自己定义
# nmcli connection add type bond-slave ifname eno50332208 con-name eno50332208 master bond0# nmcli connection add type bond-slave ifname eno33554984 con-name eno33554984 master bond0
查看当前连接
# nmcli connection showNAME UUID TYPE DEVICE bond0 f00f0026-49d3-4eee-9b66-9331a007e828 bond bond0 eno50332208 5b70dc08-5b99-430b-856b-d9706ce17993 802-3-ethernet eno50332208 eno33554984 0b978ce7-510a-46ab-8a70-e4567e064683 802-3-ethernet eno33554984
查看绑定状态
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: fault-tolerance (active-backup) #主备模式Primary Slave: NoneCurrently Active Slave: eno50332208MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: eno50332208MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:1cSlave queue ID: 0Slave Interface: eno33554984MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:12Slave queue ID: 0[root@sourcedb network-scripts]#
ip a查看当前的网卡mac地址已变为一致。
以上完成了主备模式的网卡绑定。如果我们想修改网卡的绑定模式为mode4即lacp模式呢?执行如下命令进行修改;
# nmcli connection modify bond0 bond.options mode=4# service network restartRestarting network (via systemctl): [ OK ]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: IEEE 802.3ad Dynamic link aggregation #已经修改为lacp了Transmit 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): stableActive 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: eno33554984MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:12Slave queue ID: 0Aggregator ID: 1Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 1 port state: 205details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3Slave Interface: eno50332208MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:1cSlave queue ID: 0Aggregator ID: 2Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 2 port state: 197details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3
配置lacp模式命令如下,指定关键字mode为802.3ad
# nmcli connection delete bond0 #删除原有配置#nmcli connection delete eno50332208# nmcli connection delete eno33554984# nmcli connection add type bond ifname bond0 con-name bond0 mode 802.3ad miimon 100 ip4 192.168.1.10/24 gw4 192.168.1.1# nmcli connection add type bond-slave ifname eno50332208 con-name eno50332208 master bond0# nmcli connection add type bond-slave ifname eno33554984 con-name eno33554984 master bond0# nmcli connection up bond0 # cat /proc/net/bonding/bond0 Ethernet 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): stableActive Aggregator Info: Aggregator ID: 3 Number of ports: 1 Actor Key: 9 Partner Key: 1 Partner Mac Address: 00:00:00:00:00:00Slave Interface: eno33554984MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:12Slave queue ID: 0Aggregator ID: 3Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 1 port state: 205details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3Slave Interface: eno50332208MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:25:08:1cSlave queue ID: 0Aggregator ID: 4Actor Churn State: monitoringPartner Churn State: monitoringActor Churned Count: 0Partner Churned Count: 0details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 2 port state: 197details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。