Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9247288
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: 系统运维

2016-09-29 16:12:18

Centos6.5多网卡绑定
2014-05-06 17:04:02   来源:   评论: 点击:2001




通过网口绑定(bond)技术,可以很容易实现网口冗余,负载均衡,从而达到高可用负载均衡的目的。[root@localhost ~] cat etc issueCentOS release 6 5 (Final)Kernel r on an m[root@localhost ~]
通过网口绑定(bond)技术,可以很容易实现网口冗余,负载均衡,从而达到高可用负载均衡的目的。

[root@localhost ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

[root@localhost ~]# echo "alias netdev-bond0 bonding" >/etc/modprobe.d/bonding.conf

网卡绑定前需要执行这个命令,以此来添加服务器启动时加载的模块。

修改新建网卡绑定bond0配置文件


[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
USERCTL=no
PEERDNS=yes
IPV6INIT=no
IPADDR=112.25.xx.xx
NETMASK=255.255.255.192
BROADCAST=112.25.xx.xx
GATEWAY=112.25.xx.xx
BONDING_OPTS="miimon=80 mode=6"

miimon 是链路监测的时间间隔单位是毫秒,miimon=80的意思就是每80ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路。

mode=0 表示负载均衡方式,两块网卡都工作,需要作支持

mode=1 表示冗余方式,网卡只有一个工作,一个出问题启用另外的

mode=6 表示负载均衡方式,两块网卡都工作,不需要交换机作支持

.

我这里做的是四个网卡的绑定,服务器是dell R720,其网卡默认名称为em1--em4,网卡绑定时候,四个网卡的配置基本相似,master需要制定为bond0,四个网卡均为slave
DEVICE=em1
ONBOOT=yes
TYPE=Ethernet
HWADDR=00:0c:29:9c:95:a8      -----一定要加
BOOTPROTO=static
USERCTL=no
MASTER=bond0
SLAVE=yes

.


加载中...


开机启动脚本

在 /etc/rc.d/rc.local里添加如下内容:
  1. ifenslave bond0 eth0 eth1  
[plain] view plain copy
 在CODE上查看代码片派生到我的代码片



service networkmanager stop                      必须关闭,否则重启网络后,无法通信,并且不报错。            
chkconfig NetworkManager off

重启服务器

然后查看网卡绑定信息
cat /proc/net/bonding/bond0

.


.


[root@localhost ~]# ifconfig
bond0 Link encap:Ethernet HWaddr F8:BC:12:38:BF:04
inet addr:112.25.xx.17 Bcast:112.25.xx.63 Mask:255.255.255.192
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:198948 errors:0 dropped:0 overruns:0 frame:0
TX packets:374418 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20792024 (19.8 MiB) TX bytes:29577760 (28.2 MiB)


em1 Link encap:Ethernet HWaddr F8:BC:12:38:BF:04
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:36838 errors:0 dropped:0 overruns:0 frame:0
TX packets:123885 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3250190 (3.0 MiB) TX bytes:12842300 (12.2 MiB)
Interrupt:35


em2 Link encap:Ethernet HWaddr F8:BC:12:38:BF:05
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:88178 errors:0 dropped:0 overruns:0 frame:0
TX packets:87303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11017650 (10.5 MiB) TX bytes:6243968 (5.9 MiB)
Interrupt:38


em3 Link encap:Ethernet HWaddr F8:BC:12:38:BF:06
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:37044 errors:0 dropped:0 overruns:0 frame:0
TX packets:81803 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3274966 (3.1 MiB) TX bytes:5272322 (5.0 MiB)
Interrupt:34


em4 Link encap:Ethernet HWaddr F8:BC:12:38:BF:07
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:36888 errors:0 dropped:0 overruns:0 frame:0
TX packets:81427 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3249218 (3.0 MiB) TX bytes:5219170 (4.9 MiB)
Interrupt:36


lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:99 (99.0 b) TX bytes:99 (99.0 b)

阅读(893) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~