真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

CentOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解

下文給大家?guī)鞢entOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解,希望能夠給大家在實(shí)際運(yùn)用中帶來一定的幫助,負(fù)載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用創(chuàng)新互聯(lián)在行業(yè)內(nèi)累計(jì)的經(jīng)驗(yàn)來做一個(gè)解答。

專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)連山免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

前幾天剛給大家分享過CentOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP以達(dá)到網(wǎng)絡(luò)負(fù)載均衡以及高可用性。很多人肯定也在想,在CentOS7系統(tǒng)下如何實(shí)現(xiàn)了,那么今天就給大家大家分享一下如何使用CentOS7系統(tǒng)的網(wǎng)絡(luò)組來實(shí)現(xiàn)同樣的效果了。網(wǎng)絡(luò)組是將多個(gè)網(wǎng)卡聚合在一起,從而實(shí)現(xiàn)冗錯(cuò)和提高吞吐量的一種技術(shù)手段,但它不同于舊版中bonding技術(shù),提供更好的性能和擴(kuò)展性,網(wǎng)絡(luò)組由內(nèi)核驅(qū)動(dòng)和teamd守護(hù)進(jìn)程實(shí)現(xiàn)。接下來就給大家展示一下如何實(shí)現(xiàn)。

CentOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解

一、環(huán)境需求

交換機(jī)設(shè)備:兩臺(tái)支持動(dòng)態(tài)鏈聚合功能的交換機(jī)或者一臺(tái)普通交換機(jī)

網(wǎng)卡設(shè)備:兩張網(wǎng)卡

操作操作: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.

三、具體創(chuàng)建步驟

第一步:創(chuàng)建網(wǎng)絡(luò)組文件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]#

我這里創(chuàng)建的是活動(dòng)-備份策略,但我這里額外指定了一個(gè)"hwaddr_policy":"by_active",我也看過很多博主都寫過這個(gè)活動(dòng)備份策略,但從來沒看到有人指出過這個(gè)選項(xiàng),事實(shí)上要想得到雙網(wǎng)卡其中之一故障熱替換,不添加這個(gè)選項(xiàng)是實(shí)現(xiàn)不了的。所以能看到本人博文的同仁們,你們是幸福的(因?yàn)楸救搜芯窟@個(gè)選項(xiàng)花了一天半的時(shí)間才得出這個(gè)結(jié)論)

第二步:給team0配置靜態(tài)IP以及網(wǎng)關(guān),開機(jī)自啟動(dòng)

[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的配置會(huì)在/etc/sysconfig/network-scripts下面生產(chǎn)配置文件ifcfg-team*文件,可以直接查看配置結(jié)果

[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系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解

第三步:為team0創(chuàng)建兩個(gè)端口文件

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

創(chuàng)建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.

創(chuàng)建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]# 

第四步:啟動(dòng)網(wǎng)絡(luò)組 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]# 

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

查看網(wǎng)絡(luò)組的當(dāng)前運(yùn)行狀態(tài)

[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

查看網(wǎng)卡的配置詳情

[root@centos7 Desktop]# ifconfig

eno16777728: flags=4163  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  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  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10

        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  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

        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  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]# 

第六步:隨意禁用其中一塊網(wǎng)卡,測(cè)試網(wǎng)絡(luò)是否具有高可用性

禁用port1(網(wǎng)卡一),查看ping的過程中是否丟包(正常情況下會(huì)丟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(網(wǎng)卡二),繼續(xù)觀察ping的過程(正常情況下會(huì)丟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]# 

禁用網(wǎng)卡一——>禁用網(wǎng)卡二——>關(guān)閉team0連接——>重新啟用team0——>啟用port1——>啟用port2

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

[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]# 

四、注意事項(xiàng)

    啟動(dòng)網(wǎng)絡(luò)組接口不會(huì)自動(dòng)啟動(dòng)網(wǎng)絡(luò)組中的port接口

    啟動(dòng)網(wǎng)絡(luò)組接口中的port接口不會(huì)自動(dòng)啟動(dòng)網(wǎng)絡(luò)組接口

    禁用網(wǎng)絡(luò)組接口會(huì)自動(dòng)禁用網(wǎng)絡(luò)組中的port接口

    沒有port接口的網(wǎng)絡(luò)組接口可以啟動(dòng)靜態(tài)IP連接

    啟用DHCP連接時(shí),沒有port接口的網(wǎng)絡(luò)組會(huì)等待port接口的加入

看了以上關(guān)于CentOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解,如果大家還有什么地方需要了解的可以在創(chuàng)新互聯(lián)行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,創(chuàng)新互聯(lián)技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗(yàn)了。

 

 


本文題目:CentOS6系統(tǒng)下如何實(shí)現(xiàn)雙網(wǎng)卡綁定同一IP詳解
網(wǎng)站網(wǎng)址:http://weahome.cn/article/ghgpih.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部