This commit is contained in:
2021-11-14 15:52:46 +08:00
parent 915c231124
commit 1e344dc204
112 changed files with 1039 additions and 1039 deletions

View File

@@ -7,10 +7,10 @@ tags: ["centos", "bond"]
categories: ["network"]
---
# bond 概要
## 什么是 bond
## bond 概要
### 什么是 bond
- 网卡bond是通过把多张网卡绑定为一个逻辑网卡实现本地网卡的冗余带宽扩容和负载均衡。在应用部署中是一种常用的技术。
## bond的模式种类
### bond的模式种类
- Mode=0(balance-rr) 表示负载分担round-robin和交换机的聚合强制不协商的方式配合
- Mode=1(active-backup) 表示主备模式只有一块网卡是active,另外一块是备的standby
- **如果交换机配的是捆绑,将不能正常工作,因为交换机往两块网卡发包,有一半包是丢弃的**
@@ -20,13 +20,13 @@ categories: ["network"]
- Mode=5(balance-tlb) 是根据每个slave的负载情况选择slave进行发送接收时使用当前轮到的slave
- Mode=6(balance-alb) 在5的tlb基础上增加了rlb
# CentOS7 配置 bond
## 环境
## CentOS7 配置 bond
### 环境
- 操作系统 CentOS7.6,禁用 NetworkManager 服务
- 物理网卡 eth0, eth1 绑定到 bond0
- 物理网卡 eth2, eth3 绑定到 bond1
## 网卡 eth0 配置
### 网卡 eth0 配置
- 修改 /etc/sysconfig/network-scripts/ifcfg-eth0
```
TYPE=Ethernet
@@ -38,7 +38,7 @@ categories: ["network"]
MASTER=bond0
```
## 网卡 eth1 配置
### 网卡 eth1 配置
- 修改 /etc/sysconfig/network-scripts/ifcfg-eth1
```
TYPE=Ethernet
@@ -50,7 +50,7 @@ categories: ["network"]
MASTER=bond0
```
## 网卡 eth2 配置
### 网卡 eth2 配置
- 修改 /etc/sysconfig/network-scripts/ifcfg-eth2
```
TYPE=Ethernet
@@ -62,7 +62,7 @@ categories: ["network"]
MASTER=bond1
```
## 网卡 eth3 配置
### 网卡 eth3 配置
- 修改 /etc/sysconfig/network-scripts/ifcfg-eth3
```
TYPE=Ethernet
@@ -74,7 +74,7 @@ categories: ["network"]
MASTER=bond1
```
## 增加网卡 bond0 配置
### 增加网卡 bond0 配置
- 创建 /etc/sysconfig/network-scripts/ifcfg-bond0
```
TYPE=Ethernet
@@ -88,7 +88,7 @@ categories: ["network"]
DNS1=114.114.114.114
```
## 增加网卡 bond1 配置
### 增加网卡 bond1 配置
- 创建 /etc/sysconfig/network-scripts/ifcfg-bond1
```
TYPE=Ethernet
@@ -102,7 +102,7 @@ categories: ["network"]
#DNS1=114.114.114.114
```
## 配置绑定模式
### 配置绑定模式
- 创建 /etc/modprobe.d/bonding.conf加入以下内容
```
alias bond0 bonding
@@ -110,19 +110,19 @@ categories: ["network"]
options bonding miimon=100 mode=1
```
## 载入 bonding 模块,重启 network 服务
### 载入 bonding 模块,重启 network 服务
```bash
modprob bonding
systemctl restart network
```
## 查看网卡绑定状态
### 查看网卡绑定状态
```bash
cat /proc/net/bonding/bond0
cat /proc/net/bonding/bond1
```
# CentOS8 配置 bond
## CentOS8 配置 bond
- 建立 bond 连接配置文件
```bash
nmcli c add con-name bond0 type bond ifname bond0 mode active-backup