运维别卷系列 - 云原生监控平台 之 01.prometheus 入门和部署

文章目录

    • @[toc]
    • 什么是 Prometheus
      • Prometheus 架构及其一些生态系统组件
      • Prometheus 的工作模式
      • Prometheus 的适用场景
      • Prometheus 的不适用场景
      • Prometheus 词汇表
    • Prometheus 启动参数
    • Prometheus 配置文件
      • 通用占位符定义
      • 配置文件示例解释
      • 服务发现
    • Prometheus 部署
      • 创建 namespace
      • 创建 rbac 相关的
      • 创建 svc
      • 固定节点创建 label 和持久化目录
      • 创建 deployment

Prometheus 官网

什么是 Prometheus

  • Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project’s governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project, after Kubernetes.
  • Prometheus 是一个开源系统监控和警报工具包,最初由 SoundCloud 构建。自 2012 年成立以来,许多公司和组织都采用了 Prometheus,该项目拥有非常活跃的开发者和用户社区。它现在是一个独立的开源项目,独立于任何公司进行维护。为了强调这一点,并明确项目的治理结构,Prometheus 于 2016 年加入云原生计算基金会,成为继 Kubernetes 之后的第二个托管项目。
  • Prometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.
  • Prometheus 将其指标收集并存储为时间序列数据,即指标信息与记录它的时间戳一起存储,以及称为标签的可选键值对。

Prometheus 架构及其一些生态系统组件

在这里插入图片描述

  • Prometheus server
    • Retrieval: 获取监控数据
    • TSDB: 时间序列数据库 (Time Series Database)
    • HTTP Server: 为告警和出图提供查询接口
  • Pushgateway: 针对一些 Prometheus 无法获取监控数据的服务,可以通过推送监控数据给 Pushgateway 后,由 Prometheus 去 Pushgateway 获取
  • Alertmanager: 在触发了预先设置在 Prometheus 中的告警规则后, Prometheus 便会推送告警消息到 AlertManager。
    • AlertManager 提供了十分灵活的告警方式,可以通过邮件、slack 或者钉钉等途径推送。
    • 并且 AlertManager 支持高可用部署,为了解决多个 AlertManager 重复告警的问题,引入了 Gossip,在多个 AlertManager 之间通过 Gossip 同步告警信息
  • PromQL: Prometheus 提供了一种称为 PromQL(Prometheus Query Language)的功能查询语言,允许用户实时选择和聚合时间序列数据。表达式的结果可以显示为图形,在 Prometheus 的表达式浏览器中查看为表格数据,也可以通过 HTTP API 由外部系统使用。
  • Prometheus web UI: 通过 PromQL 语句查询指标信息,并在页面展示。虽然 Prometheus 自带 UI 界面,但是大部分都是使用 Grafana 出图。另外第三方也可以通过 API 接口来获取监控指标。
  • Exporters: 指标暴露器,负责从目标应用程序上采集和聚合原始格式的数据,并转换或聚合为 Prometheus 格式的指标向外暴露。
    • Node-Exporter用于收集服务器节点(例如 k8s)的物理指标状态数据,如平均负载、CPU、内存、磁盘、网络等资源信息的指标数据,需要部署到所有运算节点
    • Kube-state-Metrics为 Prometheus 采集 k8s 资源数据的 exporter,通过监听 APIServer 收集 kubernetes 集群内资源对象的状态指标数据,例如 pod、deployment、service 等等。同时它也提供自己的数据,主要是资源采集个数和采集发生的异常次数统计。
    • cAdvisor用来监控容器内部使用资源的信息,比如 CPU、内存、网络 I/0、磁盘 I/0。
    • blackbox-exporter:监控业务容器存活性。

Prometheus 的工作模式

  • 通过上面的图可以看出,Prometheus 有两种模式
    • 服务发现(Service Discovery)机制
    • 静态配置获取要监视的目标(Prometheus Targets)
      • 通过每个目标上的指标 exporter 来采集(Scrape)指标数据

