一、bond的工作原理 所谓的bond就是将两块或两块以上网卡绑定同一个IP地址对外提供服务,从而实现负载均衡高可用。当然,直接给两块网卡设置同一IP地址 是不可能的。通过bonding,虚拟一块网卡对外提供连接, 物理网卡的被修改为相同的MAC地址。
二、bond工作模式分类 1)Mode 0 (balance-rr) 轮转(Round-robin)策略:从头到尾顺序的在每一个slave 接口上面发送数据包。本模式提供负载均衡和容错的能力
2)Mode 1 (active-backup) 活动-备份(主备)策略:在绑定中,只有一个slave被激活。 当且仅当活动的slave接口失败时才会激活其他slave。为了 避免交换机发生混乱此时绑定的MAC地址只有一个外部端口上可见
3)Mode 3 (broadcast) 广播策略:在所有的slave接口上传送所有的报文。本模式提供 无容错能力。
三、实现步骤 1、为每个设备生成独立的接口配置文件,关闭NetworkManager服务。 chkconfig --level 3 NetworkManager off
2、添加网卡,配置静态联网(bond0) [root@centos6 network-scripts] # cat ifcfg-bond0 DEVICE=bond0 IPADDR=10.1.249.34 PRFIX=16 GATEWAY=10.1.249.254 DNS1=8.8.8.8 BONDING_OPTS= "miimon=101 mode=0" #如果mode=0则为轮转模式,为1则为主备模式,为3则为广播策略 [root@centos6 network-scripts] # cat ifcfg-eth0 DEVICE=eth0 SLAVE= yes MASTER=bond0 [root@centos6 network-scripts] # cat ifcfg-eth1 DEVICE=eth1 SLAVE= yes MASTER=bond0 [root@centos6 network-scripts] # 3、随意断开一网卡测试,并查看结果 [root@centos6 network-scripts] # !cat cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 102 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7c:55:8d Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7c:55:97 Slave queue ID: 0 [root@centos6 network-scripts] # [root@centos6 ~] # cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: load balancing (round-robin) MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 3 Permanent HW addr: 00:0c:29:7c:55:8d Slave queue ID: 0 Slave Interface: eth1 MII Status: down Speed: Unknown Duplex: Unknown Link Failure Count: 3 Permanent HW addr: 00:0c:29:7c:55:97 Slave queue ID: 0 [root@centos6 ~] # cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (broadcast) MII Status: up MII Polling Interval (ms): 101 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 2 Permanent HW addr: 00:0c:29:7c:55:8d Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 1 Permanent HW addr: 00:0c:29:7c:55:97 Slave queue ID: 0 [root@centos6 ~] #
(责任编辑:最模板) |