29 openEuler管理网络-配置网络绑定

news2024/9/29 17:34:17

文章目录

    • 29 openEuler管理网络-配置网络绑定
      • 29.1 使用nmcli
      • 29.2 使用命令行
        • 29.2.1 检查是否已安装Bonding内核模块
        • 29.2.2 创建频道绑定接口
        • 29.2.3 创建从属接口
        • 29.2.4 激活频道绑定
        • 29.2.5 创建多个绑定

29 openEuler管理网络-配置网络绑定

29.1 使用nmcli

  • 创建名为bond0的绑定,使用示例如下:

    [root@superman-21 ~]# nmcli con add type bond con-name bond0 ifname bond0 mode active-backup
    连接 "bond0" (180f0202-eb66-4530-a0d0-17a4860abfe6) 已成功添加。
    [root@superman-21 ~]#
    
  • 添加从属接口,使用示例如下:

    [root@superman-21 ~]# nmcli con add type bond-slave ifname ens33 master bond0
    连接 "bond-slave-ens33" (530e5a4d-9bf5-4151-97a7-5fc34790f610) 已成功添加。
    [root@superman-21 ~]# 
    

    要添加其他从属接口,重复上一个命令,并在命令中使用新的接口,使用示例如下:

    [root@superman-21 ~]# nmcli con add type bond-slave ifname ens36 master bond0
    连接 "bond-slave-ens36" (006f3c08-ffd7-45ab-8f8b-2b79dbb640da) 已成功添加。
    [root@superman-21 ~]# 
    
  • 要启动绑定,则必须首先启动从属接口,使用示例如下:

    [root@superman-21 ~]# nmcli con up bond-slave-ens33
    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
    [root@superman-21 ~]#
    
    [root@superman-21 ~]# nmcli con up bond-slave-ens36
    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
    [root@superman-21 ~]#
    

    现在可以启动绑定,使用示例如下:

    [root@superman-21 ~]# nmcli con up bond0
    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
    [root@superman-21 ~]#
    
  • bond0状态示例如下:

    [root@superman-21 ~]# cat /proc/net/bonding/bond0 
    Ethernet Channel Bonding Driver: v5.10.0-60.18.0.50.oe2203.x86_64
    
    Bonding Mode: fault-tolerance (active-backup)
    Primary Slave: None
    Currently Active Slave: ens36
    MII Status: up
    MII Polling Interval (ms): 100
    Up Delay (ms): 0
    Down Delay (ms): 0
    Peer Notification Delay (ms): 0
    
    Slave Interface: ens36
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:96:c9:e1
    Slave queue ID: 0
    
    Slave Interface: ens33
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:96:c9:d7
    Slave queue ID: 0
    [root@superman-21 ~]# 
    

29.2 使用命令行

29.2.1 检查是否已安装Bonding内核模块

在系统中默认已加载相应模块。要载入绑定模块,可在root权限下使用如下命令:

[root@compute ~]# modprobe --first-time bonding
[root@compute ~]# 

显示该模块的信息,可在root权限下使用如下命令:

