快捷搜索:  汽车  科技

red hat部署原理(redhat7网卡bond配置主备模式及LACP模式)

red hat部署原理(redhat7网卡bond配置主备模式及LACP模式)# 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: eno50332208 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eno50332208 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00

项目中经常碰到网卡绑定的场景,下面记录一下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 show NAME 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 show NAME 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: None Currently Active Slave: eno50332208 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eno50332208 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:1c Slave queue ID: 0 Slave Interface: eno33554984 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:12 Slave queue ID: 0 [root@sourcedb network-scripts]#

red hat部署原理(redhat7网卡bond配置主备模式及LACP模式)(1)

ip a查看当前的网卡mac地址已变为一致。

以上完成了主备模式的网卡绑定。如果我们想修改网卡的绑定模式为mode4即lacp模式呢?执行如下命令进行修改;

# nmcli connection modify bond0 bond.options mode=4 # service network restart Restarting 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: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 802.3ad info LACP rate: slow Min links: 0 Aggregator selection policy (ad_select): stable Active Aggregator Info: Aggregator ID: 1 Number of ports: 1 Actor Key: 9 Partner Key: 1 Partner Mac Address: 00:00:00:00:00:00 Slave Interface: eno33554984 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:12 Slave queue ID: 0 Aggregator ID: 1 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 1 port state: 205 details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3 Slave Interface: eno50332208 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:1c Slave queue ID: 0 Aggregator ID: 2 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 2 port state: 197 details 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 aggregation Transmit Hash Policy: layer2 (0) MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 802.3ad info LACP rate: slow Min links: 0 Aggregator selection policy (ad_select): stable Active Aggregator Info: Aggregator ID: 3 Number of ports: 1 Actor Key: 9 Partner Key: 1 Partner Mac Address: 00:00:00:00:00:00 Slave Interface: eno33554984 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:12 Slave queue ID: 0 Aggregator ID: 3 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 1 port state: 205 details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3 Slave Interface: eno50332208 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:25:08:1c Slave queue ID: 0 Aggregator ID: 4 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 port key: 9 port priority: 255 port number: 2 port state: 197 details partner lacp pdu: system priority: 65535 oper key: 1 port priority: 255 port number: 1 port state: 3

猜您喜欢: