Linux網絡管理之多網卡綁定

  1、bonding介紹html

  在企業Linux服務器管理裏中,服務器的可靠性、可用性以及I/O速度都很是重要,保持服務器的高可用和安全性是生產環境的重要指標,其中最重要的一點是服務器網絡鏈接的高可用性。一般咱們會把重要的服務器作主備,其目的在於當主服務器宕機,備份服務器立刻接管其主服務器的工做,從而實現服務的連續,不至於服務的停用。還有一種狀況,咱們會給服務器作負載均衡,當一個服務器對外提供服務,接收到用戶請求太多,會致使服務器宕機,這個時候咱們用主備顯得力不從心,怎麼辦呢,這個時候咱們就須要考慮把原來訪問一臺服務器的流量,分別用不少臺服務器來分擔,這樣一來把原來一臺服務器承受的壓力分別用不少臺服務器來承擔。咱們知道一張物理網卡的網絡吞吐量是有限的,當服務器上的網卡吞吐量達到上限,這個時候就算性能再好的服務器咱們訪問它都會感受慢,這時咱們就須要考慮增大網卡的網絡吞吐量。一張網卡不夠用,咱們用兩張,三張,不少張。雖然不少張網卡同時對外提供服務是能夠解決吞吐量的問題,可是新的問題又產生了,用戶怎麼知道咱們其餘網卡上的ip呢?一般狀況咱們的都是以一個ip對外服務,(固然也有多個ip對外服務,一個域名對外服務,後臺多是多個IP),用戶只知道一個ip或者域名,那咱們雖然裝了不少張網卡,但直接使用好像是達不到咱們理想的效果。有沒有一種技術將不少張網卡虛擬成一個大的網卡,就有點相似於LVM磁盤管理同樣,能夠把不少張網卡整合成一張,而後來提升網卡的性能呢?誒,有的,bonding就有這樣的功能。它能夠將多張網卡綁定同一IP地址對外提供服務,可實現高可用或負載均衡。咱們都知道兩張網卡或多張網卡設置同一IP地址是不能夠的,但bonding能夠,它的底層工做原理就是經過虛擬一塊網卡對外提供鏈接,物理網卡的MAC地址都會被修改爲相同的MAC地址。這樣一來就實現了提升網卡的性能的同時也有冗餘的網卡。node

  2、bonding工做模式vim

  bonding的工做模式有七種,其中有三種是最爲經常使用centos

  Mode 0 (balance-rr)輪轉策略:這種模式就是從頭至尾順序的在每個slave接口上發送數據包,它提供了網卡的負載均衡和容錯的能力安全

  mode 1 (active-backup) 活動-備份策略:這種模式只有一個slave被激活,當且僅當活動的slave接口失敗時纔會激活其餘slave,爲了不交換機發生混亂,此時綁定的MAC地址只有一個外部端口上可見bash

  mode 3(broadcast)廣播策略:這種模式在全部的slave接口上傳送全部的報文,提供容錯能力。服務器

  注意:active-backup、balance-tlb 和 balance-alb 模式不須要交換機的任何特殊配置。其餘綁定模式須要配置交換機以便整合連接。如:Cisco 交換機須要在模式 0、2 和 3 中使用 EtherChannel,但在模式4中須要 LACP和EtherChannel網絡

  3、bonding實現 mode 0 並測試負載均衡

  1)查看系統是否加載了bonding模塊less

[root@test-centos7-node1 ~]# lsmod|grep bonding
[root@test-centos7-node1 ~]# 

  說明:若是你的系統執行了lsmod命令 沒有過濾到bonding相關的內容,說明你的系統沒有加載bonding模塊

  2)加載bonding模塊

[root@test-centos7-node1 ~]# lsmod|grep bonding
[root@test-centos7-node1 ~]# modprobe bonding
[root@test-centos7-node1 ~]# lsmod |grep bonding
bonding               145728  0 
[root@test-centos7-node1 ~]# 

  說明:一般狀況下內核版本2.4之後都是默認支持bonding模塊,無需手動編譯

  3)備份原有的網卡配置文件

