通过网口绑定(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
重启服务器
然后查看网卡绑定信息
[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)
(责任编辑:IT) |