中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CentOS6系統下如何實現雙網卡綁定同一IP詳解

發布時間:2020-04-17 15:22:16 來源:億速云 閱讀:678 作者:三月 欄目:網絡安全

下文給大家帶來CentOS6系統下如何實現雙網卡綁定同一IP詳解,希望能夠給大家在實際運用中帶來一定的幫助,負載均衡涉及的東西比較多,理論也不多,網上有很多書籍,今天我們就用億速云在行業內累計的經驗來做一個解答。

前幾天剛給大家分享過CentOS6系統下如何實現雙網卡綁定同一IP以達到網絡負載均衡以及高可用性。很多人肯定也在想,在CentOS7系統下如何實現了,那么今天就給大家大家分享一下如何使用CentOS7系統的網絡組來實現同樣的效果了。網絡組是將多個網卡聚合在一起,從而實現冗錯和提高吞吐量的一種技術手段,但它不同于舊版中bonding技術,提供更好的性能和擴展性,網絡組由內核驅動和teamd守護進程實現。接下來就給大家展示一下如何實現。

CentOS6系統下如何實現雙網卡綁定同一IP詳解

一、環境需求

交換機設備:兩臺支持動態鏈聚合功能的交換機或者一臺普通交換機

網卡設備:兩張網卡

操作操作:Centos7.2


二、模式介紹

broadcast — Simple runner which directs the team device to transmit packets via all ports.

roundrobin — Simple runner which directs the team device to transmits packets in a round-robin fashion.

activebackup — Watches for link changes and selects active port to be used for data transfers.

loadbalance — To do passive load balancing, runner only sets up BPF hash function which will  determine

              port for packet transmit. To do active load balancing, runner moves hashes among available ports trying

              to reach perfect balance.

lacp — Implements 802.3ad LACP protocol. Can use same Tx port selection  possibilities  as  loadbalance

              runner.


三、具體創建步驟

第一步:創建網絡組文件team0

nmcli con add type team con-name team0 config '{"runner":{"name":"activebackup","hwaddr_policy":"by_active"}}'

[root@centos7 network-scripts]# nmcli dev status

DEVICE       TYPE      STATE      CONNECTION         

virbr0       bridge    connected  virbr0             

eno16777728  ethernet  connected  eno16777728        

eno33554960  ethernet  connected  Wired connection 1 

virbr0-nic   tap       connected  virbr0-nic         

lo           loopback  unmanaged  --                 


[root@centos7 network-scripts]# nmcli con add type team con-name team0 config '{"runner":{"name":"activebackup","hwaddr_policy":"by_active"}}'

Connection 'team0' (527769ff-02de-411c-9b26-2725a74cd6e9) successfully added.

[root@centos7 network-scripts]#

我這里創建的是活動-備份策略,但我這里額外指定了一個"hwaddr_policy":"by_active",我也看過很多博主都寫過這個活動備份策略,但從來沒看到有人指出過這個選項,事實上要想得到雙網卡其中之一故障熱替換,不添加這個選項是實現不了的。所以能看到本人博文的同仁們,你們是幸福的(因為本人研究這個選項花了一天半的時間才得出這個結論)


第二步:給team0配置靜態IP以及網關,開機自啟動

[root@centos7 network-scripts]# nmcli con mod team0 connection.autoconnect yes ipv4.method manual ipv4.addresses "10.1.254.254/16" ipv4.gateway "10.1.0.1"

[root@centos7 network-scripts]# cat ifcfg-team0


nmcli的配置會在/etc/sysconfig/network-scripts下面生產配置文件ifcfg-team*文件,可以直接查看配置結果


[root@centos7 network-scripts]# cat ifcfg-team0

DEVICE=team0

TEAM_CONFIG="{\"runner\":{\"name\":\"activebackup\",\"hwaddr_policy\":\"by_active\"}}"

DEVICETYPE=Team

BOOTPROTO=none

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=team0

UUID=c1726372-479f-4ebe-aa12-7e76d702ddd0

ONBOOT=yes

IPADDR=10.1.254.254

PREFIX=16

GATEWAY=10.1.0.1

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

[root@centos7 network-scripts]# 


CentOS6系統下如何實現雙網卡綁定同一IP詳解

第三步:為team0創建兩個端口文件

nmcli con add type team-slave con-name team0-port# ifname eno######## master team0

創建port1文件

[root@centos7 network-scripts]# nmcli con add type team-slave con-name team0-port1 ifname eno16777728 master team0

Connection 'team0-port1' (a88c6e0c-5f0c-4d24-a285-2089f7a6e68b) successfully added.

創建port2文件

[root@centos7 network-scripts]# nmcli con add type team-slave con-name team0-port2 ifname eno33554960 master team0

Connection 'team0-port2' (a103239b-0980-4e63-a465-bc90a8b0958b) successfully added.

[root@centos7 network-scripts]# 


第四步:啟動網絡組 nmcli con up team#

nmcli con up team0——>nmcli con up team0-port1——>nmcli con up team0-port2

[root@centos7 network-scripts]# nmcli con up team0

[root@centos7 network-scripts]# nmcli con up team0

Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)

[root@centos7 network-scripts]# nmcli con up team0-port1

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

[root@centos7 network-scripts]# nmcli con up team0-port2

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

