kubernetes网络(三)之bird的路由反射器的使用

一、摘要

上一篇文章中我们用 bird 程序实现了三台服务器之间的BGP full mesh。本文我们将实验把full mesh方式改为RR 路由反射器方式 ,让宿主的BIRD相互学习到对方的容器网段,从而达到容器网段能相互通信的目的。

二、bird 实验

bird简介

  • BIRD 实际上是 BIRD Internet Routing Daemon 的缩写,是一款可运行在 Linux 和其他类 Unix 系统上的路由软件,它实现了多种路由协议,比如 BGP、OSPF、RIP 等。

brid路由反射器的学习

我们直接翻译计算机网络最权威的文档RFC的方式来学习。找到rfc4456中关于路由反射器的描述。

The basic idea of route reflection is very simple. Let us consider the simple example depicted in Figure 1 below.

路由反射的基本思想非常简单。让我们考虑下面图11所示的简单示例。

+-------+        +-------+|       |  IBGP  |       || RTR-A |--------| RTR-B ||       |        |       |+-------+        +-------+\            /IBGP \   ASX    / IBGP\        /+-------+|       || RTR-C ||       |+-------+Figure 1: Full-Mesh IBGP

In ASX, there are three IBGP speakers (routers RTR-A, RTR-B, and RTR-C). With the existing BGP model, if RTR-A receives an external route and it is selected as the best path it must advertise the external route to both RTR-B and RTR-C. RTR-B and RTR-C (as IBGP speakers) will not re-advertise these IBGP learned routes to other IBGP speakers.

在自治域ASX中,有3个IBGP speekers(路由器RTR-A、RTR-B和RTR-C)。在现有的BGP模型下,如果RTR-A收到一条外部路由并被选为最佳路径,则必须同时向RTR-B和RTR-C发布这条外部路由。RTR-B和RTR-C(作为IBGP speaker)不会将学到的路由重新发布给其他IBGP speaker。

来我翻译翻译,这句话说出了BGP协议的2个重要规则:

  • 从EBGP学习到的路由,必须发布给其余的IBGP speaker。如上图,RTR-A必须同时向RTR-B和RTR-C发布这条外部路由。

  • 从IBGP学习到的路由,不能再重新发布给其余IBGP speaker。如上图,RTR-B不会将从RTR-A学到的路由发布给RTR-C。

If this rule is relaxed and RTR-C is allowed to advertise IBGP learned routes to IBGP peers, then it could re-advertise (or reflect) the IBGP routes learned from RTR-A to RTR-B and vice versa. This would eliminate the need for the IBGP session between RTR-A and RTR-B as shown in Figure 2 below.

如果放宽此规则,允许RTR-C向IBGP对等体发布学到的IBGP路由,即RTR-C可以向RTR-B重新发布从RTR-A学到的IBGP路由(这种重新发布方式我们也可称为reflect反射),反之亦然。这将RTR-A和RTR-B之间就无需建立IBGP会话了。

                  +-------+        +-------+|       |        |       || RTR-A |        | RTR-B ||       |        |       |+-------+        +-------+\            /IBGP \   ASX    / IBGP\        /+-------+|       || RTR-C ||       |+-------+Figure 2: Route Reflection IBGP

The route reflection scheme is based upon this basic principle.

路由反射方案就是基于这个基本原理实现的。

路由反射器中的概念或术语

We use the term route reflection to describe the operation of a BGP speaker advertising an IBGP learned route to another IBGP peer. Such a BGP speaker is said to be a “route reflector” (RR), and such a route is said to be a reflected route.

我们使用“路由反射”一词来描述BGP speaker将IBGP学到的路由通告给另一个IBGP对等体的操作。这样的BGP speaker被称为路由反射器RR (route reflector),这样的路由被称为反射路由

The internal peers of an RR are divided into two groups:

RR的内部对等体分为两类:

1). Client peers

2). Non-Client peers