Prometheus 的适用场景

  • Prometheus works well for recording any purely numeric time series. It fits both machine-centric monitoring as well as monitoring of highly dynamic service-oriented architectures. In a world of microservices, its support for multi-dimensional data collection and querying is a particular strength.
  • Prometheus 非常适合记录任何纯数字时间序列。它既适合以机器为中心的监控,也适合监控高度动态的面向服务的架构。在微服务的世界中,它对多维数据收集和查询的支持是一个特别的优势。
  • Prometheus is designed for reliability, to be the system you go to during an outage to allow you to quickly diagnose problems. Each Prometheus server is standalone, not depending on network storage or other remote services. You can rely on it when other parts of your infrastructure are broken, and you do not need to setup extensive infrastructure to use it.
  • Prometheus 专为可靠性而设计,是您在中断期间访问的系统,可让您快速诊断问题。每个 Prometheus 服务器都是独立的,不依赖于网络存储或其他远程服务。当基础架构的其他部分损坏时,您可以依赖它,并且无需设置广泛的基础架构即可使用它。

Prometheus 的不适用场景

  • Prometheus values reliability. You can always view what statistics are available about your system, even under failure conditions. If you need 100% accuracy, such as for per-request billing, Prometheus is not a good choice as the collected data will likely not be detailed and complete enough. In such a case you would be best off using some other system to collect and analyze the data for billing, and Prometheus for the rest of your monitoring.
  • Prometheus 重视可靠性。您始终可以查看有关系统的可用统计信息,即使在故障条件下也是如此。如果您需要 100% 的准确性,例如按请求计费,Prometheus 不是一个好的选择,因为收集的数据可能不够详细和完整。在这种情况下,您最好使用其他系统来收集和分析计费数据,并使用 Prometheus 进行其余的监控。

Prometheus 词汇表

Prometheus 词汇表

  • Alert:Prometheus 中主动触发的警报规则的结果。Alert 从 Prometheus 发送到 Alertmanager。
  • Alertmanager:接收警报,将它们聚合到组中,删除重复数据,应用静音、限制,然后向电子邮件、Pagerduty、Slack 等发送通知。
  • Bridge:从客户端库中获取样本并将其公开给非 Prometheus 监控系统的组件。例如,Python、Go 和 Java 客户端可以将指标导出到 Graphite。
  • Client library:某种语言(例如 Go、Java、Python、Ruby)的库,可以轻松地直接检测代码、编写自定义收集器以从其他系统提取指标并将指标公开给 Prometheus。
  • Collector:exporter 的一部分,表示一组指标。如果它是直接检测的一部分,它可能是单个指标,如果它从另一个系统提取指标,则可能是多个指标。
  • Direct instrumentation:使用客户端库作为程序源代码的一部分以内联方式添加的检测。
  • Endpoint:可以抓取的指标源,通常对应于单个进程。
  • Exporter:与要从中获取指标的应用程序一起运行的二进制文件。exporter 公开 Prometheus 指标,通常是将以非 Prometheus 格式公开的指标转换为 Prometheus 支持的格式。
  • Instance:用于唯一标识作业中目标的标签。
  • Job:具有相同目的的目标集合(例如,监视为可伸缩性或可靠性而复制的一组类似进程)称为 job。
  • Notification:表示一组或多个警报,并由 Alertmanager 发送到电子邮件、Pagerduty、Slack 等。
  • Promdash:Prometheus 的原生仪表板构建器。它已被弃用,取而代之的是 Grafana。
  • Prometheus:通常是指 Prometheus 系统的核心二进制文件。它也可以指整个普罗米修斯监控系统。
  • PromQL:Prometheus 查询语言。它允许广泛的操作,包括聚合、切片和切割、预测和连接。
  • Pushgateway:保留来自批处理作业的最新指标推送。这允许 Prometheus 在终止后抓取其指标。
  • Recording Rules:预先计算经常需要或计算成本高昂的表达式,并将其结果保存为一组新的时间序列。
  • Remote Read:Prometheus 的一项功能,它允许在查询过程中透明地读取来自其他系统(例如长期存储)的时间序列。
  • Remote Read Adapter:位于 Prometheus 和另一个系统之间,在它们之间转换时间序列请求和响应。
  • Remote Read Endpoint:Prometheus 在执行远程读取时与之通信的内容。
  • Remote Write:Prometheus 的一项功能,允许将摄取的样本动态发送到其他系统,例如长期存储。
  • Remote Write Adapter:Prometheus 和另一个系统之间,将远程写入中的样本转换为其他系统可以理解的格式。
  • Remote Write Endpoint:Prometheus 在执行远程写入时与之通信的内容。
  • Sample:样本是时间序列中某个时间点的单个值。在 Prometheus 中,每个样本都由一个 float64 值和一个毫秒精度的时间戳组成。
  • Silence:Alertmanager 中的静默可防止警报(与静默匹配的标签)包含在通知中。
  • Target:要抓取的对象的定义。例如,要应用哪些标签、连接所需的任何身份验证或定义抓取方式的其他信息。
  • Time Series:Prometheus 时间序列(Time Series)是属于同一指标和同一组标记维度的时间戳值流。Prometheus 将所有数据存储为时间序列。

