===========================================================================================================================================================
1、編輯虛擬網絡接口配置文件,指定網卡IP
假設eth1是對外服務的網卡,已經調試好網絡;eth2是與eth0實現故障轉移的網卡。
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-bond0
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth2 (primary_reselect always)
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:ab:ac:8c
Slave Interface: eth2
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:ab:ac:a0
2、由52上直接ping配置機的bond0
[root@click365-test2 ~]# ping -c5 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.248 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.297 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.212 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.291 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=0.278 ms
--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3996ms
rtt min/avg/max/mdev = 0.212/0.265/0.297/0.033 ms
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:ab:ac:8c
此時可以很清楚的看到,eth2已經down掉,bond0僅有eth0工作。
測試機:
[root@click365-test2 ~]# ping -c5 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=2.46 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.336 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=0.278 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=0.262 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=0.307 ms
--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 0.262/0.730/2.468/0.869 ms