3 # vi /etc/moprobe.conf
编辑
/etc/moprobe.conf
文件,加入如下一行内容,以使系统在启动时加载
bonding
模块,对外虚拟网络接口设备为
bond0
加入下列两行
alias bond0 bonding
options bond0 miimon=100 mode=1
说明:
miimon
是用来进行链路监测的。
比如
:miimon=100
,那么系统每
100ms
监测一次链路连接状态,如果有一条线路不通就转入另一条线路;
mode
的值表示工作模式,他共有
0
,
1,2,3
四种模式,常用的为
0,1
两种。
mode=0
表示
load balancing (round-robin)
为负载均衡方式,两块网卡都工作。
mode=1
表示
fault-tolerance (active-backup)
提供冗余功能,工作方式是主备的工作方式
,
也就是说默认情况下只有一块网卡工作
,
另一块做备份
.
bonding
只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路
down
掉了,而交换机本身并没有故障,那么
bonding
会认为链路没有问题而继续使用
4 # vi /etc/rc.d/rc.local
加入两行
ifenslave bond0 eth0 eth1
route add -net 172.31.3.254 netmask 255.255.255.0 bond0 (
如果有对外交换机要加)
到这时已经配置完毕重新启动机器
.
重启会看见以下信息就表示配置成功了
................
Bringing up interface bond0 OK
Bringing up interface eth0 OK
Bringing up interface eth1 OK
................
下面我们讨论以下
mode
分别为
0,1
时的情况
mode=1
工作在主备模式下
,
这时
eth1
作为备份网卡是
no arp
的
[root@rhas-13 network-scripts]# ifconfig
验证网卡的配置信息
bond0 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:18495 errors:0 dropped:0 overruns:0 frame:0
TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1587253 (1.5 Mb) TX bytes:89642 (87.5 Kb)
eth0 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:9572 errors:0 dropped:0 overruns:0 frame:0
TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833514 (813.9 Kb) TX bytes:89642 (87.5 Kb)
Interrupt:11
eth1 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING NOARP SLAVE MULTICAST MTU:1500 Metric:1
RX packets:8923 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:753739 (736.0 Kb) TX bytes:0 (0.0 b)
Interrupt:15
那也就是说在主备模式下
,
当一个网络接口失效时
(
例如主交换机掉电等
),
不回出现网络中断
,
系统会按照
cat /etc/rc.d/rc.local
里指定网卡的顺序工作
,
机器仍能对外服务
,
起到了失效保护的功能
.
通过查看
bond0
的工作状态查询能详细的掌握
bonding
的工作状态
[root@cl303 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v 2.6.0 (January 14, 2004)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 10
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00: 0c :29:63:bc:b7
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00: 0c :29:63:bc:c1
在
mode=0
负载均衡工作模式
,
他能提供两倍的带宽
,
下我们来看一下网卡的配置信息
[root@rhas-13 root]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2817 errors:0 dropped:0 overruns:0 frame:0
TX packets:95 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:226957 (221.6 Kb) TX bytes:15266 (14.9 Kb)
eth0 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:1406 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113967 (111.2 Kb) TX bytes:7268 (7.0 Kb)
Interrupt:11
eth1 Link encap:Ethernet HWaddr 00:0E: 7F :25:D9:8B
inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:1411 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:112990 (110.3 Kb) TX bytes:7998 (7.8 Kb)
Interrupt:15
在这种情况下出现一块网卡失效
,
仅仅会是服务器出口带宽下降
,
也不会影响网络使用
.
[root@cl303 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v 2.6.0 (January 14, 2004)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 1
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00: 0c :29:63:bc:b7
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00: 0c :29:63:bc:c1
|