Prometheus 启动参数

可以通过 prometheus -h 命令来查看拥有哪些参数

参数参数解释
-h, --help显示参数的帮助文档
--version显示版本信息
--config.file"prometheus.yml"指定配置文件
--web.listen-address="0.0.0.0:9090"ui、api、telemetry监听地址信息
--web.config.fileTLS或身份验证配置文件
--web.read-timeout=5m页面读取请求最大超时时间
--web.max-connections=512同时访问Prometheus页面的最大连接数,默认为512
--web.external-urlPrometheus对外提供的url(eg: Prometheus通过反向代理提供服务)。用于生成一个相对和绝对的链接返回给Prometheus本身。如果这个url有路径部分,它将用于Prometheus所有HTTP端点的前缀。如果省略了,则相关的url组件将自动派生
--web.route-prefixWeb端点内部路由的前缀。默认路径:web.external-url
--web.user-assets静态资源路径,可以在/user下找到
--web.enable-lifecycle通过HTTP请求启用关闭和重新加载
--web.enable-admin-api启用管理控制操作的api端点
--web.enable-remote-write-receiver启用接受远程写入请求的 API 端点
--web.console.templates="consoles"到控制台模板目录的路径,可以在consoles/目录下找到。
--web.console.libraries="console_libraries"控制台库目录的路径
--web.page-title="Prometheus Time Series Collection and Processing Server"Prometheus实例的文件标题
--web.cors.origin=".*"正则表达式为CORS原点
--storage.tsdb.path="data/"数据存储的路径
--storage.tsdb.retention此标志已被弃用,请使用 --storage.tsdb.retention.time
--storage.tsdb.retention.timeTSDB 数据保留时长,默认是 15天,可以配置的单位:y(年),w(周),d(天),m(分钟),s(秒),ms(毫秒)
--storage.tsdb.retention.sizeTSDB 数据最大保存大小,可以配置的单位:B, KB, MB, GB, TB, PB, EB;1KB=1024B
--storage.tsdb.no-lockfile不在数据目录中创建lockfile
--storage.tsdb.head-chunks-write-queue-size=0通过其将头块写入要进行 m-mapped 的磁盘的队列的大小,0 将完全禁用队列。实验的仅与服务器模式一起使用。
--storage.agent.path="data-agent/"数据存储的路径。仅与代理模式一起使用。
--storage.agent.wal-compression压缩代理 wal。仅与代理模式一起使用。
--storage.agent.retention.min-time最小时间当 WAL 被截断时,TSDB 数据保留时长。仅与代理模式一起使用
--storage.agent.retention.max-time最长时间当 WAL 被截断时,TSDB 数据保留时长。仅与代理模式一起使用
--storage.agent.no-lockfile不要在数据目录中创建lockfile。仅与代理模式一起使用。
--storage.remote.flush-deadline关闭或重新加载配置时需要等待多长时间刷新样例。
--storage.remote.read-sample-limit=5e7在单个查询中通过远程读接口返回的最大样本总数。0意味着没有限制。对于流响应类型,此限制将被忽略。
--storage.remote.read-concurrent-limit=10并发远程读调用的最大数量。0意味着没有限制。
--storage.remote.read-max-bytes-in-frame=1048576在编组前流化远程读取响应类型的单个帧中的最大字节数。请注意,客户端可能也有帧大小的限制。默认情况下为1MB。
--rules.alert.for-outage-tolerance=1h忍受Prometheus故障恢复"for"警报状态的最大时间。
--rules.alert.for-grace-period=10m警报和恢复"for"状态之间的最小持续时间。仅对配置的"for"时间大于宽限期的警报进行维护。
--rules.alert.resend-delay=1m在向Alertmanager重新发送警报之前等待的最短时间。
--alertmanager.notification-queue-capacity=10000等待报警通知队列的大小。
--query.lookback-delta=5m允许在表达式求值期间检索度量值的delta差值。
--query.timeout=2m一个查询在终止之前可以执行的最长时间(如果超过2min,就会自动kill掉)。
--query.max-concurrency=20并发执行的最大查询数,默认为20。
--query.max-samples=50000000单个查询可以加载到内存中的最大样本数。注意,如果查询尝试将比这个更多的样本加载到内存中,那么查询将会失败,因此这也限制了查询可以返回的样本数量。
--enable-feature逗号分隔要启用的功能名称,有效选项:agent, exemplar-storage, expand-external-labels, memory-snapshot-on-shutdown, promql-at-modifier, promql-negative-offset, promql-per-step-stats, remote-write-receiver (DEPRECATED), extra-scrape-metrics, new-service-discovery-manager, auto-gomaxprocs, no-default-scrape-port, native-histograms。详情请查看https://prometheus.io/docs/prometheus/latest/feature_flags/。
--log.level=info开启打印日志级别(debug,info,warn,error,fatal)。默认为info
--log.format=logfmt日志消息的输出格式。[logfmt, json]

