bonding配置有下面几种方式,业务可供参考:
1)系统配置文件形式(ifcfg-bond0)
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 #设备名称
BOOTPROTO=static #静态IP
ONBOOT=yes #自动启动
IPADDR=172.16.16.63 #设备绑定的IP
GATEWAY=172.16.23.254 #设备绑定的网关
NETMASK=255.255.248.0 #设备绑定的掩码
TYPE=Ethernet #设备绑定的类型
编辑需要绑定的网卡:
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0 #绑定后的设备名称
SLAVE=yes
TYPE=Ethernet
[root@h63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0 #绑定后的设备名称
SLAVE=yes
TYPE=Ethernet
说明:配置网卡时不要填写IP地址和MAC地址
配置加载模式设置:
[root@h63 ~]# vim /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=6
说明:mode是网卡绑定的模式,此处是模式6
也可以在/etc/modprobe.d/下创建一个文件:
[root@h63 ~]# vim /etc/modprobe.d/bond
alias bond0 bonding
options bond0 miimon=100 mode=6
绑定配置完成,重启网络服务
[root@h63 ~]#systemctl restart network
查看网卡绑定的情况:
[root@h63 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: em1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 78:2b:cb:30:08:03
Slave queue ID: 0
Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 78:2b:cb:30:08:05
Slave queue ID: 0
至此,网卡绑定就完成了。
2)通过sysfs配置bonding
添加bond0和bond0
# echo +bond0 > /sys/class/net/bonding_masters
# echo +bond1 > /sys/class/net/bonding_masters
删除bond0
# echo -bond0 > /sys/class/net/bonding_masters
向bond0添加设备
# echo +eth0 > /sys/class/net/bond0/bonding/slaves
删除设备
# echo -eth0 > /sys/class/net/bond0/bonding/slaves
设置bond0参数
#echo balance-alb > /sys/class/net/bond0/bonding/mode
# echo 1000 > /sys/class/net/bond0/bonding/miimon