Redhat 6.5网卡聚合绑定
linux下网卡bonding配置是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡,在生产场景中是一种常用的技术,常用聚合模式为0,1,6
0(balance-rr)轮循(RR)模式,每张网卡的流量都几乎相等,需要交换机的支持
1(active-backup)冗余模式,平时只有一张网卡工作,当工作网卡出现故障后备份网卡立即被替换上,多用于高可用环境
6(balance-alb)适应性负载,发送的数据包传输第一张网卡如果负载太高,则剩下数据走第二张网卡上
关闭多余服务
service NetworkManager stop chkconfig NetworkManager off chkconfig iptables off chkconfig ip6tables off service iptables stop service ip6tables stop sed -i 's/enforcing/disabled/g' /etc/selinux/config init 6
开机自启模块
modprobe --first-time bonding
创建聚合组
vi /etc/sysconfig/network-scripts/ifcfg-bond0 添加 DEVICE=bond0 ONBOOT=yes NM_CONTROLLED=no IPADDR=172.19.44.150 NETMASK=255.255.255.0 GATEWAY=172.19.44.254 BONDING_OPTS="mode=1 miimon=200 primary=eth1 fail_over_mac=1"
加载bond0接口到内核
vi /etc/modprobe.d/bonding.conf 添加 alias bond0 bonding
修改两块网卡配置
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/networkscripts/ ifcfg-eth0.bkup cp /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/networkscripts/ ifcfg-eth1.bkup
vi /etc/sysconfig/network-scripts/ifcfg-eth0 修改 DEVICE=eth0 TYPE=Ethernet UUID="3db45d28-e63c-401b-906a-ef095de4fc1d" ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no vi /etc/sysconfig/network-scripts/ifcfg-eth1 修改 DEVICE=eth1 TYPE=Ethernet UUID="3db45d28-e63c-401b-906a-ef095de4fc1c" ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no
加载模块、重启网络
modprobe bonding service network restart
确认模块加载
lsmod | grep bonding
测试
netstat -i | grep -v 'lo'
cat /proc/net/bonding/bond0
查看MAC
ifconfig | grep HWaddr
系统自动时自绑定
vi /etc/rc.d/rc.local 增加 ifenslave bond0 eth0 eth1 route add default gw 172.19.44.254
本站所有文章均可随意转载,转载时请保留原文链接及作者。