78、 ansible----playbook

news/2024/9/13 23:24:04/ 标签: ansible

ansible_0">一、ansible模块

11、防火墙和网络模块:

[root@test1 ~]# ansible 192.168.168.23 -m iptables -a 'chain=INPUT protocol=ICMP source=192.168.168.22 jump=REJECT' -b  ##-b后台,拒绝

在这里插入图片描述

[root@test3 ~]# yum -y install nginx[root@test3 ~]# systemctl restart nginx.service [root@test3 ~]# curl 192.168.168.23
this is nginx!
[root@test1 ~]# ansible 192.168.168.23 -m iptables -a 'chain=INPUT protocol=tcp destination_port=80 jump=REJECT' -b  ##80端口关闭,拒绝访问

删除防火墙策略

[root@test1 ~]# ansible 192.168.168.23 -m iptables -a 'chain=INPUT protocol=tcp destination_port=80 jump=REJECT state=absent' -b

在这里插入图片描述

[root@test1 ~]# ansible 192.168.168.23 -m iptables -a 'chain=INPUT protocol=tcp destination_port=80 jump=ACCEPT' -b  ##放开80端口

firewalld模块

[root@test3 ~]# systemctl start firewalld[root@test1 ~]# ansible 192.168.168.23 -m firewalld -a 'service=nginx zone=public permanent=true state=enabled immediate=true' -e[root@test3 ~]# firewall-cmd --get-services | grep nginx##查询不到nginx服务,不支持
[root@test3 ~]# firewall-cmd --get-services | grep http##查询http服务,支持#### service不支持nginx,启动端口80/tcp[root@test1 ~]# ansible 192.168.168.23 -m firewalld -a 'port=80/tcp zone=public permanent=true state=enabled immediate=true' -b

在这里插入图片描述

删除端口,防火墙策略

[root@test1 ~]# ansible 192.168.168.23 -m firewalld -a 'port=80/tcp zone=public permanent=true state=disabled immediate=true' -b

在这里插入图片描述

12、配置网卡

