您的位置:首页 > 运维架构 > Linux

CentOS下双网卡绑定

2016-08-10 09:00 459 查看
像流媒体传输之类的服务器使用单网卡负载过高,可能造成画面卡顿情况,为缓解网络压力,特进行双网卡绑定。
这里我们将2块1GB的网卡进行绑定,使其带宽达到2GB,从而减少网络拥塞。

1.修改/etc/sysconfig/network-scripts/ifcfg-eth0/1配置文档,内容如下:
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes


2.创建一个绑定网络口的配置文档/etc/sysconfig/network-scripts/ifcfg-bond0,内容如下:
DEVICE=bond0
BOOTPROTO=static
IPADDR=52.110.1.2
NETMASK=255.255.255.0
GATEWAY=52.110.1.1
BORADCAST=52.110.1.255
ONBOOT=yes
TYPE=Ethernet


3.修改/etc/modprobe.d/dist.conf,配置绑定模型,配置文件最后加入以下内容:
alias bond0 bonding
options bond0 miimon=100 mode=0
#选项 millmon 是指定隔多长时间来进行链路监测,单位是ms。
#选项 mode 是表示绑定口的工作模式,有0-7共7种模式,常用的有0和1模式,mode=0表示"round-robin"策略,两张卡同时工作在负载均衡状态。mode=1表示"active-backup"策略,两张卡一用一备的备份状态。

4. 修改的是/etc/rc.local,负责在系统启动时将虚拟网卡和两张物理网卡相绑定,增加以下内容:
echo "ifenslave bond0 eth0 eth1" >>/etc/rc.local


5.重启网卡,使其生效
service network restart


注意:将networkmanager服务关闭并设置为开机不启动 以防止干扰相关的操作
service NetworkManager stop
chkconfig NetworkManager off


测试:关闭其中任何一块绑定的网卡,网络不受影响。

附:测试网卡接口速度 ethtool
[root@dahuatech ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: off
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  双网卡 bond