| OS | selinux | firewalld | 網(wǎng)卡 |
|---|---|---|---|
| CentOS7 | 關(guān)閉 | 關(guān)閉 | eth0、eth2 |
https://www.kernel.org/doc/Documentation/networking/bonding.txt

Linux bonding驅(qū)動(dòng)程序提供了一種用于將多個(gè)網(wǎng)絡(luò)接口聚合為單個(gè)邏輯“綁定”接口的方法。 綁定接口的行為取決于模式。 一般來(lái)說(shuō),模式提供熱備用或負(fù)載平衡服務(wù)。此外,可以執(zhí)行鏈路完整性監(jiān)視
共7種(0-6)模式。默認(rèn)是balance-rr(循環(huán))
Mode0(balance-rr)循環(huán)策略:從第一個(gè)可用的從屬設(shè)備到最后一個(gè)從屬設(shè)備按順序傳輸數(shù)據(jù)包。 此模式提供負(fù)載平衡和容錯(cuò)能力。
Mode1(active-backup)主動(dòng)-備份策略:綁定中只有一個(gè)從屬處于活動(dòng)狀態(tài)。當(dāng)且僅當(dāng)活動(dòng)的從站發(fā)生故障時(shí),其他從站才變?yōu)榛顒?dòng)狀態(tài)。綁定的MAC地址在外部?jī)H在一個(gè)端口(網(wǎng)絡(luò)適配器)上可見(jiàn),以避免混淆交換機(jī)。
Mode2(balance-xor):為容錯(cuò)和負(fù)載平衡設(shè)置XOR(異或)策略。 使用此方法,接口會(huì)將傳入請(qǐng)求的MAC地址與其中一個(gè)從NIC的MAC地址進(jìn)行匹配。 一旦建立了鏈接,便從第一個(gè)可用接口開(kāi)始依次發(fā)出傳輸。
Mode3(broadcast)廣播策略:在所有從屬接口上傳輸所有內(nèi)容。 此模式提供容錯(cuò)能力。
Mode4(802.3ad):設(shè)置IEEE802.3ad動(dòng)態(tài)鏈接聚合策略。創(chuàng)建共享相同速度和雙工設(shè)置的聚合組。在活動(dòng)聚合器中的所有從屬上發(fā)送和接收。需要符合802.3ad要求的開(kāi)關(guān)
Mode5(balance-tlb):設(shè)置傳輸負(fù)載平衡(TLB)策略以實(shí)現(xiàn)容錯(cuò)和負(fù)載平衡。 根據(jù)每個(gè)從接口上的當(dāng)前負(fù)載分配傳出流量。 當(dāng)前從站接收到傳入流量。 如果接收方從站發(fā)生故障,則另一個(gè)從站將接管發(fā)生故障的從站的MAC地址。
Mode6(balance-alb):設(shè)置和活動(dòng)負(fù)載平衡(ALB)策略用于容錯(cuò)和負(fù)載平衡。 包括IPV4流量的發(fā)送和接收以及負(fù)載平衡。 通過(guò)ARP協(xié)商實(shí)現(xiàn)接收負(fù)載平衡
查看已添加的eth0、eth2網(wǎng)卡狀態(tài)
[root@CentOS7 ~]# nmcli dev status
DEVICE TYPE STATE CONNECTION
eth0 ethernet disconnected --
eth2 ethernet disconnected --1)使用主備(active-backup)模式添加bonding接口
[root@CentOS7 ~]# nmcli con add type bond con-name bond01 ifname bond0 mode active-backup
Connection 'bond01' (ca0305ce-110c-4411-a48e-5952a2c72716) successfully added.2)添加slave接口
[root@CentOS7 ~]# nmcli con add type bond-slave con-name bond01-slave0 ifname eth0 master bond0
Connection 'bond01-slave0' (5dd5a90c-9a2f-4f1d-8fcc-c7f4b333e3d2) successfully added.
[root@CentOS7 ~]# nmcli con add type bond-slave con-name bond01-slave1 ifname eth2 master bond0
Connection 'bond01-slave1' (a8989d38-cc0b-4a4e-942d-3a2e1eb8f95b) successfully added.3)啟動(dòng)slave接口
[root@CentOS7 ~]# nmcli con up bond01-slave0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@CentOS7 ~]# nmcli con up bond01-slave1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)4)啟動(dòng)bond接口
[root@CentOS7 ~]# nmcli con up bond01
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)5)查看bond狀態(tài)
[root@CentOS7 ~]# 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): 100
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:08:2a:73
Slave queue ID: 0
Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:08:2a:7d
Slave queue ID: 06)測(cè)試
在另一臺(tái)Linux主機(jī)ping本機(jī)的bond0接口ip,然后人為地?cái)嗟鬳th0網(wǎng)卡,看是否會(huì)發(fā)生主備切換
查看本機(jī)bond0接口ip
[root@CentOS7 ~]# ip ad show dev bond0|sed -rn '3s#.* (.*)/24.*#\1#p'
192.168.8.129
[root@CentOS6 ~]# ping 192.168.8.129
PING 192.168.8.129 (192.168.8.129) 56(84) bytes of data.
64 bytes from 192.168.8.129: icmp_seq=1 ttl=64 time=0.600 ms
64 bytes from 192.168.8.129: icmp_seq=2 ttl=64 time=0.712 ms
64 bytes from 192.168.8.129: icmp_seq=3 ttl=64 time=2.20 ms
64 bytes from 192.168.8.129: icmp_seq=4 ttl=64 time=0.986 ms
64 bytes from 192.168.8.129: icmp_seq=7 ttl=64 time=0.432 ms
64 bytes from 192.168.8.129: icmp_seq=8 ttl=64 time=0.700 ms
64 bytes from 192.168.8.129: icmp_seq=9 ttl=64 time=0.571 ms
^C
--- 192.168.8.129 ping statistics ---
9 packets transmitted, 7 received, 22% packet loss, time 8679ms
rtt min/avg/max/mdev = 0.432/0.887/2.209/0.562 ms在另一臺(tái)主機(jī)ping的時(shí)候,斷掉eth0網(wǎng)卡發(fā)現(xiàn)中間丟了兩個(gè)包
[root@CentOS7 ~]# 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: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 4
Permanent HW addr: 00:0c:29:08:2a:73
Slave queue ID: 0
Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0c:29:08:2a:7d
Slave queue ID: 0查看當(dāng)前的active slave是eth2,說(shuō)明主備切換成功
nmcli命令配置完后自動(dòng)生成的配置文件
[root@CentOS7 ~]# cd /etc/sysconfig/network-scripts/
[root@CentOS7 network-scripts]# ls ifcfg-bond*
ifcfg-bond01 ifcfg-bond-slave-eth0 ifcfg-bond-slave-eth2
[root@CentOS7 network-scripts]# cat ifcfg-bond01
BONDING_OPTS=mode=active-backup
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond01
UUID=e5369ad8-2b8b-4cc1-aca2-67562282a637
DEVICE=bond0
ONBOOT=yes
[root@CentOS7 network-scripts]# cat ifcfg-bond-slave-eth0
TYPE=Ethernet
NAME=bond01-slave0
UUID=f6ed385e-e1ae-487d-b36a-43b13ac3f84f
DEVICE=eth0
ONBOOT=yes
MASTER_UUID=e5369ad8-2b8b-4cc1-aca2-67562282a637
MASTER=bond0
SLAVE=yes
bond01-slave1的配置文件和此文件基本一樣broadcast(廣播):數(shù)據(jù)通過(guò)所有端口傳輸
active-backup(主動(dòng)備份):使用一個(gè)端口或鏈接,而將其他端口或鏈接保留為備份
round-robin(輪詢):數(shù)據(jù)依次在所有端口上傳輸
loadbalance(負(fù)載均衡):具有活動(dòng)的Tx負(fù)載平衡和基于BPF的Tx端口選擇器
lacp:實(shí)現(xiàn)802.3ad鏈路聚合控制協(xié)議
1)查看已添加的eth0、eth2網(wǎng)卡狀態(tài)
[root@CentOS7 ~]# nmcli dev status
DEVICE TYPE STATE CONNECTION
eth0 ethernet disconnected --
eth2 ethernet disconnected --2)使用主備(activebackup)模式添加名為team0的網(wǎng)絡(luò)組接口
[root@CentOS7 ~]# nmcli con add type team ifname team0 con-name team0 config '{"runner":{"name":"activebackup"}}'
Connection 'team0' (28b4e208-339f-4eb2-ae0f-6b07621e7685) successfully added.3)添加從屬網(wǎng)絡(luò)到名為team0的網(wǎng)絡(luò)組
[root@CentOS7 ~]# nmcli con add type team-slave ifname eth0 con-name team0-slave0 master team0
Connection 'team0-slave0' (3c1b3008-ebeb-4e2d-9790-30111f1e1271) successfully added.
[root@CentOS7 ~]# nmcli con add type team-slave ifname eth2 con-name team0-slave1 master team04)啟動(dòng)網(wǎng)絡(luò)組和從屬網(wǎng)絡(luò)
[root@CentOS7 ~]# nmcli con up team0
[root@CentOS7 ~]# nmcli con up team0-slave0
[root@CentOS7 ~]# nmcli con up team0-slave1
[root@CentOS7 ~]# nmcli dev status
DEVICE TYPE STATE CONNECTION
team0 team connected team0
eth0 ethernet connected team0-slave0
eth2 ethernet connected team0-slave15)查看網(wǎng)絡(luò)組狀態(tài)
[root@CentOS7 ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
eth0
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eth06)測(cè)試
nmcli命令配置完后自動(dòng)生成的配置文件
[root@CentOS7 ~]# cd /etc/sysconfig/network-scripts/
[root@CentOS7 network-scripts]# ls ifcfg-team0*
[root@CentOS7 network-scripts]# grep -v "^IPV6" ifcfg-team0
TEAM_CONFIG="{\"runner\":{\"name\":\"activebackup\"}}"
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=team0
UUID=28b4e208-339f-4eb2-ae0f-6b07621e7685
DEVICE=team0
ONBOOT=yes
DEVICETYPE=Team
[root@CentOS7 network-scripts]# cat ifcfg-team0-slave0
NAME=team0-slave0
UUID=3c1b3008-ebeb-4e2d-9790-30111f1e1271
DEVICE=eth0
ONBOOT=yes
TEAM_MASTER=team0
DEVICETYPE=TeamPort
[root@CentOS7 network-scripts]# cat ifcfg-team0-slave1
NAME=team0-slave1
DEVICE=eth2
ONBOOT=yes
TEAM_MASTER=team0另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)頁(yè)題目:Linux配置網(wǎng)絡(luò)分組-創(chuàng)新互聯(lián)
當(dāng)前URL:http://chinadenli.net/article2/diijic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、小程序開(kāi)發(fā)、商城網(wǎng)站、面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容