An RR reflects routes between these groups, and may reflect routes among client peers. An RR along with its client peers form a cluster. The Non-Client peer must be fully meshed but the Client peers need not be fully meshed. Figure 3 depicts a simple example outlining the basic RR components using the terminology noted above.

一个RR是在group组内部的client peer 之间的反射路由。RR与其client peer客户端对等体组成集群clusternon-client非客户端对等体必须full mesh(全互联),但clent peer客户端对等体不必full mesh。图3描述了一个使用上述术语概述基本RR组件的简单示例。

                 / - - - - - - - - - - - - -  -|           Cluster           |+-------+        +-------+| |       |        |       |  || RTR-A |        | RTR-B || |Client |        |Client |  |+-------+        +-------+|       \           /         |IBGP  \         / IBGP|         \       /           |+-------+|         |       |           || RTR-C ||         |  RR   |           |+-------+|           /   \             |- - - - - /- - -\- - - - - - /IBGP  /       \ IBGP+-------+         +-------+| RTR-D |  IBGP   | RTR-E ||  Non- |---------|  Non- ||Client |         |Client |+-------+         +-------+Figure 3: RR Components

总结

  1. BGP协议默认的规则: 从IBGP学习到的路由,不能再重新发布给其余IBGP speaker,而RR路由反射器是打破了这个规则,所以才被称为路由反射器。
  2. 使用RR路由反射器后,bgp speaker 不需要full mesh全互联,只需要client 与 RR 建立BGP peer即可.(这是RR的最最主要的作用)
  3. RR 与 Non-client, non-client 与 non-client 之间还是必须全互联。(如上图所示,RR 不会 把RTR-D从外部学的路由的反射给RTR-E,所以要求RTR-D与RTR-E之前需要相互建立bgp peer关系)。

实验目标

  • 学习使用bird实现 BGP 路由反射器
  • 三台宿主的各个容器网段能相互通信

实验环境

系统版本bird版本宿主IP容器网段宿主简称
ubuntu16.04BIRD 1.5.010.226.11.27192.168.227.0/24宿主A
ubuntu16.04BIRD 1.5.010.226.11.22192.168.222.0/24宿主B
ubuntu16.04BIRD 1.5.010.226.11.21192.168.221.0/24宿主C

实验拓扑

三台宿主在同一网段内,每个宿主各自下挂一个容器网段。下面实现10.226.11.27作为RR,10.226.11.21与10.226.11.21作为RR client,从而完成三台宿主上的bird相互学习路由,最终目的是实现各个容器网段能相互通信。 特别说明:10.226.11.21 与 10.226.11.22 之间不需要建立BGP peer关系。
在这里插入图片描述

创建模拟的容器网段

我们知道容器是通过linux 的 namespace 机制实现的一个隔离空间, 这里我们同样借助 namespace 机制 实现一个隔离空间,并为隔离出的命名空间配置网络,模拟一个宿主"挂了"一个容器网段。

  • 宿主10.226.11.22上创建模拟容器网段
# 创建命名空间 netns1
ip netns add netns1
# 创建 veth peer
ip link add veth1 type veth peer name veth2
# 将 veth1 放入 netns1
ip link set veth1 netns netns1
# 查看 veth
ip link show | grep veth
# 为 netns1 中的
ip netns exec netns1 ifconfig veth1 192.168.222.102/24 up
# 为 netns1 指定默认网关,网关是宿主1的网络协议栈
ip netns exec netns1 route add -net 0.0.0.0/0 gw 192.168.222.101
# 为宿主中的 veth2 配置IP地址,这样就实现了宿主与netns1 通过 veth2 与 veth1 的互联
ifconfig veth2 192.168.222.101/24 up
  • 宿主10.226.11.21上创建模拟容器网段