[root@superman-21 ~]# modinfo bonding
filename:       /lib/modules/5.10.0-60.18.0.50.oe2203.x86_64/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, tadavis@lbl.gov and many others
description:    Ethernet Channel Bonding Driver
license:        GPL
alias:          rtnl-link-bond
srcversion:     567375FF5BBB59184962A66
depends:        
retpoline:      Y
intree:         Y
name:           bonding
vermagic:       5.10.0-60.18.0.50.oe2203.x86_64 SMP mod_unload modversions 
sig_id:         PKCS#7
signer:         openEuler kernel signing key
sig_key:        62:1D:B6:4C:CD:82:A9:3E:3B:55:8A:80:AE:2F:A5:A0:40:94:0E:F5
sig_hashalgo:   sha256
signature:      18:23:5D:42:90:11:E1:9D:E1:69:5E:C4:BB:71:33:2D:74:FF:FD:42:
                46:8C:26:6C:02:A5:06:92:58:F4:B1:02:AB:45:01:80:2F:3B:E7:77:
                A1:AD:DF:C5:5D:12:0A:8F:D5:03:10:DE:45:FB:E8:8A:1F:87:86:13:
                16:5F:1D:51:A5:E3:85:B7:9F:6C:94:A1:35:00:13:CB:D5:3A:FF:AA:
                89:E2:03:92:1D:45:00:27:2C:B3:5A:BC:E2:F2:12:12:4E:64:8C:6A:
                A8:D9:C2:93:28:CB:F7:E4:05:4C:43:31:5E:9D:53:C6:D7:B0:78:E1:
                F2:75:86:C6:18:40:21:1A:E3:0F:14:D3:EF:5B:E6:08:49:C0:32:40:
                FF:B4:30:EE:D1:7B:8A:86:F4:C4:EF:65:A9:6B:45:48:75:2A:E5:E9:
                1E:E9:AB:88:96:ED:0B:87:0E:F4:78:5A:BD:A9:90:4D:24:C5:DA:12:
                C0:34:0F:13:43:BD:1F:46:DF:38:AC:0E:5A:CB:40:AD:48:55:4F:40:
                27:F3:8C:D5:6D:3D:66:27:5F:2D:3D:0F:DB:4B:34:08:0E:8E:DF:7D:
                1E:46:C7:35:AB:12:9A:33:BC:61:35:64:29:EB:22:12:F9:BD:D8:FA:
                F0:E8:33:6D:98:E5:52:4A:64:82:57:02:90:5F:B7:3D:87:67:A7:E5:
                9D:8C:F2:36:04:AB:80:CC:D6:72:AE:F9:69:F3:79:D5:50:7C:90:76:
                BC:DA:B3:51:21:B6:30:9D:46:B7:C0:D9:6C:B8:BF:CF:39:3F:8A:36:
                0B:7F:E5:4C:F2:87:FC:8F:0D:D9:11:2B:B7:1C:EE:44:03:67:C1:81:
                81:A5:5A:7C:10:09:C7:37:F2:2D:11:EE:0D:63:4D:AC:55:25:F3:39:
                3E:B5:37:51:AF:9B:EA:FB:0B:66:2D:25:5C:8F:1F:6F:F6:18:E5:D5:
                C1:44:E7:EE:2E:23:CA:D4:F5:B2:FC:A6:94:2D:8F:BA:0F:F6:AD:0A:
                BA:44:AB:DC:28:A1:58:B9:0B:81:CE:59:C5:78:36:8F:DB:2D:07:2A:
                82:24:DA:F1:E1:E7:4C:E1:FD:D8:8D:5F:BE:A9:64:1B:B0:38:86:59:
                09:AD:D6:EC:FF:74:FF:A1:B6:B9:18:84:BA:F8:CD:E5:E5:BD:F1:A6:
                5D:E6:80:2C:64:56:21:52:A0:5A:CC:48:D2:8B:10:08:ED:E2:FF:1F:
                FA:9E:26:60:63:B0:92:19:02:5B:51:A7:38:0D:35:BC:02:60:E6:8F:
                CD:B9:D6:BF:5F:B4:BA:96:34:DC:24:DA:BC:B8:A4:C8:4A:81:58:4C:
                42:89:E7:4C:64:F4:87:D4:A0:C2:0E:59
parm:           max_bonds:Max number of bonded devices (int)
parm:           tx_queues:Max number of transmit queues (default = 16) (int)
parm:           num_grat_arp:Number of peer notifications to send on failover event (alias of num_unsol_na) (int)
parm:           num_unsol_na:Number of peer notifications to send on failover event (alias of num_grat_arp) (int)
parm:           miimon:Link check interval in milliseconds (int)
parm:           updelay:Delay before considering link up, in milliseconds (int)
parm:           downdelay:Delay before considering link down, in milliseconds (int)
parm:           use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int)
parm:           mode:Mode of operation; 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)
parm:           primary:Primary network device to use (charp)
parm:           primary_reselect:Reselect primary slave once it comes up; 0 for always (default), 1 for only if speed of primary is better, 2 for only on active slave failure (charp)
parm:           lacp_rate:LACPDU tx rate to request from 802.3ad partner; 0 for slow, 1 for fast (charp)
parm:           ad_select:802.3ad aggregation selection logic; 0 for stable (default), 1 for bandwidth, 2 for count (charp)
parm:           min_links:Minimum number of available links before turning on carrier (int)
parm:           xmit_hash_policy:balance-alb, balance-tlb, balance-xor, 802.3ad hashing method; 0 for layer 2 (default), 1 for layer 3+4, 2 for layer 2+3, 3 for encap layer 2+3, 4 for encap layer 3+4 (charp)
parm:           arp_interval:arp interval in milliseconds (int)
parm:           arp_ip_target:arp targets in n.n.n.n form (array of charp)
parm:           arp_validate:validate src/dst of ARP probes; 0 for none (default), 1 for active, 2 for backup, 3 for all (charp)
parm:           arp_all_targets:fail on any/all arp targets timeout; 0 for any (default), 1 for all (charp)
parm:           fail_over_mac:For active-backup, do not set all slaves to the same MAC; 0 for none (default), 1 for active, 2 for follow (charp)
parm:           all_slaves_active:Keep all frames received on an interface by setting active flag for all slaves; 0 for never (default), 1 for always. (int)
parm:           resend_igmp:Number of IGMP membership reports to send on link failure (int)
parm:           packets_per_slave:Packets to send per slave in balance-rr mode; 0 for a random slave, 1 packet per slave (default), >1 packets per slave. (int)
parm:           lp_interval:The number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch. The default is 1. (uint)
[root@superman-21 ~]# 