修改ip地址
[root@test1 ~]# ansible 192.168.168.22 -m ansible.builtin.lineinfile -a "path=/etc/sysconfig/network-scripts/ifcfg-ens33 regexp='^IPADDR' line='IPADDR=192.168.168.25'"
查看有没有改成功
[root@test2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
DEVICE=ens33
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.168.25  ##修改成功
NETMASK=255.255.255.0
GATEWAY=192.168.168.2
DNS1=218.2.135.1
DNS2=221.131.143.69
重启网卡
[root@test1 ~]# ansible 192.168.168.22 -a 'systemctl restart network'
回终端查看

在这里插入图片描述

ip地址改回为192.168.168.22
[root@test1 ~]# cd /etc/ansible/
[root@test1 ansible]# ls
ansible.cfg  hosts  roles  test2.sh
[root@test1 ansible]# vim hosts 192.168.168.25[root@test1 ansible]# ansible 192.168.168.25 -m ansible.builtin.lineinfile -a "path=/etc/sysconfig/network-scripts/ifcfg-ens33 regexp='^IPADDR' line='IPADDR=192.168.168.22'"[root@test1 ansible]# ansible 192.168.168.25 -a 'systemctl restart network'点击xshell,重新连接ifconfig

在这里插入图片描述

13、script模块:

运行的本地的脚本,把脚本运行的结果输出到目标主机。

[root@test1 ansible]# cd /opt/
[root@test1 opt]# vim test.sh
[root@test1 opt]# chmod 777 test.sh 
[root@test1 opt]# ansible 192.168.168.22 -m script -a '/opt/test.sh'[root@test1 ansible]# cd /opt/
[root@test1 opt]# vim test.sh#!/bin/bash
echo "hello world!" > /opt/test2.txt[root@test1 opt]# chmod 777 test.sh 
[root@test1 opt]# ansible 192.168.168.22 -m script -a '/opt/test.sh'[root@test2 ~]# cd /opt/
[root@test2 opt]# ls
jenkins-2.396-1.1.noarch.rpm  test  test2.txt
[root@test2 opt]# cat test2.txt
hello world!

运行的本地的脚本,把脚本运行的结果输出到目标主机。

[root@test1 opt]# cp test.sh test1.sh
[root@test1 opt]# vim test1.sh#!/bin/bash
ifconfig > /opt/test3.txt
free -h > /opt/test4.txt
df -h > /opt/test5.txt[root@test1 opt]# ansible 192.168.168.22 -m script -a '/opt/test1.sh'  ##脚本在本地,脚本里面的命令是在目标主机里面运行

在这里插入图片描述

14、setup模块:

查看目标主机的信息:ip地址,cpu,内核,系统信息。

[root@test1 opt]# ansible 192.168.168.22 -m setup

查看目标主机的cpu

[root@test1 opt]# ansible 192.168.168.22 -m setup -a 'filter=ansible_*processor*'

在这里插入图片描述

[root@test1 opt]# ansible 192.168.168.22 -m setup -a 'filter=ansible_processor'
查看内核版本
[root@test1 opt]# ansible 192.168.168.22 -m setup -a 'filter=ansible_proc_cmdline'
查看内存
[root@test1 opt]# ansible 192.168.168.22 -m setup -a 'filter=ansible_mem*'
查看系统信息
[root@test1 opt]# ansible 192.168.168.22 -m setup -a 'filter=ansible_system'

总结:

  • command和shell
  • copy,yum,user
  • service服务,对服务管理
  • file模块,文件的属性进行修改
  • hostname 改主机名
  • ping模块
指定端口

在这里插入图片描述

这种情况就不再需要传输密钥对,对目标主机生效

在这里插入图片描述

对目标组内所有主机都生效

在这里插入图片描述

利用拼接对web添加多个主机

192.168.168.[1:5] [0:9]

在这里插入图片描述
组嵌套

在这里插入图片描述

ansible_218">二、ansible的脚本:

playbook:剧本

2.1、playbook的组成:

1、Tasks 任务,每个Tasks 就是一个模块

2、variables 变量,存储和传递数据,可以自定义,也可以是全局变量,也可以是脚本外传参。

3、Templates模块,用于生成配置文件和多任务的编排。

4、handlers 处理器,用于满足某些条件时,触发的操作,一般用于重启等操作。

5、roles 角色 组织和封装剧本的过程,角色可以把任务、变量、模块、处理器,组合成一个可用单元。

2.1.1、安装httpd

[root@test1 opt]# vim test1.yaml- name: first play
#定义这个剧本的名称,可不写gather_facts: false
#在执行剧本之前是否收集目标主机的信息,false:不收集,可用加快执行速度,如果不写>,默认就是收集。hosts: 192.168.168.22
#指定目标主机,可以是组名,也可以是ip地址remote_user: root
#在目标主机的执行用户tasks:- name: test connection
#定义一个任务的名称,可以自定义ping:
#ping就是模块的名称- name: close selinuxcommand: '/sbin/setenforce 0'ignore_errors: true
# 如果在执行任务中报错,返回码非0,报错,task就会停止,ignore_errors:True就会忽略
错误,继续执行下一个任务- name: close firewalldservice: name=firewalld state=stopped
#调用service模块,关闭防火墙- name: install httpdyum: name=httpd state=latest
#latest,安装当前库中的最新版本的软件- name: interviewshell: echo "this is httpd" > /var/www/html/index.html
#指定shell模块。修改默认的访问页面notify: restart httpd
#ansible 在执行任务之后不会立即执行重启,通过notify指令对应的名称传给触发器,让触
发器在任务的最后执行重启,影响执行的效率handlers:- name: restart httpdservice: name=httpd state=restarted[root@test1 opt]# ansible-playbook test1.yaml 

在这里插入图片描述

在这里插入图片描述

2.1.2、安装nginx

#安装nginx,传一个配置文件到目标主机,修改默认端口为8080,访问页面的内容 this is nginx 安装方式yum

[root@test1 opt]# yum -y install nginx ##提前下载nginx,传出nginx.conf------在/etc/nginx/nginx.conf[root@test1 /]# cp /etc/nginx/nginx.conf /opt/nginx.conf[root@test1 opt]# vim nginx.conf 39         listen       8080;40         listen       [::]:8080;[root@test1 opt]# yum -y remove nginx[root@test1 opt]# vim test2.yaml- name: second play
#定义这个剧本的名称,可不写gather_facts: false
#在执行剧本之前是否收集目标主机的信息,false:不收集,可用加快执行速度,如果不写,默认就是收集。hosts: 192.168.168.22
#指定目标主机,可以是组名,也可以是ip地址remote_user: root
#在目标主机的执行用户tasks:- name: test2 connection
#定义一个任务的名称,可以自定义ping:
#ping就是模块的名称- name: close selinuxcommand: '/sbin/setenforce 0'ignore_errors: true
# 如果在执行任务中报错,返回码非0,报错,task就会停止,ignore_errors:True就会忽略错误,继续执行下一个任务- name: close firewalldservice: name=firewalld state=stopped
#调用service模块,关闭防火墙- name: install nginxyum: name=nginx state=latest
#latest,安装当前库中的最新版本的软件- name: interviewshell: echo "this is nginx" > /usr/share/nginx/html/index.html
#指定shell模块。修改默认的访问页面- name: nginx.confcopy: 'src=/opt/nginx.conf dest=/etc/nginx/nginx.conf'notify: restart nginx
#ansible 在执行任务之后不会立即执行重启,通过notify指令对应的名称传给触发器,让触发器在任务的最后执行重启,影响执行的效率handlers:- name: restart nginxservice: name=nginx state=restarted[root@test1 opt]# ansible-playbook test2.yaml 

在这里插入图片描述

访问测试

在这里插入图片描述

2.2、#定义变量,引用变量:#脚本当中定义参量

[root@test1 opt]# vim test3.yaml #定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: rootvars:groupname: mysqlusername: nginx1
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 306- name: create useruser:name: "{{ username }}"uid: 306group: "{{ groupname }}"[root@test1 opt]# ansible-playbook test3.yaml 

在这里插入图片描述

在这里插入图片描述

[root@test1 opt]# vim test3.yaml #定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: rootvars:groupname: mysqlusername: nginx1
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 16- name: create useruser:name: "{{ username }}"uid: 16group: "{{ groupname }}"[root@test1 opt]# ansible-playbook test3.yaml

在这里插入图片描述

在这里插入图片描述

[root@test2 opt]# yum -y remove nginx ##卸载软件,就可覆盖用户和组

在这里插入图片描述

#定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: rootbecome: yes
#先vars:groupname: mysqlusername: nginx
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 306- name: create useruser:name: "{{ username }}"uid: 306group: "{{ groupname }}"[root@test1 opt]# ansible-playbook test3.yaml

在这里插入图片描述

在这里插入图片描述

2.3、脚本外传参

[root@test1 opt]# ansible-playbook test4.yaml -e 'groupname=test1 username=test1'##脚本外面的优先级比里面高

[root@test1 opt]# vim test4.yaml#定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: rootbecome: yes
#先vars:groupname: mysqlusername: nginx
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 307- name: create useruser:name: "{{ username }}"uid: 307group: "{{ groupname }}"[root@test1 opt]# ansible-playbook test4.yaml -e 'groupname=test1 username=test1'

在这里插入图片描述

在这里插入图片描述

2.4、检查脚本的语法

1、检查脚本语法

[root@test1 opt]# ansible-playbook test3.yaml --syntax-check

2、检查脚本里面的任务个数

[root@test1 opt]# ansible-playbook test3.yaml --list-task

在这里插入图片描述

3、检查对哪些主机生效

[root@test1 opt]# ansible-playbook test3.yaml --list-hosts

在这里插入图片描述

4、指定位置运行

[root@test1 opt]# ansible-playbook test3.yaml --start-at-task='create user' -e 'username=test3 groupname=mysql'  ##此脚本中,组需要存在

在这里插入图片描述

cat /etc/passwd ##查看用户

cat /etc/group ##查看组

[root@test1 opt]# vim test4.yaml #定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: rootbecome: yes
#先vars:groupname: mysqlusername: nginx
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 307- name: create useruser:name: "{{ username }}"uid: 308group: "{{ groupname }}"[root@test1 opt]# ansible-playbook test3.yaml --start-at-task='create user' -e 'username=test3 groupname=mysql'  ##此脚本中,组需要存在

在这里插入图片描述

5、切换用户

#定义变量,引用变量:
#脚本当中定义,以及脚本外传参
- name: second playhosts: 192.168.168.22remote_user: dnbecome: yes
#先用普通用户执行,但是需要切换到其他的用户,例如切换到管理员become_user: rootvars:groupname: mysqlusername: nginx
#定义变量:tasks:- name: create groupgroup:name: "{{ groupname }}"system: yesgid: 307- name: create useruser:name: "{{ username }}"uid: 308group: "{{ groupname }}"

2.5、#如何在脚本中实现条件判断:

#when 满足条件的主机执行,不满足的跳过

[root@test1 opt]# vim test5.yaml #如何在脚本中实现条件判断:
#when 满足条件的主机执行,不满足的跳过
- name: this is ifhosts: allremote_user: roottasks:- name: test whendebug: msg='条件满足'
#debug相当于echo echo "条件满足"when: ansible_default_ipv4.address == "192.168.168.22"[root@test1 opt]# ansible-playbook test5.yaml##取反,除了192.168.168.22都执行[root@test1 opt]# vim test5.yaml #如何在脚本中实现条件判断:
#when 满足条件的主机执行,不满足的跳过
- name: this is ifhosts: allremote_user: roottasks:- name: test whendebug: msg='条件满足'
#debug相当于echo echo "条件满足"when: ansible_default_ipv4.address != "192.168.168.22"   ##取反,除了192.168.168.22都执行

2.6、循环结构

[root@test1 opt]# vim test6.yaml #循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_items: [a,b,c,d]
#输出item的值,with_items:a b c d 依次传入      [root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_items:- [a,b,c,d]- [1,2,3,4]
#输出item的值,with_items:a b c d 依次传入
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_list:- [a,b,c,d]- [1,2,3,4]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_together:- [a,b,c,d]- [1,2,3,4]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_together:- [a,b,c,d]- [1,2,3,4]- [A,B,C]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_nested:- [a,b,c,d]- [1,2,3,4]- [A,B,C]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_nested:- [a,b,c,d]- [1,2,3,4]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
[root@test1 opt]# ansible-playbook test6.yaml#循环结构:absible有多种循环方式,一般都命名为with_items,定义循环的内容。#with_item 单循环输出:- name: item testhosts: 192.168.168.22remote_user: rootgather_facts: falsetasks:- debug:msg: "{{item}}"with_nested:- [a,b,c,d]- [1,2,3,4]
#输出item的值,with_items:a b c d 依次传入
#with_list,整个列表作为一个整体,进行输出
#with_together,作为整体,以列两两配对输出
#with_nested:每一层都是遍历执行一遍,输出结束
#条件判断,主机的ip
#才会执行,一次性创建4个文件,/opt/a /opt/b /opt/c /opt/d 循环 with_items
[root@test1 opt]# ansible-playbook test6.yaml

#条件判断,主机的ip
#才会执行,一次性创建4个文件,/opt/a /opt/b /opt/c

[root@test1 opt]# vim test11.yaml - name: file testhosts: allremote_user: roottasks:- name: file whenfile:path: "{{ item }}"state: touchwith_items: [/opt/a,/opt/b,/opt/c,/opt/d]when: ansible_default_ipv4.address == "192.168.168.22"[root@test1 opt]# ansible-playbook test11.yaml
[root@test2 opt]# ls
a  c  jenkins-2.396-1.1.noarch.rpm  test2.txt  test4.txt
b  d  test                          test3.txt  test5.txt

http://www.ppmy.cn/news/1516177.html

相关文章

计算机毕业设计pyspark+django+scrapy租房推荐系统 租房大屏可视化 租房爬虫 hadoop 58同城租房爬虫 房源推荐系统

用到的技术: 1. python 2. django后端框架 3. django-simpleui,Django后台 4. vue前端 5. element-plus,vue的前端组件库 6. echarts前端可视化库 7. scrapy爬虫框架 基于大数据的租房信息推荐系统包括以下功能&#xff1a…

普通项目解决跨域问题和springSecurity解决跨域问题

普通项目解决跨域问题 添加一个配置文件 package com.lzy.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration; import org.springframewor…

青龙面板本地部署流程结合内网穿透使用手机远程本地服务器薅羊毛

文章目录 前言一、前期准备本教程环境为:Centos7,可以跑Docker的系统都可以使用。本教程使用Docker部署青龙,如何安装Docker详见: 二、安装青龙面板三、映射本地部署的青龙面板至公网四、使用固定公网地址访问本地部署的青龙面板 …

P2P 文件共享:现代网络中的高效文件传输

在互联网的世界中,不同应用程序的数据传输方法各异。P2P文件共享(Peer-to-Peer File Sharing) 作为一种高效的文件传输方式,使得用户可以在没有中央服务器的情况下直接进行文件交换。本文将详细介绍P2P文件共享的基本原理、优势及…

【游戏速递】 小猪冲刺:萌动指尖的极速挑战,小虎鲸Scratch资源站独家献映!

在线玩:Scratch小猪冲刺:全新挑战的几何冒险游戏-小虎鲸Scratch资源站 想象一下,一群憨态可掬的小猪,穿上炫酷的装备,踏上了追逐梦想的赛道。它们或跳跃、或滑行,灵活躲避各种障碍,只为那终点的…

【经验分享】CANOPEN协议驱动移植(基于CANfestival源码架构)

【经验分享】CANOPEN协议驱动移植(基于CANfestival源码架构) 前言一、CANOPEN整体实现原理二、CANOPEN驱动收发三、Timer定时器四、Object Dictionary对象字典五、CANOPEN应用层接口六、CANOPEN 驱动移植经验总结 前言 本次CANOPEN移植基于CANfestival开源代码&…

知识图谱问答召回机制-llm-graph-builder

背景 以Neo4j开源的 llm-graph-builder (以下简称 LGB)为例,说明 graph RAG的模式下,如何进行知识的召回操作。 原理说明 graph RAG模式下,依旧保持了RAG的思想,使用了向量作为语义召回的手段。 在 L…

leetcode738:单调递增的数字

单调递增的数字 当且仅当每个相邻位数上的数字 x 和 y 满足 x < y 时&#xff0c;我们称这个整数是单调递增的。 给定一个整数 n &#xff0c;返回 小于或等于 n 的最大数字&#xff0c;且数字呈 单调递增 。 public int monotoneIncreasingDigits(int n) {if(n<10){r…

Expo 开发ReactNative 后切换 eas 账号

修改slug app.json中的sulg字段更新为新账号应用sulg 修改projectId app.json中的extra.eas.projectId字段更新为新账号应用projectId 退出账号&#xff1a; eas logout 重新登录&#xff1a; eas login

算法笔记|Day34动态规划VII

算法笔记|Day34动态规划VII ☆☆☆☆☆leetcode 198.打家劫舍题目分析代码 ☆☆☆☆☆leetcode 213.打家劫舍II题目分析代码 ☆☆☆☆☆leetcode 337.打家劫舍 III题目分析代码 ☆☆☆☆☆leetcode 198.打家劫舍 题目链接&#xff1a;leetcode 198.打家劫舍 题目分析 1.dp数…

系规学习第20天

1.过程要素管理&#xff08;几包试问 配变法案莲蓉&#xff09;&#xff1a; 对流程的执行、监控与调优是至关重要的&#xff0c;包括服务级别管理、服务报告管理、事件管理、问题管理、配置管理、变更管理、发布管理、安全管理&#xff0c;进行有效的支持并确保执行。 2. 服务…

异步编排利器:使用CompletableFuture优化服务页面响应速度

文章目录 1、什么是CompletableFuture异步编排&#xff1f;1.1、问题背景1.2、为什么使用CompletableFuture&#xff1f; 2、如何使用CompletableFuture进行异步编排&#xff1f;2.1、创建异步任务2.2、任务的串行执行2.3、多任务组合2.4、代码示例 3、总结 在如今的互联网应用…

Python基础—Python保护代码和数据的方法

保护代码和数据的安全性至关重要。无论是防止代码被轻易修改&#xff0c;还是确保数据的隐私与完整性&#xff0c;采取适当措施都是必不可少的。今天&#xff0c;我们就来揭开六大保护策略的神秘面纱&#xff0c;让初学者也能轻松掌握这些实用技巧。 1. 使用加密技术保护敏感…

每日掌握一个科研插图·2D密度图|24-08-21

小罗碎碎念 在统计学和数据可视化领域&#xff0c;探索两个定量变量之间的关系是一种常见的需求。为了更深入地理解这种关系&#xff0c;我们可以使用多种图形表示方法&#xff0c;这些方法在本质上是对传统图形的扩展和变体。 散点图&#xff1a;这是最基本的图形&#xff0c…

【Linux网络】CGI技术

欢迎来到 破晓的历程的 博客 ⛺️不负时光&#xff0c;不负己✈️ 文章目录 一、CGI技术概述二、CGI技术的工作原理三、CGI技术的特点四、CGI技术的局限性和发展趋势五、CGI技术的安全性措施 一、CGI技术概述 CGI&#xff08;Common Gateway Interface&#xff09;是一种用于…

专题---自底向上的计算机网络(数据链路层)

目录 计算机网络概述 物理层 数据链路层 网络层 传输层 应用层 网络安全 集线器与交换机的主要区别。 ‌工作原理与层次‌&#xff1a;集线器工作在OSI模型的物理层&#xff0c;可以看作是1层设备&#xff0c;而交换机主要工作在数据链路层&#xff0c;可以看作是2层设备…

系统编程-lvgl

带界面的MP3播放器 -- lvgl 目录 带界面的MP3播放器 -- lvgl 一、什么是lvgl&#xff1f; 二、简单使用lvgl 在工程中编写代码 实现带界面的mp3播放器 main.c events_init.c events_init.h 补充1&#xff1a;glob函数 补充2&#xff1a;atexit函数 一、什么是lvgl&a…

Spring Boot项目中集成Geth与以太坊区块链进行交互操作实例

前置条件已经安装Geth并启动。 现在我们讲一下Spring Boot项目中集成Geth&#xff0c;然后怎么以太坊区块链进行交互操作。 1、添加依赖到工程pom.xml <dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <versi…

SpringBoot集成kafka-生产者发送消息

springboot集成kafka发送消息 1、kafkaTemplate.send()方法1.1、springboot集成kafka发送消息Message对象消息1.2、springboot集成kafka发送ProducerRecord对象消息1.3、springboot集成kafka发送指定分区消息 2、kafkaTemplate.sendDefault()方法3、kafkaTemplate.send(...)和k…

微信小程序: including tag name selectors, ID selectors, and at

微信小程序报错&#xff1a; Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors. 1、组件和引用组件的页面不能使用 id 选择器&#xff08;#a&#xff09;、属性选择器&#xff08;[a]&#xff09;和标…