Prometheus 配置文件

Prometheus 配置文件

通用占位符定义

占位符占位符解释
<boolean>可以取值 true 或 false 的布尔值
<duration>`与正则表达式((([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?
<filename>当前工作目录中的有效路径
<float>浮点数
<host>由主机名或 IP 后跟可选端口号组成的有效字符串
<int>整数值
<labelname>与正则表达式 [a-zA-Z_][a-zA-Z0-9_]* 匹配的字符串。源标签中任何其他不受支持的字符都应转换为下划线。例如,标签 app.kubernetes.io/name 应写为 app_kubernetes_io_name。
<labelvalue>一串 Unicode 字符
<path>有效的 URL 路径
<scheme>可以采用值 http 或 https 的字符串
<secret>作为机密的常规字符串,例如密码
<string>常规字符串
<size>以字节为单位的大小,例如 512MB。需要一个单位。支持单位:B、KB、MB、GB、TB、PB、EB。
<tmpl_string>使用前经过模板扩展的字符串

其他占位符是单独指定的。

配置文件示例解释

github 上的配置文件模板

#配置文件中的全局配置
global:scrape_interval: 15s       # 多久收集一次数据,默认1分钟evaluation_interval: 30s   # 多久评估一次规则,默认1分钟scrape_timeout: 10s        # 每次收集数据的超时时间,默认10秒# 当 Prometheus 和外部系统(联邦, 远程存储, Alertmanager)通信的时候,添加标签到任意的时间序列或者报警external_labels:monitor: codelabfoo:     bar# 加载规则文件, 可以使用通配符
# 规则文件指定全局变量列表。从所有匹配的文件中读取规则和警报。
rule_files:
- "first.rules"
- "my/*.rules"# 远程写入功能相关的设置
remote_write:- url: http://remote1/pushwrite_relabel_configs:- source_labels: [__name__]regex:         expensive.*action:        drop- url: http://remote2/push# 远程读取相关功能的设置
remote_read:- url: http://remote1/readread_recent: true- url: http://remote3/readread_recent: falserequired_matchers:job: special# 收集数据-配置列表
# scrape_config 部分指定了一组目标和参数,描述了如何抓取它们。
# 在一般情况下,一个抓取资源配置指定一个作业。在高级配置中,这可能会改变。
# 可以通过 static_configs 参数静态配置目标,也可以使用支持的服务发现机制之一动态发现目标。
# 此外,relabel_configs 允许在抓取之前对任何目标及其标签进行高级修改。
scrape_configs:
# 必须配置, 自动附加的 job labels, 必须唯一
- job_name: prometheus# 标签冲突, true 为以抓取的数据为准并忽略服务器中的,false 为通过重命名来解决冲突。honor_labels: true# 从目标获取指标的 HTTP 资源路径metrics_path: '/metrics'# 文件服务发现配置列表# 基于文件的服务发现提供了一种更通用的方法来配置静态目标,并用作插入自定义服务发现机制的接口。# 它读取一组包含零个或多个 <static_config> 列表的文件。# 对所有定义文件的更改都会通过磁盘监视检测到并立即应用。# 文件可以 yaml 或 json 格式提供。仅应用形成良好目标组的更改。file_sd_configs:# 从这些文件中提取目标- files:- foo/*.slow.json- single/file.yml# 刷新文件的时间间隔refresh_interval: 10m# 使用 job 名作为 label 的静态配置目录的列表static_configs:- targets: ['localhost:9090', 'localhost:9191']labels:my:   labelyour: label# 目标节点重新打标签的配置列表。# 重新标记是一个功能强大的工具,可以在抓取目标之前动态重写目标的标签集。# 可以配置多个,按照先后顺序应用relabel_configs:- source_labels: [job, __meta_dns_name]   # 从现有的标签中选择源标签, 最后会被替换,保持,丢弃regex: (.*)some-[regex]  # 正则表达式, 将会提取 source_labels 中匹配的值# 在替换动作中将结果值写入的标签target_label: jobreplacement: foo-${1}# 如果正则表达匹配, 那么替换值. 可以使用正则表达中的捕获组# 将 abc 标签的内容复制到 cde 标签中- source_labels: [abc]target_label: cde- replacement: statictarget_label: abc- regex:replacement: statictarget_label: abc# 可选的, bearer token 文件的信息bearer_token_file: valid_token_file  # Alertmanager相关的配置
alerting:alertmanagers:# 配置如何访问 Alertmanager,可使用 http 或 https- scheme: httpsstatic_configs:- targets:- "1.2.3.4:9093"- "1.2.3.5:9093"
  • Prometheus 的配置文件是 prometheus.yml,在启动时指定相关的文件,可对配置内容进行加载,配置文件分为四个模块
    • global全局配置
    • alerting告警配置
    • rule_files规则配置
    • scrape_configs目标拉取配置

服务发现

在 Prometheus 的配置中,一个最重要的概念就是数据源 target,而数据源的配置主要分为静态配置和动态发现,以下简单列举几个国内用的上的,其他详细的,可以看 Prometheus 的官方文档

服务发现名称服务发现类型
static_configs静态服务发现
azure_sd_configs亚马逊云主机服务发现
consul_sd_configsconsul 服务发现
docker_sd_configsdocker 服务发现
dockerswarm_sd_configsdockerswarm 服务发现
dns_sd_configsDNS 服务发现
ec2_sd_configsAWS EC2 服务发现
eureka_sd_configseureka 服务发现
file_sd_configs文件服务发现
http_sd_configsHTTP 服务发现
kubernetes_sd_configsKubernetes 服务发现

Prometheus 部署

  • 以下采用 k8s 的方式部署,所以,需要现有一套 k8s 集群,以下的 k 命令是 kubectl 命令的简化版,需要自己对 kubectl 命令做一个软连接,如果没有,需要自己替换成 kubectl 命令
  • 我的 k8s 版本是 v1.26.3 的,有可能会出现 kind 版本不对,需要自己对应的去修改 yaml 文件
  • 部署的 prometheus 是 v2.45.5 版本,是当前 2024年5月 的 LTS 版本

创建 namespace

k create ns monitor

创建 rbac 相关的

---
apiVersion: v1
kind: ServiceAccount
metadata:annotations:name: prometheusnamespace: monitor
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:name: prometheus
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-admin
subjects:- kind: ServiceAccountname: prometheusnamespace: monitor

创建 svc

创建一个 nodeport 类型的,这样可以直接使用 ip+端口的方式访问 Prometheus 的 web UI

---
apiVersion: v1
kind: Service
metadata:annotations:labels:app: prometheusname: prometheus-svcnamespace: monitor
spec:type: NodePortports:- name: httpport: 9090targetPort: 9090nodePort: 31090selector:app: prometheus

固定节点创建 label 和持久化目录

  • 当前没有做 ha 模式,也没做远程共享存储,这里直接使用 localpath 的方式来持久化 Prometheus 的 TSDB 数据,因此也需要固定 Prometheus 到某个固定节点
  • 关于目录的创建和配置文件的准备,也需要去指定的节点操作,下面的节点信息,需要自己替换
    • config 目录放 Prometheus 的配置文件
    • data 目录放 Prometheus 的 TSDB 数据
    • rules 目录放 Prometheus 的告警规则文件
k label node 192.168.11.185 prometheus=
mkdir -p /data/k8s-data/prometheus/{config,data,rules}
chmod -R 777 /data/k8s-data/prometheus

Prometheus 配置文件,对应的路径 /data/k8s-data/prometheus/config/prometheus.yml

global:scrape_interval: 30sevaluation_interval: 30sscrape_timeout: 10sexternal_labels:prometheus: monitor/k8s
rule_files:
- /etc/prometheus/rules/*.yml
scrape_configs:
- job_name: prometheusmetrics_path: '/metrics'static_configs:- targets: ['prometheus-svc.monitor.svc.cluster.local:9090']

创建 deployment

---
apiVersion: apps/v1
kind: Deployment
metadata:annotations:labels:app: prometheusname: prometheusnamespace: monitor
spec:replicas: 1selector:matchLabels:app: prometheustemplate:metadata:labels:app: prometheusspec:serviceAccount: prometheusaffinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:- matchExpressions:- key: prometheusoperator: ExistspodAntiAffinity:requiredDuringSchedulingIgnoredDuringExecution:- labelSelector:matchExpressions:- key: appoperator: Invalues:- prometheustopologyKey: kubernetes.io/hostnameterminationGracePeriodSeconds: 0containers:- name: prometheuscommand:- "/bin/prometheus"args:- "--config.file=/etc/prometheus/config/prometheus.yml"- "--storage.tsdb.path=/etc/prometheus/data"- "--storage.tsdb.retention.time=30d"- "--web.enable-lifecycle"image: prom/prometheus:v2.45.5env:- name: TZvalue: Asia/ShanghaiimagePullPolicy: IfNotPresentports:- containerPort: 9090name: httplivenessProbe:failureThreshold: 60initialDelaySeconds: 5periodSeconds: 10successThreshold: 1tcpSocket:port: httptimeoutSeconds: 1readinessProbe:failureThreshold: 60initialDelaySeconds: 5periodSeconds: 10successThreshold: 1tcpSocket:port: httptimeoutSeconds: 1volumeMounts:- name: prometheus-homemountPath: /etc/prometheusresources:requests:memory: 256Micpu: 100mlimits:memory: 2048Micpu: 1000mvolumes:- hostPath:path: /data/k8s-data/prometheustype: DirectoryOrCreatename: prometheus-home

启动成功后,使用 ip:31090 的方式来访问 Prometheus,访问 status 下面的 targets 可以看到,我们配置文件配置的 Prometheus 已经有了,并且状态是 up

在这里插入图片描述

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

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

相关文章

Unity里的Time

Time and frame rate management Time类&#xff1a; Time script reference page. 一些常见的属性有&#xff1a; Time.time 返回从游戏开始经历的时间.Time.deltaTime 返回从上帧结束到现在经历的时间&#xff0c;和帧率成反比Time.timeScale 控制时间流逝的因子Time.fixe…

嵌入式学习-通用定时器

简介 框图介绍 时钟选择 计数器部分 输入捕获和输出比较框图 嵌入式学习全文参考&#xff08;小向是个der&#xff09;做笔记&#xff1a;https://blog.csdn.net/qq_41954556/article/details/129735708

C#中json数据序列化和反序列化的最简单方法(C#对象和字符串的相互转换)

文章目录 将C#对象转换为json字符串Newtonsoft模块的安装用Newtonsoft将对象转换为json字符串 将json字符串转换为C#对象 将C#对象转换为json字符串 本介绍将基于C#中的第三方库Newtonsoft进行&#xff0c;因此将分为Newtonsoft模块的安装和使用两部分。该模块的优势在于只需要…

Python以docker形式部署,flask简易服务器。

公司大部分都是springboot 服务器&#xff0c;有时候用到python写的一些模型&#xff0c;部署在linux上进行处理 首先项目这样&#xff1a; flask就不说了&#xff0c;快捷服务器&#xff0c; # -*- coding: utf-8 -*-from flask import Flask, request# 实例化Flask对象 app…

LVM - Linux磁盘逻辑卷管理器概念讲解及实践

1、lvm概念 逻辑卷管理器(LogicalVolumeManager)本质上是一个虚拟设备驱动,是在内核中块设备和物理设备之间添加的一个新的抽象层次,它可以将几块磁盘(物理卷,PhysicalVolume)组合起来形成一个存储池或者卷组(VolumeGroup)。LVM可以每次从卷组中划分出不同大小的逻辑卷(Logi…

【核弹】我的第一款IDEA插件

SuperHotSwap 插件名称叫做&#xff1a;SuperHotSwap&#xff08;超级热更新&#xff09; 开发初心&#xff1a;旨在做出一款最便捷的IDEA热更新插件&#xff0c;减少用户操作步骤&#xff0c;提供零配置的可视化操作更新。 为什么要写这个插件&#xff1a; 每次改一下Mappe…

OSPF工作过程

1.OSPF的数据包 hello包——周期性的发现&#xff0c;建立以及保活邻居关系 hello时间 --- 10S 死亡时间 --- 4倍的hello时间 --- 40S RID --- 1&#xff0c;全网唯一;2&#xff0c;格式统一---- 格式要求和IP地址一样&#xff0c;由32位二进制构成&#xff0c;使用点分十进制…

[js] 递归,数组对象根据某个值进行升序或者降序

一、效果图 1.1 父级 1.2 父级与子级 二、代码 升序降序&#xff0c;只要把 a.num - b.num 改成 b.num - a.num <html lang"en"><head><meta charset"UTF-8" /><meta name"viewport" content"widthdevice-width, i…

idea 使用 git

可以看见项目地址&#xff0c; git clone 地址 就可以拉新项目了 命令 git remote -v

JETBRAINS IDES 分享一个2099通用试用码,支持一键升级!CLion 2024 版

文章目录 废话不多说上教程&#xff1a;&#xff08;动画教程 图文教程&#xff09;一、动画教程激活 与 升级&#xff08;至最新版本&#xff09; 二、图文教程 &#xff08;推荐&#xff09;Stage 1.下载安装 toolbox-app&#xff08;全家桶管理工具&#xff09;Stage 2 : 下…

8.基于鱼鹰优化算法(OOA)优化VMD参数(OOA-VMD)

代码原理 鱼鹰优化算法&#xff08;Osprey Optimization Algorithm, OOA&#xff09;是一种基于仿生学原理的启发式优化算法&#xff0c;它模拟了鱼鹰觅食的行为&#xff0c;通过调整搜索空间中的个体位置来优化目标函数。 鱼鹰优化算法可参考&#xff1a;鱼鹰优化算法(Ospre…

Spring Framework-IoC详解

IoC的概念和作用 在介绍Ioc之前&#xff0c;我们首先先了解一下以下内容 什么是程序的耦合 耦合性(Coupling)&#xff0c;也叫耦合度&#xff0c;是对模块间关联程度的度量。耦合的强弱取决于模块间接口的复杂性、调用模块的方式以及通过界面传送数据的多少。模块间的耦合度…

ssti学习(1)

一、成因&#xff1a; 渲染模板时&#xff0c;没有严格控制对用户的输入。&#xff08;使用了危险的模板&#xff0c;导致用户可以和flask程序进行交互&#xff09; flask是一种基于web开发的web服务器&#xff0c;如果用户可以和flask交互&#xff0c;则可以执行eval、syste…

03 Linux编程-进程

1、进程的相关概念 1.1 程序与进程 程序是静态的概念&#xff0c;进程是程序的一次运行活动。 1.2 查看系统中有哪些进程 ps #只显示一小部分进程 ps -aux #会打印当前所有进程 ps -aux|grep init #使用grep筛选出只含有init的进程top #运行显示的进程有点类似windows…

视频号小店应该怎么去做呢?运营步骤分享!建议收藏!

大家好&#xff0c;我是电商小V 视频号小店是一个新推出的项目&#xff0c;目前可以说正处于红利期&#xff0c;也是正处于野蛮生长的阶段&#xff0c;平台现在对视频号的扶持可以说是非常大的&#xff0c;对于新入驻的商家也是非常友好的&#xff0c;所以说现在入驻是最好的时…

ASP.NET邮件收发程序的设计与开发

摘 要 《邮件收发程序的设计与开发》是一个综合性的程序设计&#xff0c;涉及到界面、系统、数据库、协议、编码等多个方面的内容。本设计前台采用.NET技术,后台数据库采用SQL Server 2000&#xff0c;语言采用C#&#xff0c;主要讲述了邮件系统的注册、登陆、管理、发送和…

定时器的理论和使用

文章目录 一、定时器理论1.1定时器创建和使用 二、定时器实践2.1周期触发定时器2.2按键消抖 一、定时器理论 定时器是一种允许在特定时间间隔后或在将来的某个时间点调用回调函数的机制。对于需要周期性任务或延迟执行任务的嵌入式应用程序特别有用。 软件定时器&#xff1a; …

SpringBoot多模块项目MybatisPlus配置

项目目录 主模块配置 配置类 Configuration EnableTransactionManagement MapperScan("com.sms.**.mapper") public class MybatisPlugConfig {Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor mybatisPlusInterceptor new…

回复完成 输入框还显示值的问题

回复完成 输入框还显示值的问题 解决代码 先把id 值清空 再构建下这个输入框 $("#details_article_reply_content").val(""); // 清空textareavar editor editormd("article_details_reply", {width: "100%",height: "100%"…

网上有哪些赚钱的方法能一天赚二三十?盘点7个靠谱的搞钱副业和赚钱软件

想在家里躺着就能把钱赚&#xff1f;这不再是遥不可及的梦想&#xff01;随着互联网的飞速发展&#xff0c;网上赚钱的方式层出不穷&#xff0c;总有一款适合你。 今天&#xff0c;就让我们一起揭开这些神秘面纱&#xff0c;看看哪些网上赚钱秘诀能让你轻松实现月入过万&#x…