当前位置:   article > 正文

在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作。_服务器双网卡配置lacp

服务器双网卡配置lacp

 连接会话

[root@xixi ~]# nmcli device connect ens224
Device 'ens224' successfully activated with '39bef2c8-fc11-4059-84b9-679bfb13719a'.
[root@xixi ~]# nmcli device connect ens256
Device 'ens256' successfully activated with 'b27b5e56-6c3c-4dc8-9f95-5c0a924fa971'.

[root@xixi ~]# nmcli device status 
DEVICE      TYPE      STATE      CONNECTION 
ens160      ethernet  connected  ens160     
ens224      ethernet  connected  ens224     
ens256      ethernet  connected  ens256     
virbr0      bridge    connected  virbr0     
lo          loopback  unmanaged  --         
virbr0-nic  tun       unmanaged  --        

5: ens256: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.131/24 brd 192.168.225.255 scope global dynamic noprefixroute ens256
       valid_lft 1764sec preferred_lft 1764sec
    inet6 fe80::2b84:62ab:7ee7:12f2/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute ens224
       valid_lft 1758sec preferred_lft 1758sec
    inet6 fe80::81f0:cc46:b792:268a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

创建 team0 设备和 team0 会话

[root@xixi ~]# nmcli connection add type team ifname team0 con-name team0 config '{"runner":{"name": "activebackup"}}'
[root@xixi doc]# cd /usr/share/doc/teamd/example_configs/
[root@xixi example_configs]# ll
total 64
-rw-r--r--. 1 root root 305 Jul 26  2020 activebackup_arp_ping_1.conf
-rw-r--r--. 1 root root 465 Jul 26  2020 activebackup_arp_ping_2.conf
-rw-r--r--. 1 root root 194 Jul 26  2020 activebackup_ethtool_1.conf
-rw-r--r--. 1 root root 212 Jul 26  2020 activebackup_ethtool_2.conf
-rw-r--r--. 1 root root 241 Jul 26  2020 activebackup_ethtool_3.conf
-rw-r--r--. 1 root root 447 Jul 26  2020 activebackup_multi_lw_1.conf
-rw-r--r--. 1 root root 285 Jul 26  2020 activebackup_nsna_ping_1.conf
-rw-r--r--. 1 root root 318 Jul 26  2020 activebackup_tipc.conf
-rw-r--r--. 1 root root  96 Jul 26  2020 broadcast.conf
-rw-r--r--. 1 root root 209 Jul 26  2020 lacp_1.conf
-rw-r--r--. 1 root root  98 Jul 26  2020 loadbalance_1.conf
-rw-r--r--. 1 root root 140 Jul 26  2020 loadbalance_2.conf
-rw-r--r--. 1 root root 183 Jul 26  2020 loadbalance_3.conf
-rw-r--r--. 1 root root  93 Jul 26  2020 random.conf
-rw-r--r--. 1 root root 244 Jul 26  2020 roundrobin_2.conf
-rw-r--r--. 1 root root  97 Jul 26  2020 roundrobin.conf

[root@xixi example_configs]# more activebackup_arp_ping_2.conf 
{
    "device":    "team0",
    "runner":    {"name": "activebackup"},
    "link_watch":    {
        "name": "arp_ping",
        "interval": 100,
        "missed_max": 30,
        "source_host": "192.168.23.2",
        "target_host": "192.168.23.1"
    },
    "ports":    {
        "eth1": {
            "prio": -10,
            "sticky": true
        },

向team0中添加从设备(ens224、256)

[root@xixi ~]# nmcli connection add type team-slave ifname ens224 con-name team0-port1 master team0
Connection 'team0-port1' (3c198f30-556c-407d-8a58-1c7e123b4791) successfully added.
[root@xixi ~]# nmcli connection add type team-slave ifname ens256 con-name team0-port2 master team0
Connection 'team0-port2' (cd8f75d6-e16a-402e-a651-a8d964683282) successfully added.

先激活 team0-port1、team0-port2 从设备,再激活 team0 主设备

[root@xixi ~]# nmcli connection up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)
[root@xixi ~]# nmcli connection up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12)
[root@xixi ~]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)

[root@xixi ~]# nmcli connection show 
NAME         UUID                                  TYPE      DEVICE 
ens160       f667da4f-915c-4c68-ba16-2211ac796d6a  ethernet  ens160 
team0        597c5007-56ea-402b-9768-48ea445f47c4  team      team0  
virbr0       82441c83-895c-46c2-add3-a9b378921af6  bridge    virbr0 
team0-port1  3c198f30-556c-407d-8a58-1c7e123b4791  ethernet  ens224 
team0-port2  cd8f75d6-e16a-402e-a651-a8d964683282  ethernet  ens256 
ens224       39bef2c8-fc11-4059-84b9-679bfb13719a  ethernet  --     
ens256       b27b5e56-6c3c-4dc8-9f95-5c0a924fa971  ethernet  --     

查看 team0 的工作状态

[root@xixi ~]# teamdctl team0 stat
setup:
  runner: activebackup
ports:
  ens224
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  ens256
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: ens224

7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute team0

当从设备 team0-port1 (ens224)断开时,会切换到 ens256

[root@xixi ~]# nmcli connection down team0-port1
Connection 'team0-port1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@xixi ~]# teamdctl team0 stat
setup:
  runner: activebackup
ports:
  ens256
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: ens256

7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute team0

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/293621
推荐阅读
相关标签
  

闽ICP备14008679号