ip netns add netns1
ip link add veth1 type veth peer name veth2
ip link set veth1 netns netns1
ip link show | grep veth
ip netns exec netns1 ifconfig veth1 192.168.221.102/24 up
ip netns exec netns1 route add -net 0.0.0.0/0 gw 192.168.221.101
ifconfig veth2 192.168.221.101/24 up
  • 宿主10.226.11.27上创建模拟容器网段
ip netns add netns1
ip link add veth1 type veth peer name veth2
ip link set veth1 netns netns1
ip link show | grep veth
ip netns exec netns1 ifconfig veth1 192.168.227.102/24 up
ip netns exec netns1 route add -net 0.0.0.0/0 gw 192.168.227.101
ifconfig veth2 192.168.227.101/24 up

bird的安装

  • bird程序的安装
apt-get update
apt-get install bird
/etc/init.d/bird start
  • 检查是否安装成功
/etc/init.d/bird status
birdc show status

输出如下显示表示安装正常

root@10_226_11_21:/etc/bird# birdc show status
BIRD 1.5.0 ready.
BIRD 1.5.0
Router ID is 10.226.11.21
Current server time is 2024-09-23 15:03:28
Last reboot on 2024-09-22 20:22:36
Last reconfiguration on 2024-09-23 13:01:00
Daemon is up and running

BGP RR模式的实现

宿主A作为RR角色

RR 需要与所有client 建立BGP peer关系,它的/etc/bird/bird.conf配置如下

# This is a minimal configuration file, which allows the bird daemon to start
# but will not cause anything else to happen.
#
# Please refer to the documentation in the bird-doc package or BIRD User's
# Guide on http://bird.network.cz/ for more information on configuring BIRD and
# adding routing protocols.#log syslog all;
log "/var/log/bird.log" all;
# Change this into your BIRD router ID. It's a world-wide unique identification
# of your router, usually one of router's IPv4 addresses.
router id 10.226.11.27;# The Kernel protocol is not a real routing protocol. Instead of communicating
# with other routers in the network, it performs synchronization of BIRD's
# routing tables with the OS kernel.
protocol kernel {debug { states };scan time 10;learn;persist;import none;  # kernel to bird mapexport all;   # Actually insert routes into the kernel routing table
}# The Device protocol is not a real routing protocol. It doesn't generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel.
protocol direct {interface "veth2";
}
protocol device {
}# 与10.226.11.21建立bgp peer的配置
protocol bgp peer_10_226_11_21 {debug { states };local as 64512;neighbor 10.226.11.21 as 64512;source address 10.226.11.27;#multihop;password "passwd";direct;export all; # 控制哪些路由可以发布给bgp peerimport all; # 从 direct, device, static, kernel 等所有protocol的路由都导入bird 的 bgp 路由## 让 10.226.11.21 作为 rr clientrr client;# cluster id 标识属于哪个集群rr cluster id 224.0.0.1;
}# 与10.226.11.22建立bgp peer的配置
protocol bgp peer_10_226_11_22 {debug { states };# 配置 BGP 的 graceful restart# 如果对端因为网络抖动或暂时崩溃而暂时下线,会导致所有传入路由瞬间消失# 为了避免这种情况下数据转发中断,才有 graceful restart# 建议打开graceful restart on;# 指定自己的 ASN 为 65550local as 64512;# 指定对端的 ASN 为 64512,IP 为 10.226.11.22# 如果 ASN 和 local as 相同,那么 BIRD 会自动认为这是一个 iBGP,否则是 eBGP# i 表示 internal(内部),e 表示 external(外部)neighbor 10.226.11.22 as 64512;# source: 定义本地地址作为BGP会话的源地址。Default:邻居所连接接口的本端地址。source address 10.226.11.27;#multihop;# password: 如果和对端约定了密码,在这里配置约定好的密码,否则不用写password "passwd";# direct: eBGP 默认启用可以不写# direct: iBGP 如果是直接连接的可以写这个来避免 multihop 被指定# 指定邻居为直连。邻居的IP地址必须在直接可达的IP范围内(即与路由器的接口有关联),# 否则BGP会话不会启动,而是等待这样的接口出现。另一种选择是多跳选项。默认值:使能eBGP。direct;#export: 控制哪些路由可以发布给bgp peerexport all;import all;## 让 10.226.11.22 作为 rr clientrr client;rr cluster id 224.0.0.1;
}

