歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Oracle Linux 6.4(BOND)雙網卡綁定實戰—附加說明

Oracle Linux 6.4(BOND)雙網卡綁定實戰—附加說明

日期:2017/2/28 14:00:43   编辑:Linux教程

操作環境
Oracle Linux Server release 6.4
內核
Linux rac1 2.6.39-400.17.1.el6uek.x86_64

[root@RAC-2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0

BOOTPROTO=static

IPADDR=192.168.254.2

NETMASK=255.255.255.0

BROADCAST=192.168.254.1

ONBOOT=yes

TYPE=Ethernet

GATEWAY=192.168.254.1

USERCTL=no

"/etc/sysconfig/network-scripts/ifcfg-bond0" [New] 17L, 163C written

[root@RAC-2 ~]# cd /etc/sysconfig/network-scripts/

[root@RAC-2 network-scripts]# vi ifcfg-eth1

DEVICE=eth1

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes
~
"ifcfg-eth1" 11L, 77C written
[root@RAC-2 network-scripts]# vi ifcfg-eth2
DEVICE=eth2

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes
~
"ifcfg-eth2" 11L, 77C written
[root@RAC-2 network-scripts]# vi /etc/modprobe.d/modprobe.conf

alias bond0 bonding

options bond0 miimon=100 mode=1
~
~
"/etc/modprobe.d/modprobe.conf" [New] 4L, 54C written
說明:
miimon是用來進行鏈路監測的,比如:miimon=100,那麼系統每100ms監測一次鏈路連接狀態,如果有一條線路不通就轉入另一條線路;mode的值表示工作模式,他共有0,1,2,3四種模式,常用的為0,1兩種。
mode=0表示load balancing (round-robin)為負載均衡方式,兩塊網卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主備的工作方式,也就是說默認情況下只有一塊網卡工作,另一塊做備份.


[root@RAC-2 network-scripts]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
ifenslave bond0 eth2 eth1
~
"/etc/rc.d/rc.local" 8L, 246C written
[root@RAC-2 network-scripts]# ifconfig bond0 192.168.254.2 up

#[root@rac4 network-scripts]# ifenslave bond0 eth2 eth1
Illegal operation: The specified slave interface 'eth0' is already a slave


最後重啟服務器:

[root@rac4 ~]# reboot

從下面BOND網卡已經啟動了
[root@RAC-2 ~]# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:E7:1F:5D
inet addr:192.168.254.2 Bcast:192.168.254.1 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee7:1f5d/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:35 errors:0 dropped:15 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2498 (2.4 KiB) TX bytes:1028 (1.0 KiB)

eth1 Link encap:Ethernet HWaddr 08:00:27:E7:1F:5D
inet addr:192.168.254.2 Bcast:192.168.254.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:12 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6411 (6.2 KiB) TX bytes:288 (288.0 b)

eth2 Link encap:Ethernet HWaddr 08:00:27:99:BE:CC
inet addr:192.168.254.2 Bcast:192.168.254.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:73 errors:0 dropped:62 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4935 (4.8 KiB) TX bytes:740 (740.0 b)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)

下面看當前活動網卡ech1,狀態是啟動
[root@RAC-2 ~]# 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: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:e7:1f:5d
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 08:00:27:99:be:cc
Slave queue ID: 0

七種bond模式說明

第一種模式:mod=0 ,即:(balance-rr) Round-robin policy(平衡掄循環策略)

特點:傳輸數據包順序是依次傳輸(即:第1個包走eth0,下一個包就走eth1….一直循環下去,直到最後一個傳輸完畢),此模式提供負載平衡和容錯能力;但是我們知道如果一個連接或者會話的數據包從不同的接口發出的話,中途再經過不同的鏈路,在客戶端很有可能會出現數據包無序到達的問題,而無序到達的數據包需要重新要求被發送,這樣網絡的吞吐量就會下降

第二種模式:mod=1,即: (active-backup) Active-backup policy(主-備份策略)

特點:只有一個設備處於活動狀態,當一個宕掉另一個馬上由備份轉換為主設備。mac地址是外部可見得,從外面看來,bond的MAC地址是唯一的,以避免switch(交換機)發生混亂。此模式只提供了容錯能力;由此可見此算法的優點是可以提供高網絡連接的可用性,但是它的資源利用率較低,只有一個接口處於工作狀態,在有 N 個網絡接口的情況下,資源利用率為1/N

第三種模式:mod=2,即:(balance-xor) XOR policy(平衡策略)

特點:基於指定的傳輸HASH策略傳輸數據包。缺省的策略是:(源MAC地址 XOR 目標MAC地址) % slave數量。其他的傳輸策略可以通過xmit_hash_policy選項指定,此模式提供負載平衡和容錯能力

第四種模式:mod=3,即:broadcast(廣播策略)

特點:在每個slave接口上傳輸每個數據包,此模式提供了容錯能力

第五種模式:mod=4,即:(802.3ad) IEEE 802.3adDynamic link aggregation(IEEE 802.3ad 動態鏈接聚合)

特點:創建一個聚合組,它們共享同樣的速率和雙工設定。根據802.3ad規范將多個slave工作在同一個激活的聚合體下。

外出流量的slave選舉是基於傳輸hash策略,該策略可以通過xmit_hash_policy選項從缺省的XOR策略改變到其他策略。需要注意的是,並不是所有的傳輸策略都是802.3ad適應的,尤其考慮到在802.3ad標准43.2.4章節提及的包亂序問題。不同的實現可能會有不同的適應性。

必要條件:

條件1:ethtool支持獲取每個slave的速率和雙工設定

條件2:switch(交換機)支持IEEE 802.3ad Dynamic link aggregation

條件3:大多數switch(交換機)需要經過特定配置才能支持802.3ad模式

第六種模式:mod=5,即:(balance-tlb) Adaptive transmit load balancing(適配器傳輸負載均衡)

特點:不需要任何特別的switch(交換機)支持的通道bonding。在每個slave上根據當前的負載(根據速度計算)分配外出流量。如果正在接受數據的slave出故障了,另一個slave接管失敗的slave的MAC地址。

該模式的必要條件:ethtool支持獲取每個slave的速率

第七種模式:mod=6,即:(balance-alb) Adaptive load balancing(適配器適應性負載均衡)

特點:該模式包含了balance-tlb模式,同時加上針對IPV4流量的接收負載均衡(receive load balance, rlb),而且不需要任何switch(交換機)的支持。接收負載均衡是通過ARP協商實現的。bonding驅動截獲本機發送的ARP應答,並把源硬件地址改寫為bond中某個slave的唯一硬件地址,從而使得不同的對端使用不同的硬件地址進行通信。

Copyright © Linux教程網 All Rights Reserved