[root@test-centos7-node1 test]# ls /etc/sysconfig/network-scripts/
ifcfg-ens33  ifdown-ippp    ifdown-sit       ifup-bnep  ifup-plusb   ifup-TeamPort
ifcfg-ens36  ifdown-ipv6    ifdown-Team      ifup-eth   ifup-post    ifup-tunnel
ifcfg-lo     ifdown-isdn    ifdown-TeamPort  ifup-ippp  ifup-ppp     ifup-wireless
ifdown       ifdown-post    ifdown-tunnel    ifup-ipv6  ifup-routes  init.ipv6-global
ifdown-bnep  ifdown-ppp     ifup             ifup-isdn  ifup-sit     network-functions
ifdown-eth   ifdown-routes  ifup-aliases     ifup-plip  ifup-Team    network-functions-ipv6
[root@test-centos7-node1 test]# cp /etc/sysconfig/network-scripts/{ifcfg-ens33,ifcfg-ens33.bak}
[root@test-centos7-node1 test]# cp /etc/sysconfig/network-scripts/{ifcfg-ens36,ifcfg-ens36.bak}
[root@test-centos7-node1 test]# ls /etc/sysconfig/network-scripts/
ifcfg-ens33      ifdown       ifdown-isdn    ifdown-Team      ifup-bnep  ifup-plip    ifup-sit       init.ipv6-global
ifcfg-ens33.bak  ifdown-bnep  ifdown-post    ifdown-TeamPort  ifup-eth   ifup-plusb   ifup-Team      network-functions
ifcfg-ens36      ifdown-eth   ifdown-ppp     ifdown-tunnel    ifup-ippp  ifup-post    ifup-TeamPort  network-functions-ipv6
ifcfg-ens36.bak  ifdown-ippp  ifdown-routes  ifup             ifup-ipv6  ifup-ppp     ifup-tunnel
ifcfg-lo         ifdown-ipv6  ifdown-sit     ifup-aliases     ifup-isdn  ifup-routes  ifup-wireless
[root@test-centos7-node1 test]# 

  4)建立bonding配置文件

[root@test-centos7-node1 test]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
  
DEVICE=bond0
ONBOOT=YES
BOOTPROTO=static
IPADDR=192.168.0.33
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
BONDING_OPTS="miimon=100 mode=0"
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
~                                                                                                                           
"/etc/sysconfig/network-scripts/ifcfg-bond0" [New] 8L, 141C written                                       
[root@test-centos7-node1 test]# 

  說明:band0相對於原來也是一塊網卡,咱們能夠像配置物理網卡同樣配置,但它又區別於物理網卡,它是一張虛擬的網卡,咱們除了配置ip地址信息以外,還須要配置它工做的模式,以及心跳檢測時間,其中miimon 是用來進行鏈路監測的。若是miimon=100,那麼系統每100ms 監測一次鏈路鏈接狀態,若是有一條線路不通就轉入另外一條線路。

  5)修改物理網卡配置文件

[root@test-centos7-node1 test]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[root@test-centos7-node1 test]# cat /etc/sysconfig/network-scripts/ifcfg-ens36
NAME=ens36
DEVICE=ens36
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[root@test-centos7-node1 test]# 

  說明:把原有的配置ip信息去掉,把BOOTPROTO修改爲none,而後新加MASTER=bond0,SLAVE=yes便可

  6)重啓網絡服務並測試

   說明:重啓網絡服務我用的crt會一直卡在哪裏,緣由是咱們從新配置了IP地址。咱們可用crt從新鏈接新配的地址

[root@test-centos7-node1 test]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:f2:82:0c brd ff:ff:ff:ff:ff:ff
3: ens36: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether 00:0c:29:f2:82:0c brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 00:0c:29:f2:82:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.33/24 brd 192.168.0.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fef2:820c/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever
[root@test-centos7-node1 test]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:0c
Slave queue ID: 0

Slave Interface: ens36
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:16
Slave queue ID: 0
[root@test-centos7-node1 test]# 

  說明:可看到兩張物理網卡和bond0的MAC都變成同樣了,何況兩張物理網卡上沒有任何ip地址,bond0上是咱們剛纔配置的ip地址,說明咱們配置的bond0已經可使用了。固然咱們也能夠看/proc/net/bonding/bond0來查看bond的詳細信息,其中能夠看到兩塊物理網卡都從屬bond0,band0的工做模式是load balancing。此模式實現了網卡的負載均衡和容錯,咱們可任意斷開一個物理網卡,其網絡服務不斷開。測試的話可選擇下載一個大文件來測試。

  下載http://192.168.0.99/bigfile 文件測試

  1)使用bond0 兩物理網卡負載均衡來下載

[root@test-centos7-node1 test]# time wget http://192.168.0.99/bigfile
--2020-01-10 10:33:48--  http://192.168.0.99/bigfile
Connecting to 192.168.0.99:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5211422720 (4.9G)
Saving to: ‘bigfile’

100%[============================================================>] 5,211,422,720 57.2MB/s   in 93s    

2020-01-10 10:35:21 (53.6 MB/s) - ‘bigfile’ saved [5211422720/5211422720]