配置文件中重要的就如下2行代码,其余代码与上一文中几乎相同:

这2行代码说明了:本节点作为RR,并且指定了哪些bgp节点作为rr client,同时设置集群标识。

	rr client;rr cluster id 224.0.0.1;
宿主B作为RR client角色

/etc/bird.bird.conf的配置文件如下:

# This is a minimal configuration file, which allows the bird daemon to start
# but will not cause anything else to happen.
#
# Please refer to the documentation in the bird-doc package or BIRD User's
# Guide on http://bird.network.cz/ for more information on configuring BIRD and
# adding routing protocols.#log syslog all;
log "/var/log/bird.log" all;
# Change this into your BIRD router ID. It's a world-wide unique identification
# of your router, usually one of router's IPv4 addresses.
router id 10.226.11.22;# The Kernel protocol is not a real routing protocol. Instead of communicating
# with other routers in the network, it performs synchronization of BIRD's
# routing tables with the OS kernel.
protocol kernel {debug { states };scan time 10;learn;persist;import none;  # kernel to bird mapexport all;   # Actually insert routes into the kernel routing table
}# The Device protocol is not a real routing protocol. It doesn't generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel.
protocol direct {interface "veth2";
}
protocol device {
}# 与 RR 建立 bgp peer 关系
protocol bgp peer_10_226_11_27 {debug { states };local as 64512;neighbor 10.226.11.27 as 64512;source address 10.226.11.22;direct;password "passwd";export all;import all;
}

10.226.11.22 作为 rr client ,只需要与 RR 建立 bgp peer关系;从配置文件可以看出,自己不知道peer_10_226_11_27是一个RR,也就是说RR不需要让其cilent 知道自己是一个RR。

宿主C作为RR client角色

/etc/bird.bird.conf的配置文件如下:

# This is a minimal configuration file, which allows the bird daemon to start
# but will not cause anything else to happen.
#
# Please refer to the documentation in the bird-doc package or BIRD User's
# Guide on http://bird.network.cz/ for more information on configuring BIRD and
# adding routing protocols.
log "/var/log/bird.log" all;
# Change this into your BIRD router ID. It's a world-wide unique identification
# of your router, usually one of router's IPv4 addresses.
router id 10.226.11.21;# The Kernel protocol is not a real routing protocol. Instead of communicating
# with other routers in the network, it performs synchronization of BIRD's
# routing tables with the OS kernel.
protocol kernel {learn;persist;scan time 10;import none;export all;   # Actually insert routes into the kernel routing table
}# The Device protocol is not a real routing protocol. It doesn't generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel.
protocol device {
}protocol direct {interface "veth2";
}# 与 RR 建立 bgp peer 关系
protocol bgp peer_10_226_11_27 {debug { states };local as 64512;neighbor 10.226.11.27 as 64512;source address 10.226.11.21;direct;password "passwd";export all;import all;
}

10.226.11.21 作为 rr client ,只需要与 RR 建立 bgp peer关系;从配置文件可以看出,自己不知道peer_10_226_11_27是一个RR,也就是说RR不需要让其cilent 知道自己是一个RR。

查看状态

登录宿主A 10.226.11.27查看其相关网络的状态

  • 查看 bgp peer 邻居状态

Established表示与bgp peer邻接关系已经建立,而且已经相互完成了路由学习