更多命令请在root权限下使用modprobe --help查看。

29.2.2 创建频道绑定接口

要创建绑定接口,可在root权限下通过在 /etc/sysconfig/network-scripts/ 目录中创建名为 ifcfg-bondN 的文件(使用接口号码替换 N,比如 0)。

根据要绑定接口类型的配置文件来编写相应的内容,比如网络接口。接口配置文件示例如下:

[root@superman-21 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 
DEVICE=bond0
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.0.21
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="=mode=active-backup"
[root@superman-21 ~]# 

29.2.3 创建从属接口

创建频道绑定接口后,必须在从属接口的配置文件中添加 MASTER 和 SLAVE 指令。

例如将两个网络接口enp3s0 和 enp4s0 以频道方式绑定,其配置文件示例分别如下:

[root@superman-21 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens33 
TYPE=Ethernet
NAME=bond-slave-ens33
UUID=530e5a4d-9bf5-4151-97a7-5fc34790f610
DEVICE=ens33
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@superman-21 ~]# 
[root@superman-21 ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond-slave-ens36
TYPE=Ethernet
NAME=bond-slave-ens36
UUID=006f3c08-ffd7-45ab-8f8b-2b79dbb640da
DEVICE=ens36
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@superman-21 ~]# 

29.2.4 激活频道绑定

要激活绑定,则需要启动所有从属接口。请在root权限下,运行以下命令:

[root@superman-21 ~]# ifup ens33
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@superman-21 ~]#
[root@superman-21 ~]# ifup ens36
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@superman-21 ~]#

image-20221219190513462 说明:
对于已经处于“up”状态的接口,请首先使用“ifdown ens33 ”命令修改状态为down,其中 ens36 为实际网卡名称。

完成后,启动所有从属接口以便启动绑定(不将其设定为 “down”)。

要让 NetworkManager 感知到系统所做的修改,在每次修改后,请在root权限下,运行以下命令:

[root@superman-21 ~]# nmcli con load /etc/sysconfig/network-scripts/ifcfg-device
[root@superman-21 ~]# 

查看绑定接口的状态,请在root权限下运行以下命令:

[root@superman-21 ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:96:c9:e1 brd ff:ff:ff:ff:ff:ff permaddr 00:0c:29:96:c9:d7
    altname enp2s1
3: ens36: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:96:c9:e1 brd ff:ff:ff:ff:ff:ff
    altname enp2s4
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:96:c9:e1 brd ff:ff:ff:ff:ff:ff
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:bc:bb:cd brd ff:ff:ff:ff:ff:ff
6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:bc:bb:cd brd ff:ff:ff:ff:ff:ff
[root@superman-21 ~]# 

29.2.5 创建多个绑定

系统会为每个绑定创建一个频道绑定接口,包括 BONDING_OPTS 指令。使用这个配置方法可让多个绑定设备使用不同的配置。请按照以下操作创建多个频道绑定接口:

  • 创建多个 ifcfg-bondN 文件,文件中包含 BONDING_OPTS 指令,让网络脚本根据需要创建绑定接口。
  • 创建或编辑要绑定的现有接口配置文件,添加 SLAVE 指令。
  • 使用 MASTER 指令工具在频道绑定接口中分配要绑定的接口,即从属接口。

以下是频道绑定接口配置文件示例:

DEVICE=bondN
NAME=bondN
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.0.21
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="bonding parameters separated by spaces"

在这个示例中,使用绑定接口的号码替换 N。例如要创建两个接口,则需要使用正确的 IP 地址创建两个配置文件 ifcfg-bond0 和 ifcfg-bond1。

image-20230226184930553

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/381251.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vue 组合API

一、组合API是什么&#xff1f;通过创建 Vue 组件&#xff0c;我们可以将界面中重复的部分连同其功能一起提取为可重用的代码段。组合api提供复用性降低耦合性增加可读性下面我们来看下在vue2.0中的一个场景&#xff1a;在2.0里面的**exportdefault{}**通常是由components、pro…

5.排序算法之二:选择排序

选择排序&#xff08;select sort&#xff09;在无序列表中&#xff0c;把无序列表分成有序区&#xff08;刚开始有序区元素个数为0&#xff09;和无序区&#xff08;刚开始无序区元素个数为n&#xff09;&#xff0c;循环n-1趟&#xff0c;每一趟找到最小或最大的那个元素&…

CNC数据采集解决方案(2023杭州乐芯科技)

杭州乐芯科技IOT数据采集平台产品是杭州乐芯科技有限公司为满足工业4.0大型集团工厂推出的新一代数据采集平台级产品&#xff0c;可满足单一平台&#xff08;一个服务器&#xff09;同时采集各类设备&#xff0c;同时兼容各种工业数据采集协议&#xff0c;单服务器压力测试达10…

chainWebpack之optimization.splitChunks的cacheGroups缓存组代码分块实践案

研究了好几天webpack打包&#xff0c;我们项目是vue的高版本&#xff0c;已经没有了webpack.config.js文件了&#xff0c;是直接在vue.config.js里的chainWebpack方法直接配置&#xff0c;这样做法的好处是用户既可以保留webpack的默认配置&#xff0c;又可以通过chainWebpack设…

【Java开发】JUC基础 05:线程通信/协作

1 生产者消费者问题&#x1f4cc; 线程通信应用的场景可以简单地描述为生产者和消费者问题假设仓库中只能存放一件产品&#xff0c;生产者将生产出来的产品放入仓库&#xff0c;消费者将仓库中产品取走消费&#xff1b;如果仓库中没有产品&#xff0c;则生产者将产品放入仓库&a…

Java知识复习(八)Spring基础

1、什么是Spring框架&#xff1f; Spring &#xff1a;是一款开源的轻量级 Java 开发框架&#xff0c;旨在提高开发人员的开发效率以及系统的可维护性 2、Spring、SpringMVC和SpringBoot的区别 Spring主要指Spring Framework&#xff0c;就是指如上图所示的各项功能模块Spr…

【Java 多线程学习】

多线程学习多线程1. 并行与并发2.进程和线程3. *****多线程的实现方式3.1 继承Thread类的方式进行实现3.2 实现Runnable接口方式进行实现3.3 利用Callable和Future接口方式实现3.4 设置获取线程名字4.获得线程对象5.线程休眠6.线程调度[线程的优先级]7.后台线程/守护线程多线程…

Pytest自动化框架-权威教程02-Pytest 使用及调用方法

Pytest 使用及调用方法使用python -m pytest调用pytest2.0版本新增你可以在命令行中通过Python编译器来调用Pytest执行测试:Copypython -m pytest [...]通过python调用会将当前目录也添加到sys.path中,除此之外,这几乎等同于命令行直接调用pytest [...]。可能出现的执行退出cod…

【K8S笔记】Kubernetes 集群架构与组件介绍

K8S 官方文档 https://kubernetes.io/zh/docs/home ##注重关注 概念和任务 板块。 K8S 集群架构 K8S也是运用了分布式集群架构&#xff1a; 管理节点/Master 整个集群的管理&#xff0c;任务协作。工作节点/Node 容器运行、删除。 K8S 组件介绍 管理节点/Master 相关组件 …

JDK1.8 ConcurrentHashMap

数据结构锁sizeCtlconcurrencyLevelForwardingNode、ReservationNode扩容get、put、removehashmap&#xff1a;线程不安全 hashtable&#xff1a;通过synchronized保证线程安全但效率低。强一致性 ConcurrentHashMap&#xff1a;弱一致性 数据结构 ConcurrentHashMap为node数…

前端转golang从小白到实战自学笔记(2023/3/1)

了解&#xff1a;https://www.runoob.com/go/go-concurrent.htmlgolang学习方向区块链研发工程师go服务器>&#xff08;特点&#xff1a;数据处理&#xff0c;处理大并发&#xff09;/游戏软件工程师golang分布式/云计算软件工程师&#xff08;盛大云、cdn、京东&#xff09…

Mybatis主要流程源码分析

分层架构图 主要流程图 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d9uhH9IK-1677658947721)(https://note.youdao.com/yws/public/resource/7f152b4b25320263d411a49583d3f4db/xmlnote/WEBRESOURCE9ea90840088eaeaa4a463bbc3f1912e8/17619)] 主…

索引优化与查询优化

1.哪些维度可以进行数据库调优 索引失效、没有充分利用到索引–》索引建立关联查询太多JOIN (设计缺陷或不得已的需求)–》SQL优化服务器调优及各个参数设置(缓冲、线程数等)–》调整my.cnf数据过多–》分库分表 大方向上完全可以分成 物理查询优化和 逻辑查询优化 两大块 物…

记录一次挖矿病毒kthreaddk和rcu_bj,导致CPU飙高处理

htop命令 存在kthreaddk和rcu_bj进程&#xff0c;cpu飙高 占用一般cpu或者70-80% 1、检查定时任务 查看是否有 # crontab -l 检查root账号是否有异常定时任务 有的话crontab -e 修改定时任务保存 并检查所有的用户有没有定时任务( 注&#xff1a;我的是gitlab git账户被入侵)异…

Nginx 配置详解(二)

序言Nginx的代理功能与负载均衡功能是最常被用到的&#xff0c;描述一些关于代理功能的配置&#xff0c;再说明负载均衡详细。Nginx 代理服务的配置说明1、设置 404 页面导向地址error_page 404 https://www.runnob.com; #错误页 proxy_intercept_errors on; #如果被代理服务…

PowerShell Install Mysql 5.7

MySQL介绍 MySQL 是最流行的关系型数据库管理系统&#xff0c;在 WEB 应用方面 MySQL 是最好的 RDBMS(Relational Database Management System&#xff1a;关系数据库管理系统)应用软件之一。 mysql download Mysql ServerdownloadPowershell 使用使用参数参考 前提条件 开启…

机器学习算法-KNN、决策树

目录1、最近邻算法 KNN1.1 K的选择1.2 案例&#xff1a;鸢尾花2、决策树2.1 决策树介绍2.2 案例&#xff1a;鸢尾花数据2.3 补充1、最近邻算法 KNN 原理&#xff1a;找到K 个与新数据最近的样本&#xff0c;取样本中最多的一个类别作为新数据的类别 要点&#xff1a;距离—是欧…

Three.js上手——搭建Vue3+Three.js项目

上一篇文章 Three.js初试 介绍了一些 Three.js 的基本概念&#xff0c;这一篇主要是介绍一下它的应用。 结合 Vue3 Vite 一起搭建一个项目。 项目初始化 Vite 项目构建 兼容性注意 Vite 需要 Node.js 版本 14.18&#xff0c;16。然而&#xff0c;有些模板需要依赖更高的 Nod…

代码随想录【Day29】|491. 递增子序列、46. 全排列、47. 全排列 II

491. 递增子序列 题目链接 题目描述&#xff1a; 给定一个整型数组, 你的任务是找到所有该数组的递增子序列&#xff0c;递增子序列的长度至少是2。 示例: 输入: [4, 6, 7, 7]输出: [[4, 6], [4, 7], [4, 6, 7], [4, 6, 7, 7], [6, 7], [6, 7, 7], [7,7], [4,7,7]] 说明: …

教务选课排课系统

技术&#xff1a;Java、JSP等摘要&#xff1a;Internet网是目前全球最大的计算机通信网&#xff0c;它遍及全球几乎所有的国家和地区。www系统是一个大型的分布式超媒体信息数据库&#xff0c;它极大的推动了Internet的发展&#xff0c;己经成为Internet中最流行、最主要的信息…