real    1m32.961s
user    0m0.502s
sys     0m21.582s
[root@test-centos7-node1 test]# 

  說:可看到下載一個4.9G的大文件,用bond0下載平均下載速度是53.6MB/S

  2)不使用bond0下載,恢復兩物理網卡,讓其都是用不一樣的IP

[root@test-centos7-node1 ~]# ls /etc/sysconfig/network-scripts/
ifcfg-ens33      ifdown-ippp    ifdown-TeamPort  ifup-isdn    ifup-TeamPort
ifcfg-ens33.bak  ifdown-ipv6    ifdown-tunnel    ifup-plip    ifup-tunnel
ifcfg-ens36      ifdown-isdn    ifup             ifup-plusb   ifup-wireless
ifcfg-ens36.bak  ifdown-post    ifup-aliases     ifup-post    init.ipv6-global
ifcfg-lo         ifdown-ppp     ifup-bnep        ifup-ppp     network-functions
ifdown           ifdown-routes  ifup-eth         ifup-routes  network-functions-ipv6
ifdown-bnep      ifdown-sit     ifup-ippp        ifup-sit
ifdown-eth       ifdown-Team    ifup-ipv6        ifup-Team
[root@test-centos7-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.0.10
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
[root@test-centos7-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens36
NAME=ens36
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.0.20
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
[root@test-centos7-node1 ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f2:82:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global ens33
       valid_lft forever preferred_lft forever
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f2:82:16 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.20/24 brd 192.168.0.255 scope global ens36
       valid_lft forever preferred_lft forever
5: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
[root@test-centos7-node1 ~]# time wget http://192.168.0.99/bigfile
--2020-01-10 10:42:55--  http://192.168.0.99/bigfile
Connecting to 192.168.0.99:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5211422720 (4.9G)
Saving to: ‘bigfile’

100%[=================================================>] 5,211,422,720 63.6MB/s   in 2m 48s 

2020-01-10 10:45:43 (29.6 MB/s) - ‘bigfile’ saved [5211422720/5211422720]


real    2m48.065s
user    0m0.823s
sys     1m6.360s
[root@test-centos7-node1 ~]#

  說明:可看到不使用bond0 下載平均速度是29.6MB/S

  4、bonding實現 mode 1 並測試

  前面的網卡配置文件備份,這裏就不在演示,同上面的同樣,這裏只須要修改bond0 的配置文件,將其mode 0 修改爲mode 1 ,物理網卡的配置文件同上面的同樣

[root@test-centos7-node1 ~]# ip a l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
3: ens36: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.33/24 brd 192.168.0.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::e4e0:29ff:fe24:b5e1/64 scope link 
       valid_lft forever preferred_lft forever
[root@test-centos7-node1 ~]# 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: ens33
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:0c
Slave queue ID: 0

Slave Interface: ens36
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:16
Slave queue ID: 0
[root@test-centos7-node1 ~]# 

  說明:能夠看到,兩個網卡都是啓動的狀態,當前活躍的網卡是ens33

  測試:模擬ens33網線斷了,看看ens36會不會頂替上去

 

   說明:能夠看到ens33出現故障 ens36 當即就頂替上去了,這裏須要注意一點ens33若是恢復了,它不會去頂替ens36 它會一直盯着ens36 直到它ens36死了,它纔會頂替上去。

  5、bonding實現 mode 3

  前期準備同上,只需更改bond0配置文件/etc/sysconfig/network-scripts/ifcfg-bond0,把mode=1  修改爲mode=3,而後重啓服務網絡便可

[root@test-centos7-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=YES
BOOTPROTO=static
IPADDR=192.168.0.33
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
BONDING_OPTS="miimon=100 mode=3"
[root@test-centos7-node1 ~]# systemctl restart network
[root@test-centos7-node1 ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
3: ens36: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether e6:e0:29:24:b5:e1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.33/24 brd 192.168.0.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::e4e0:29ff:fe24:b5e1/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever
[root@test-centos7-node1 ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (broadcast)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:0c
Slave queue ID: 0

Slave Interface: ens36
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:f2:82:16
Slave queue ID: 0
[root@test-centos7-node1 ~]#

  說明:此模式是廣播模式,什麼意思呢,就是訪問bond0 它就會廣播給每一個網卡,而後每張物理網卡收到廣播後都會迴應。

  測試:在192.168.0.99 上ping 192.168.0.33

[root@test html]# ping 192.168.0.33
PING 192.168.0.33 (192.168.0.33) 56(84) bytes of data.
64 bytes from 192.168.0.33: icmp_seq=1 ttl=64 time=1.43 ms
64 bytes from 192.168.0.33: icmp_seq=1 ttl=64 time=1.51 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=2 ttl=64 time=1.38 ms
64 bytes from 192.168.0.33: icmp_seq=2 ttl=64 time=1.45 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=3 ttl=64 time=2.22 ms
64 bytes from 192.168.0.33: icmp_seq=3 ttl=64 time=2.28 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=4 ttl=64 time=0.997 ms
64 bytes from 192.168.0.33: icmp_seq=4 ttl=64 time=1.06 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=5 ttl=64 time=0.618 ms
64 bytes from 192.168.0.33: icmp_seq=5 ttl=64 time=0.764 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=6 ttl=64 time=0.600 ms
64 bytes from 192.168.0.33: icmp_seq=6 ttl=64 time=0.670 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=7 ttl=64 time=0.584 ms
64 bytes from 192.168.0.33: icmp_seq=7 ttl=64 time=0.707 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=8 ttl=64 time=0.581 ms
64 bytes from 192.168.0.33: icmp_seq=8 ttl=64 time=0.651 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=9 ttl=64 time=0.579 ms
64 bytes from 192.168.0.33: icmp_seq=9 ttl=64 time=0.650 ms (DUP!)
64 bytes from 192.168.0.33: icmp_seq=10 ttl=64 time=0.589 ms
64 bytes from 192.168.0.33: icmp_seq=10 ttl=64 time=0.661 ms (DUP!)
^C
--- 192.168.0.33 ping statistics ---
10 packets transmitted, 10 received, +10 duplicates, 0% packet loss, time 9006ms
rtt min/avg/max/mdev = 0.579/0.999/2.284/0.528 ms
[root@test html]#

  說明:0.99向0.33發送一條ping報文,0.99上收到了兩個消息,是否是很奇怪呀,出去一個回來兩個重複的。這就是由於0.33上的兩塊物理網卡收到廣播後都進行了迴應,因此在0.99上會收到2條重複的迴應消息。

  6、卸載bonding 恢復原有物理網卡

  1)恢復配置文件

[root@test-centos7-node1 ~]# cp /etc/sysconfig/network-scripts/{ifcfg-ens33.bak,ifcfg-ens33}
cp: overwrite ‘/etc/sysconfig/network-scripts/ifcfg-ens33’? y
[root@test-centos7-node1 ~]# cp /etc/sysconfig/network-scripts/{ifcfg-ens36.bak,ifcfg-ens36}
cp: overwrite ‘/etc/sysconfig/network-scripts/ifcfg-ens36’? y
[root@test-centos7-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.0.10
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
[root@test-centos7-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens36
NAME=ens36
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.0.20
PREFIX=24
GATEWAY=192.168.0.1
DNS1=192.168.0.1
[root@test-centos7-node1 ~]# mv /etc/sysconfig/network-scripts/{ifcfg-bond0,ifcfg-bond0.bak} 
[root@test-centos7-node1 ~]# ls /etc/sysconfig/network-scripts/
ifcfg-bond0.bak  ifcfg-lo     ifdown-ipv6    ifdown-sit       ifup-aliases  ifup-isdn   ifup-routes    ifup-wireless
ifcfg-ens33      ifdown       ifdown-isdn    ifdown-Team      ifup-bnep     ifup-plip   ifup-sit       init.ipv6-global
ifcfg-ens33.bak  ifdown-bnep  ifdown-post    ifdown-TeamPort  ifup-eth      ifup-plusb  ifup-Team      network-functions
ifcfg-ens36      ifdown-eth   ifdown-ppp     ifdown-tunnel    ifup-ippp     ifup-post   ifup-TeamPort  network-functions-ipv6
ifcfg-ens36.bak  ifdown-ippp  ifdown-routes  ifup             ifup-ipv6     ifup-ppp    ifup-tunnel
[root@test-centos7-node1 ~]# 

  2)卸載bonding 模塊

   3)重啓

  正常狀況下修改了配置文件後重啓網絡服務就能夠了 ,若是要卸載bonding模塊,卸載後重啓網絡服務,物理網卡是啓動不起來的,須要把服務器重啓下便可恢復正常。

  總結:經過上面的實驗能夠看到 bonding技術相似raid技術,它可把多張網卡綁定在一塊兒,不一樣的模式有着不一樣模式的特色。mode 0 輪循負載均衡,可提升網卡的性能的同時也有冗餘網卡。mode1 主備模式,可實現網卡的高可用。mode3 廣播模式,提供容錯能力。其餘模式可參考文檔https://www.kernel.org/doc/Documentation/networking/bonding.txt

相關文章
相關標籤/搜索