linux多网卡绑定

为了增加网络牢固性,linux服务器通过多块网卡来实现网卡冗余或链路聚合、负载均衡的技术。
网卡绑定mode共有七种(0~6) bond0、bond1、bond2、bond3、bond4、bond5、bond6
常用的有三种
mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。
mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。
mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

以mode=6为例,配置方法如下
1.在服务管理中关闭NetworkManager服务并禁用自动启动
#service NetworkManager status #查看状态
#service NetworkManager stop #停止服务
#chkconfig NetworkManager off #禁用服务,下次不自动启动
2.配置网卡
#cd /etc/sysconfig/network-scripts/
#cp ifcfg-eth0 ifcfg-bond0 #创建bond0

bond0配置
#su root #进入root用户下
#vi ifcfg-eth0
DEVICE=bond0
BOOTPROTO=none #不指定IP获取放松
ONBOOT=yes #随系统启动
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
#:wq!

eth1和eth0配置
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
3.修改modprobe相关设定文件,并加载bonding模块:
#vi /etc/modprobe.d/bonding.conf
#追加
alias bond0 bonding
options bonding mode=6 miimon=200 #mode选择6,检测时长200ms
保存退出

4.重启网络service network restart,或者重启系统 init 6
#su root
#ifup bond0 #如果重启后没有启动,激活bond0
#ifconfig #查看是否启动
# ifconfig | grep HWaddr #查看运行状态

5.如果不能上网
# vi /etc/rc.d/rc.local
#追加
ifenslave bond0 eth0 eth1
route add default gw 192.168.0.1 #增加默认网关

修改DNS
修改/etc/resolv.conf文件
# vi /etc/resolv.conf
nameserver 8.8.8.8 #google域名服务器
nameserver 114.144.114.114 #国内域名服务器

#init 6

#常见错误
1.重启系统后ifcfg-bond0 配置出错“e=bond0″–修改为”DEVICE=bond0“

#注意事项
Bonding导致丢包严重问题:
(1)Bonding的mode设置不正确,使用mode=1,负载均衡模式,需要交换机的支持和配置;
(2)采用mode=6来进行负载均衡,不需要交换机的支撑;
Bonding导致网卡重启变化问题:
(1)配置过程中,没有设置具体的MAC地址,导致重启后网卡变化,从而导致bond发生错误;
(2)配置的过程中,一定记得备份文件,在发生错误的时候进行恢复;使用cpxy命令

原创文章,作者:tianwai,如若转载,请注明出处:http://www.178linux.com/19722

(1)
tianwaitianwai
上一篇 2016-06-23 11:13
下一篇 2016-06-24 12:47

相关推荐

  • 文件查找相关:whereis、find和locate

        本文将对find和locate进行详细讲解 命令简介 名称:whereis     功能:定位文件所在的目录     用法:whereis shell命令     注意:whereis是根据环境变量PATH来查找文件的,而PATH通常设置成存放命令的那些路径,如/bin、…

    Linux干货 2016-04-05
  • 进程管理

    Process Manager 工作管理  jobs ctrl+z,& bg,fg nohup 进程,资源管理  查看:pstree,ps,top,vmstat,pmap 查询:pgrep,pidof,fuser,lsof 管理:kill,nice,renice 管理软件or命令  htop glances dstat …

    Linux干货 2016-04-11
  • 由苹果的低级Bug想到的

    2014年2月22日,在这个“这么二”的日子里,苹果公司推送了 iOS 7.0.6(版本号11B651)修复了 SSL 连接验证的一个 bug。官方网页在这里:http://support.apple.com/kb/HT6147,网页中如下描述: package com.ifeve.book; &n…

    Linux干货 2016-08-15
  • PHP5.4的变化关注—What has changed in PHP 5.4.x

    What has changed in PHP 5.4.x Most improvements in PHP 5.4.x have no impact on existing code. There are a few incompatibilities and new features that should be …

    Linux干货 2015-06-17
  • 自制Linux系统

                          自制Linux系统 1、环境准备:         在centos6上添加一块新硬盘,并分区格式化。 &n…

    系统运维 2016-09-21
  • Memcached命令

    Memcache 的命令行用法: 1、启动Memcache 常用参数    memcached 1.4.3      -p <num>      设置端口号(默认不设置为: 11211)      -U <num> &nbsp…

    Linux干货 2015-05-18

评论列表(1条)

  • michael134@qq.com
    michael134@qq.com 2016-06-23 14:04

    我mode4 表示不服