root@10_226_11_27:/work/code# birdc  show  protocol
BIRD 1.5.0 ready.
name     proto    table    state  since       info
kernel1  Kernel   master   up     16:06:17
direct1  Direct   master   up     16:06:17
device1  Device   master   up     16:06:17
peer_10_226_11_21 BGP      master   up     16:06:21    Established
peer_10_226_11_22 BGP      master   up     16:06:22    Established
  • bird 路由表
root@10_226_11_27:/work/code# birdc show route
BIRD 1.5.0 ready.
# 从 protocol direct 导入的路由
192.168.227.0/24   dev veth2 [direct1 16:06:17] * (240)
# 从 bgp peer_10_226_11_21 学习的路由 
192.168.221.0/24   via 10.226.11.21 on eth0 [peer_10_226_11_21 16:06:21] * (100) [i]
# 从 bgp peer_10_226_11_22 学习的路由 
192.168.222.0/24   via 10.226.11.22 on eth0 [peer_10_226_11_22 16:18:14] * (100) [i]

从可以看到RR 上学习到了2个宿主的2个容器网段。

  • bird路由表的详细信息
root@10_226_11_27:/work/code# birdc show route all
BIRD 1.5.0 ready.
192.168.227.0/24   dev veth2 [direct1 16:06:17] * (240)Type: device unicast univ
192.168.221.0/24   via 10.226.11.21 on eth0 [peer_10_226_11_21 16:06:21] * (100) [i]Type: BGP unicast univBGP.origin: IGPBGP.as_path:BGP.next_hop: 10.226.11.21BGP.local_pref: 100
192.168.222.0/24   via 10.226.11.22 on eth0 [peer_10_226_11_22 16:18:14] * (100) [i]Type: BGP unicast univBGP.origin: IGPBGP.as_path:BGP.next_hop: 10.226.11.22BGP.local_pref: 100
  • kernel 路由表
root@10_226_11_27:/work/code# ip route show
default via 10.226.8.1 dev eth0
# 宿主 eth0接口 的直连路由
10.226.8.0/22 dev eth0  proto kernel  scope link  src 10.226.11.27
# 从bird 学习来的路由
192.168.221.0/24 via 10.226.11.21 dev eth0  proto bird
192.168.222.0/24 via 10.226.11.22 dev eth0  proto bird
# 宿主 veth2接口 直接的路由(模拟的容器网段)
192.168.227.0/24 dev veth2  proto kernel  scope link  src 192.168.227.101
  • 查看宿主10.226.11.22的bird路由表

在这里插入图片描述

从可以看到本宿主上学习到了其余2个宿主的2个容器网段:192.168.221.0/24和192.168.227.0/24

  • 查看宿主10.226.11.22的bird路由表

从可以看到本宿主上学习到了其余2个宿主的2个容器网段:192.168.222.0/24和192.168.227.0/24

网络测试验证

  • 从容器192.168.227.102 ping 容器192.168.221.102
    在这里插入图片描述

  • 容器192.168.221.102 ping 192.168.222.102
    在这里插入图片描述

可见三个容器网络可以互通,达到了实验目的。

实验结论

  • 实现了三台宿主的bird的BGP RR 模式
  • 三台宿主通过bgp相互完成了路由学习
  • 通过实验我们对calico中的bird程序有了更深入的认知

三、参考文档

bird官网

BIRD BGP route-reflector

https://wiki.skywolf.cloud/quickstart/player.html

https://gitlab.nic.cz/labs/bird/-/wikis/BGP_example_1

https://lyyao09.github.io/2020/06/30/linux/Intro-to-BGP-with-BIRD/

https://soha.moe/post/bird-bgp-kickstart.html

四、补充

生产环境中路由反射器的最佳实践

在这里插入图片描述

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

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

相关文章

操作系统 | 学习笔记 | | 王道 | 5.3 磁盘和固态硬盘

5.3 磁盘和固态硬盘 5.3.1 磁盘 磁盘结构 磁盘:磁盘的表面由一些磁性物质组成,可以用这些磁性物质来记录二进制数据 磁道:磁盘的盘面被划分成一个个磁道。这样的一个“圈”就是一个磁道 扇区:一个磁道又被划分成一个个扇区&am…