[root@centos7 network-scripts]# 


第五步:查看配置后的最終效果

查看網絡組的當前運行狀態

[root@centos7 Desktop]# teamdctl team0 state

setup:

  runner: activebackup

ports:

  eno16777728

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

  eno33554960

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

runner:

  active port: eno16777728

[root@centos7 Desktop]# ifconfig


查看網卡的配置詳情

[root@centos7 Desktop]# ifconfig

eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        ether 00:0c:29:06:f9:87  txqueuelen 1000  (Ethernet)

        RX packets 1463  bytes 105137 (102.6 KiB)

        RX errors 0  dropped 121  overruns 0  frame 0

        TX packets 79  bytes 5744 (5.6 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


eno33554960: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        ether 00:0c:29:06:f9:91  txqueuelen 1000  (Ethernet)

        RX packets 1510  bytes 108863 (106.3 KiB)

        RX errors 0  dropped 126  overruns 0  frame 0

        TX packets 214  bytes 17571 (17.1 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 16  bytes 1072 (1.0 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 16  bytes 1072 (1.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 10.1.254.254  netmask 255.255.0.0  broadcast 10.1.255.255

        inet6 fe80::20c:29ff:fe06:f991  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:06:f9:87  txqueuelen 0  (Ethernet)

        RX packets 2000  bytes 117274 (114.5 KiB)

        RX errors 0  dropped 247  overruns 0  frame 0

        TX packets 293  bytes 22841 (22.3 KiB)

        TX errors 0  dropped 3 overruns 0  carrier 0  collisions 0


virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:3a:39:12  txqueuelen 0  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


[root@centos7 Desktop]# 


第六步:隨意禁用其中一塊網卡,測試網絡是否具有高可用性

禁用port1(網卡一),查看ping的過程中是否丟包(正常情況下會丟3-4包)

[root@centos7 network-scripts]# nmcli dev dis eno16777728 

Device 'eno16777728' successfully disconnected.

[root@centos7 network-scripts]# teamdctl team0 state

setup:

  runner: activebackup

ports:

  eno33554960

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

runner:

  active port: eno33554960

[root@centos7 network-scripts]# 


啟用port1,禁用port2(網卡二),繼續觀察ping的過程(正常情況下會丟3-4包)

[root@centos7 network-scripts]# nmcli con up team0-port1

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)

[root@centos7 network-scripts]# nmcli dev dis eno33554960 

Device 'eno33554960' successfully disconnected.

[root@centos7 network-scripts]# teamdctl team0 state

setup:

  runner: activebackup

ports:

  eno16777728

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

runner:

  active port: eno16777728

[root@centos7 network-scripts]# 


第七步:如果要想更改用其它策略,直接去修改一下ifcfg-team0文件最為簡單(注意TEAM_CONFIG=...一行的改變)

[root@centos7 network-scripts]# cat ifcfg-team0

DEVICE=team0

TEAM_CONFIG="{\"runner\":{\"name\":\"roundrobin\"}}"

DEVICETYPE=Team

BOOTPROTO=none

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=team0

UUID=c1726372-479f-4ebe-aa12-7e76d702ddd0

ONBOOT=yes

IPADDR=10.1.254.254

PREFIX=16

GATEWAY=10.1.0.1

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

[root@centos7 network-scripts]# 


禁用網卡一——>禁用網卡二——>關閉team0連接——>重新啟用team0——>啟用port1——>啟用port2

查看更改后的效果(這里修改成了roundrobin輪轉策略,需要兩張網卡分別接在兩臺支持動態鏈聚合的交換機上才能體驗得出來輪轉的效果,虛擬機是無法驗證的)

[root@centos7 network-scripts]# teamdctl team0 state

setup:

  runner: roundrobin

ports:

  eno16777728

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

  eno33554960

    link watches:

      link summary: up

      instance[link_watch_0]:

        name: ethtool

        link: up

        down count: 0

[root@centos7 network-scripts]# 


四、注意事項

    啟動網絡組接口不會自動啟動網絡組中的port接口

    啟動網絡組接口中的port接口不會自動啟動網絡組接口

    禁用網絡組接口會自動禁用網絡組中的port接口

    沒有port接口的網絡組接口可以啟動靜態IP連接

    啟用DHCP連接時,沒有port接口的網絡組會等待port接口的加入


看了以上關于CentOS6系統下如何實現雙網卡綁定同一IP詳解,如果大家還有什么地方需要了解的可以在億速云行業資訊里查找自己感興趣的或者找我們的專業技術工程師解答的,億速云技術工程師在行業內擁有十幾年的經驗了。

 

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

阜康市| 河东区| 贡嘎县| 丰原市| 甘谷县| 鄂州市| 南涧| 瑞昌市| 夏河县| 泰和县| 泰来县| 环江| 霍邱县| 兴仁县| 陕西省| 靖州| 新巴尔虎左旗| 涪陵区| 陆良县| 福海县| 石楼县| 福鼎市| 郯城县| 邓州市| 惠安县| 绥芬河市| 天台县| 常州市| 平遥县| 鹤岗市| 庆城县| 大理市| 确山县| 大安市| 巢湖市| 潜江市| 南投县| 卢湾区| 叙永县| 白水县| 景东|