一、新建bond0虚拟设备
vi /etc/sysconfig/network-scripts/ifcfg-bond0
输入
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.1.0 #网段
NETMASK=255.255.255.0 # 掩码
IPADDR=192.168.1.2 # 指定IP
USERCTL=no
GATEWAY=192.168.1.1 # 网关
TYPE=Ethernet
二、修改所有真实网卡的配置
vi /etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth1
....
内容修改为:
DEVICE=eth0 # 这里填写对应的设备名称
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
三、将bond0加入modprobe
加入
alias bond0 bonding
options bond0 miimon=100 mode=0
四、加入启动命令
加入
ifenslave bond0 eth0 eth1
其中eth0、eth1为真实网卡名称,按照实际情况填写
五、重启系统后即可启动负载均衡式的bond
第三步选项说明:
miimon=100
每100毫秒 (即0.1秒) 检查一次网络
mode=0
共有七种模式,常用的模式是0和1
mode=0 : 负载均衡模式,所有网卡一起使用,峰值=所有网卡带宽的总和,当某个网卡故障,仅降低带宽,不影响其他网卡
mode=1 : 热备模式,即一块网卡运行,其他待命,当运行的网卡故障,其他网卡顶上
mode英文解释:
mode=1(active-backup) Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
mode=2 (balance-xor) XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
mode=3(broadcast) Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=4(802.3ad) IEEE 802.3ad Dynamic link aggregation.
mode=5(balance-tlb) Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave. Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6(balance-alb) Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
查看bond0状态:
cat /proc/net/bonding/bond0
若某个网卡的MII Status=down,表示该网卡无法连接网络
此时应检查:
1、网线是否插好
2、网线是否损坏
3、网卡配置是否正确
4、网卡是否没插好
5、网卡是否损坏
PS: 使用bond时,所有网卡接口都需用网线接上交换机和路由器
阅读(9439) | 评论(0) | 转发(0) |