828华为云征文 | 在华为云X实例上安装部署企业Wiki知识分享平台的实践

目录 前言 1. 华为云X实例介绍 1.1 华为云Flexus云服务概述 1.2 Flexus云服务器X实例的特点 2. MM-Wiki知识分享平台介绍 2.1 什么是MM-Wiki 2.2 MM-Wiki的功能特点 3. 安装部署环境 4. MM-Wiki安装部署步骤 4.1 下载与准备工作 4.2 安装MM-Wiki 4.3 启动与运行 5…

[spring]MyBatis介绍 及 用MyBatis操作简单数据库

文章目录 一. 什么是MyBatis二. MyBatis操作数据库步骤创建工程创建数据库创建对应实体类配置数据库连接字符串写持久层代码单元测试 三. MyBatis基础操作打印日志参数传递增删改查 四. MyBatis XML配置文件配置链接字符串和MyBatis写持久层代码方法定义Interface方法实现xml测…

从入门到精通:QT 100个关键技术关键词

Qt基础概念 Qt Framework - 一个跨平台的C图形用户界面应用程序开发框架。它不仅提供了丰富的GUI组件,还包括网络、数据库访问、多媒体支持等功能。 Qt Creator - Qt官方提供的集成开发环境(IDE),集成了代码编辑器、项目管理工具、…

Linux网络之UDP与TCP协议详解

文章目录 UDP协议UDP协议数据报报头 TCP协议确认应答缓冲区 超时重传三次握手其他问题 四次挥手滑动窗口流量控制拥塞控制 UDP协议 前面我们只是说了UDP协议的用法,但是并没有涉及到UDP协议的原理 毕竟知道冰箱的用法和知道冰箱的原理是两个层级的事情 我们首先知道计算机网…

【RabbitMQ】RabbitMQ 的概念以及使用RabbitMQ编写生产者消费者代码

目录 1. RabbitMQ 核心概念 1.1生产者和消费者 1.2 Connection和Channel 1.3 Virtual host 1.4 Queue 1.5 Exchange 1.6 RabbitMO工作流程 2. AMQP 3.RabbitMO快速入门 3.1.引入依赖 3.2.编写生产者代码 ​3.3.编写消费者代码 4.源码 1. RabbitMQ 核心概念 在安装…

【Redis】Linux下安装配置及通过C++访问Redis

文章目录 一、Linux Centos 7.0版本下的安装及配置二、通过C访问Redis 一、Linux Centos 7.0版本下的安装及配置 通过源来安装,此次安装的版本为 redis 5.0 的,要通过其他源进行安装,首先安装 scl 源 yum install centos-release-scl-rh再安…

LED显示屏驱动电源:恒流与恒压,谁更胜一筹?

LED显示屏,作为现代电子显示技术的重要代表,已经在我们的生活中无处不在。无论是商场的广告牌、体育场的计分板,还是家庭中的智能电视,LED显示屏都以其鲜艳的色彩、高清晰度和长寿命赢得了我们的青睐。然而,在这背后&a…

爬虫逆向学习(七):补环境动态生成某数四代后缀MmEwMD

声明:本篇文章内容是整理并分享在学习网上各位大佬的优秀知识后的实战与踩坑记录 前言 这篇文章主要是研究如何动态生成后缀参数MmEwMD的,它是在文章爬虫逆向学习(六):补环境过某数四代的基础上进行研究的,代码也是在它基础上增…

Python在AI中的应用--使用决策树进行文本分类

Python在AI中的应用--使用决策树进行文本分类 文本分类决策树什么是决策树 scikit算法 使用scikit的决策树进行文章分类一个文本分类的Python代码使用的scikit APIs说明装入数据集决策树算法类类构造器: 构造决策树分类器产生输出评估输出结果分类准确度分类文字评估…

