- 记一次ct6系列下网卡bonding的配置过程,ct7的bonding配置过程请参考我的另一篇文章CentOS7.x下bonding的配置
环境介绍:
操作系统 | 网卡名称 | 负载模式 | bond地址 |
---|---|---|---|
CentOS6 | em1/em2 | mode1 | 172.16.0.183 |
1.备份网卡配置文件
代码语言:javascript复制[root@localhost ~]$ cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]$ mkdir /tmp/net_bak
[root@localhost network-scripts]$ cp ifcfg-*/tmp/net_bak/
[root@localhost network-scripts]$ ls /tmp/net_bak/
ifcfg-em1 ifcfg-em2 ifcfg-lo
2.加载bonding模块
代码语言:javascript复制modprobe --first-time bonding
3.创建基于bond0接口的配置文件
代码语言:javascript复制vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Bond
BOOTPROTO=none
ONBOOT=yes
IPADDR=172.16.0.183
NETMASK=255.255.255.0
GATEWAY=172.16.0.1
DNS1=114.114.114.114
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"
4.加载bond0接口到内核
代码语言:javascript复制vi /etc/modprobe.d/bonding.conf
修改成如下:
alias bond0 bonding
5.编辑em1、em2的接口文件
代码语言:javascript复制vim /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
MASTER=bond0
SLAVE=yes
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
vim /etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
MASTER=bond0
SLAVE=yes
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
6.关闭和停止NetworkManager服务
代码语言:javascript复制service NetworkManager stop
chkconfig NetworkManager off
注: 如果有装的话关闭它,如果报错说明没有装这个,那就不用管
7.加载模块、重启网络
代码语言:javascript复制modprobe bonding
service network restart
8.查看bond0接口的状态
代码语言:javascript复制cat /proc/net/bonding/bond0
Bonding Mode: fault-tolerance (active-backup) # bond0 接口当前的负载模式是主备模式
Primary Slave: None
Currently Active Slave: em2 # 当前激活的网卡
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: em1 # bond0 组内的网卡
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 84:2b:2b:6a:76:d4
Slave queue ID: 0
Slave Interface: em2 # bond0 组内的网卡
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:2b:2b:6a:76:d5
Slave queue ID: 0
- bonding模式介绍:
- balance-rr (0) –轮询模式,负载均衡(bond默认的模式)
- active-backup (1) –主备模式(常用)
- balance-xor (2) -平衡模式
- broadcast (3) -广播模式
- 802.3ad (4) –动态链接聚合模式
- balance-tlb (5) -适配器传输负载均衡
- balance-alb (6) -适配器适应性负载均衡