如何从格式化的笔记本电脑或台式机中恢复照片

您想学习如何从已格式化的笔记本电脑或台式机中恢复已删除的照片吗?这篇文章解释了如何使用最佳格式的照片恢复软件来做到这一点。您可以通过简单的步骤格式化计算机后恢复已删除的图像。 将照片保存在笔记本电脑或 PC 硬盘上是很常见的。与相机存储卡和 USB 闪存驱…

代码随想录Day16 单调栈

739. 每日温度 该题的题意很简单 要求遍历温度数组 找出几天后会出现下一次更高的温度 这就可以用到单调栈的知识 通常是一维数组,要寻找任一个元素的右边或者左边第一个比自己大或者小的元素的位置,此时我们就要想到可以用单调栈了 那么我们该如何实现…

Leetcode 65. 有效数字

1.题目基本信息 1.1.题目描述 给定一个字符串 s ,返回 s 是否是一个 有效数字。 例如,下面的都是有效数字:”2″, “0089”, “-0.1”, “3.14”, “4.”, “-.9”, “2e10”, “-90E3”, “3e7”, “6e-1”, “53.5e93”, “-123.456e789…

单链表:学生信息管理系统

一、头文件 #ifndef __LINK_H__ #define __LINK_H__ #include <myhead.h> #define MAX 30 // 建立学生结构体 typedef struct student {int id; //学号char name[20]; //姓名float score; //分数 }stu;typedef struct node {union{int len;stu data;};struct node * nex…

(Arxiv-2024)DiffLoRA:通过扩散生成个性化低秩自适应权重

DiffLoRA&#xff1a;通过扩散生成个性化低秩自适应权重 paper title&#xff1a;DiffLoRA: Generating Personalized Low-Rank Adaptation Weights with Diffusion paper是电子科技大学发表在arxiv 2024的工作 paper地址 Abstract 个性化文本转图像生成因其能够根据用户定义的…

【python】requests 库 源码解读、参数解读

文章目录 一、基础知识二、Requests库详解2.1 requests 库源码简要解读2.2 参数解读2.3 处理响应2.4 错误处理 一、基础知识 以前写过2篇文章&#xff1a; 计算机网络基础&#xff1a; 【socket】从计算机网络基础到socket编程——Windows && Linux C语言 Python实现…

环形缓冲区例子

即使使用中断函数或者定时器函数记录按键&#xff0c;如果只能记录一个键值的话&#xff0c;如果不能 及时读走出来&#xff0c;再次发生中断时新值就会覆盖旧值。要解决数据被覆盖的问题&#xff0c;可以使用 一个稍微大点的缓冲区&#xff0c;这就涉及数据的写入、读出&#…

MyBatis - 动态SQL

前言 我们在某网站填写个人信息时&#xff0c;时常会遇到可以选填的空&#xff08;即可填&#xff0c;可不填&#xff09;&#xff0c;由于之前讲过的Java中的SQL语句都是固定的&#xff0c;且我们不可能对所有情况都写出与之对应的插入语句&#xff08;太过繁琐&#xff09;&…

【LLM多模态】Animatediff文生视频大模型

note AnimateDiff框架&#xff1a;核心是一个可插拔的运动模块&#xff0c;它可以从真实世界视频中学习通用的运动先验&#xff0c;并与任何基于相同基础T2I的个性化模型集成&#xff0c;以生成动画。训练策略&#xff1a;AnimateDiff的训练包括三个阶段&#xff1a; 领域适配…

56 mysql 用户权限相关的实现

前言 这里讨论 mysql 的权限相关处理 使用如下语句创建 tz_test 用户, 并赋予他 test_02 数据库的查询权限 create user tz_test% identified by tz_test; grant select on test_02.* to tz_test%; 查询目标数据表, 数据如下, tz_test_02 UPDATE command denied to user …