当前位置: 首页 > news >正文

中间件:maxwell、canal

文章目录

  • 1、底层原理:基于mysql的bin log日志实现的:把自己伪装成slave
  • 2、bin log 日志有三种模式:
    • 2.1、statement模式:
    • 2.2、row模式:
    • 2.3、mixed模式:
  • 3、maxwell只支持 row 模式:
  • 4、maxwell介绍
  • 5、maxwell入门
  • 6、拉取maxwell镜像命令如下
  • 7、配置数据库mysql
    • 7.1、在/var/lib/docker/volumes/mysql_conf/_data目录下创建 my.cnf
    • 7.2、查看 my.cnf
    • 7.3、编辑 my.cnf
    • 7.4、mysql 中创建 maxwell 用户
      • 7.4.1、在 docker 中连接 mysql
      • 7.4.2、创建 maxwell 用户
      • 7.4.3、授权用户maxwell从任何主机(%代表任何主机)连接到MySQL服务器,并对名为maxwell的数据库拥有所有权限(ALL)
      • 7.4.4、授权用户maxwell从任何主机(%代表任何主机)连接到MySQL服务器,并赋予它三个特定的权限:SELECT、REPLICATION CLIENT和REPLICATION SLAVE
  • 8、重启 mysql
  • 9、启动一个名为 zendesk/maxwell 的 Docker 容器,并配置 Maxwell 以监听 MySQL 数据库的变化并将这些变化输出到标准输出(stdout)
  • 10、修改 tingshu_album 数据库
  • 11、Maxwell正常关闭所有任务

1、底层原理:基于mysql的bin log日志实现的:把自己伪装成slave

在这里插入图片描述

  1. 所有的写操作到master主机,master会记录数据变化到 bin log 日志
  2. slave会通过 IO 线程 通过slave用户和master建立链接,并拉取bin log 日志的内容记录到自己的 relay log 中
  3. slave通过sql 线程 读取 relay log 中的内容进行 replay 重演重做,进而完成数据同步

2、bin log 日志有三种模式:

2.1、statement模式:

把 sql 语句记录到 bin log 日志。问题:当sql中有系统函数时,就会出现数据不一致。

2.2、row模式:

把变化后的数据记录到 bin log 日志。解决数据不一致问题,问题:批量操作时,使日志很大。

2.3、mixed模式:

智能选择适合的模式记录到 bin log 日志。当有系统函数时会自动选择row模式,当有批量操作时自动选择statement模式(推荐)。

3、maxwell只支持 row 模式:

会通过row模式获取 bin log 修改后的数据转化成 json 输出

4、maxwell介绍

maxwell的github地址:https://github.com/zendesk/maxwell

在这里插入图片描述
maxwells官网:https://maxwells-daemon.io/
在这里插入图片描述
Quick Start - Maxwell’s Daemon:https://maxwells-daemon.io/quickstart/

在这里插入图片描述

5、maxwell入门

在这里插入图片描述

6、拉取maxwell镜像命令如下

[root@localhost docker]# docker pull zendesk/maxwell
Using default tag: latest
latest: Pulling from zendesk/maxwell
1efc276f4ff9: Pull complete 
a2f2f93da482: Pull complete 
12cca292b13c: Pull complete 
69e15dccd787: Pull complete 
79219af6aa7c: Pull complete 
f39f1bdf1c84: Pull complete 
3261018f1785: Pull complete 
4f4fb700ef54: Pull complete 
be1353da9f00: Pull complete 
627d862c87f8: Pull complete 
Digest: sha256:68d51e27b6de2315ea710c0fe88972d4bd246ffb2519c82a49aa90a980d6cf64
Status: Downloaded newer image for zendesk/maxwell:latest
docker.io/zendesk/maxwell:latest

7、配置数据库mysql

在这里插入图片描述

# /etc/my.cnf[mysqld]
# maxwell needs binlog_format=row
binlog_format=row
server_id=1 
log-bin=master
[root@localhost etc]# docker inspect spzx-mysql
        "Mounts": [{"Type": "volume","Name": "mysql_data","Source": "/var/lib/docker/volumes/mysql_data/_data","Destination": "/var/lib/mysql","Driver": "local","Mode": "z","RW": true,"Propagation": ""},{"Type": "volume","Name": "mysql_conf","Source": "/var/lib/docker/volumes/mysql_conf/_data","Destination": "/etc/mysql","Driver": "local","Mode": "z","RW": true,"Propagation": ""}],
/var/lib/docker/volumes/mysql_conf/_data

7.1、在/var/lib/docker/volumes/mysql_conf/_data目录下创建 my.cnf

[root@localhost ~]# cd /var/lib/docker/volumes/mysql_conf/_data
[root@localhost _data]# ll
总用量 8
drwxrwxr-x. 2 root root   41 1226 2023 conf.d
-rw-rw-r--. 1 root root 1543 913 17:35 my.cnf
-rw-r--r--. 1 root root 1448 928 2021 my.cnf.fallback

此时发现已经有文件 my.cnf,这个文件是我在搭建mysql主从复制时创建的。

7.2、查看 my.cnf

[root@localhost _data]# cat my.cnf
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html[mysqld]
# 服务器唯一id,默认值1
server-id=1
# # 设置日志格式,默认值ROW。row(记录行数据)  statement(记录sql)  mixed(混合模式)
binlog_format=STATEMENT
# # 二进制日志名,默认binlog
# # log-bin=binlog
log-bin=spzxbinlog
# # 设置需要复制的数据库,默认复制全部数据库
binlog-do-db=mydb2
binlog-do-db=mydb3
# # 设置不需要复制的数据库
binlog-ignore-db=mydb4
# #binlog-ignore-db=infomation_schema
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL# Custom config should go here
!includedir /etc/mysql/conf.d/

7.3、编辑 my.cnf

[mysqld]
# 服务器唯一id,默认值1
server-id=1
# # 设置日志格式,默认值ROW。row(记录行数据)  statement(记录sql)  mixed(混合模式)
binlog_format=row
# # 二进制日志名,默认binlog
# # log-bin=binlog
log-bin=spzxbinlog
# # 设置需要复制的数据库,默认复制全部数据库
binlog-do-db=mydb2
binlog-do-db=mydb3
binlog-do-db=tingshu_album
# # 设置不需要复制的数据库
binlog-ignore-db=mydb4
binlog-ignore-db=mysql
binlog-ignore-db=sys
binlog-ignore-db=performance_schema
binlog-ignore-db=information_schema
# #binlog-ignore-db=infomation_schema
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL# Custom config should go here
!includedir /etc/mysql/conf.d/

7.4、mysql 中创建 maxwell 用户

mysql> CREATE USER 'maxwell'@'%' IDENTIFIED BY 'XXXXXX';
mysql> CREATE USER 'maxwell'@'localhost' IDENTIFIED BY 'XXXXXX';mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'%';
mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'localhost';mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'localhost';

7.4.1、在 docker 中连接 mysql

[root@localhost _data]# docker exec -it spzx-mysql /bin/bash
root@ab66508d9441:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.27 MySQL Community Server - GPLCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

7.4.2、创建 maxwell 用户

mysql> CREATE USER 'maxwell'@'%' IDENTIFIED BY 'maxwell';
Query OK, 0 rows affected (0.11 sec)

7.4.3、授权用户maxwell从任何主机(%代表任何主机)连接到MySQL服务器,并对名为maxwell的数据库拥有所有权限(ALL)

mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'%';
Query OK, 0 rows affected (0.01 sec)

7.4.4、授权用户maxwell从任何主机(%代表任何主机)连接到MySQL服务器,并赋予它三个特定的权限:SELECT、REPLICATION CLIENT和REPLICATION SLAVE

mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
Query OK, 0 rows affected (0.01 sec)

8、重启 mysql

[root@localhost _data]# docker restart spzx-mysql 
spzx-mysql

9、启动一个名为 zendesk/maxwell 的 Docker 容器,并配置 Maxwell 以监听 MySQL 数据库的变化并将这些变化输出到标准输出(stdout)

在这里插入图片描述

docker run -it --rm zendesk/maxwell bin/maxwell --user=$MYSQL_USERNAME \--password=$MYSQL_PASSWORD --host=$MYSQL_HOST --producer=stdout
docker run -it --rm zendesk/maxwell bin/maxwell --user=maxwell \--password=maxwell --host=192.168.74.148 --port=3306 --producer=stdout
[root@localhost _data]# docker run -it --rm zendesk/maxwell bin/maxwell --user=maxwell \
>     --password=maxwell --host=192.168.74.148 --port=3306 --producer=stdout
2024-09-19 09:08:15 INFO  Maxwell - Starting Maxwell. maxMemory: 1031798784 bufferMemoryUsage: 0.25
2024-09-19 09:08:15 INFO  SchemaStoreSchema - Creating maxwell database
2024-09-19 09:08:15 INFO  Maxwell - Maxwell v1.41.2 is booting (StdoutProducer), starting at Position[BinlogPosition[spzxbinlog.000003:156], lastHeartbeat=0]
2024-09-19 09:08:16 INFO  AbstractSchemaStore - Maxwell is capturing initial schema
2024-09-19 09:08:17 INFO  BinlogConnectorReplicator - Setting initial binlog pos to: spzxbinlog.000003:156
2024-09-19 09:08:17 INFO  BinaryLogClient - Connected to 192.168.74.148:3306 at spzxbinlog.000003/156 (sid:6379, cid:23)
2024-09-19 09:08:17 INFO  BinlogConnectorReplicator - Binlog connected.
2024-09-19 09:08:15 INFO  SchemaStoreSchema - Creating maxwell database

在这里插入图片描述

10、修改 tingshu_album 数据库

在这里插入图片描述
在这里插入图片描述

[root@localhost _data]# docker run -it --rm zendesk/maxwell bin/maxwell --user=maxwell \
>     --password=maxwell --host=192.168.74.148 --port=3306 --producer=stdout
2024-09-19 09:08:15 INFO  Maxwell - Starting Maxwell. maxMemory: 1031798784 bufferMemoryUsage: 0.25
2024-09-19 09:08:15 INFO  SchemaStoreSchema - Creating maxwell database
2024-09-19 09:08:15 INFO  Maxwell - Maxwell v1.41.2 is booting (StdoutProducer), starting at Position[BinlogPosition[spzxbinlog.000003:156], lastHeartbeat=0]
2024-09-19 09:08:16 INFO  AbstractSchemaStore - Maxwell is capturing initial schema
2024-09-19 09:08:17 INFO  BinlogConnectorReplicator - Setting initial binlog pos to: spzxbinlog.000003:156
2024-09-19 09:08:17 INFO  BinaryLogClient - Connected to 192.168.74.148:3306 at spzxbinlog.000003/156 (sid:6379, cid:23)
2024-09-19 09:08:17 INFO  BinlogConnectorReplicator - Binlog connected.
{"database":"tingshu_album","table":"album_info","type":"update","ts":1726737222,"xid":1315,"commit":true,"data":{"id":1,"user_id":1,"album_title":"《夜色钢琴曲》maxwell","category3_id":1018,"album_intro":"《夜色钢琴曲》最新专辑上线啦 我的新专辑《夜色钢琴曲 最新专辑》(点击跳转)已经上线,新专辑是《夜...","cover_url":"https://imagev2.xmcdn.com/storages/b3d2-audiofreehighqps/91/8E/GMCoOSAFquG2AAU4zwEKNohZ.png","include_track_count":54,"is_finished":"0","estimated_track_count":164,"album_rich_intro":"<p data-flag=\"normal\" style=\"line-height:30px;font-family:Helvetica, Arial, sans-serif;\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><span data-flag=\"tag\" style=\"padding:5px;margin:10px 0px;color:rgb(255, 255, 255);display:inline-block;\">《夜色钢琴曲》最新专辑上线啦</span> </strong></p><p style=\"color:#333333;font-weight:normal;font-size:16px;line-height:30px;font-family:Helvetica,Arial,sans-serif;hyphens:auto;text-align:left;\" lang=\"en\" data-flag=\"normal\">我的新专辑<a href=\"https://www.ximalaya.com/yinyue/35219974/\" style=\"color:#4990E2;text-decoration:none;\"><b>《夜色钢琴曲 最新专辑》</b></a>(点击跳转)已经上线,新专辑是《夜色钢琴曲》的升级版,我精选了诸多经典原创作品与大家分享,愿未来的每一个夜晚,大家在钢琴曲的陪伴下,能够卸下身体的浮躁与焦虑,内心不再孤单与慌张。</p><span><br /></span><p data-flag=\"normal\" style=\"line-height:30px;font-family:Helvetica, Arial, sans-serif;text-align:justify;\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><span data-flag=\"strong\" style=\"word-break:break-all;\">赵海洋出生于1988年3月31日,专业的钢琴、作曲、编曲、钢琴教师、作品轻盈舒畅,委婉通透,曲曲经典,让人沐在他的音乐月光下,洗涤凡尘心垢。相关曲谱高清音乐某宝搜索:8919005,微博:夜色钢琴赵海洋</span></strong></p><p data-flag=\"normal\" style=\"font-size:16px;line-height:30px;font-family:Helvetica, Arial, sans-serif;color:rgb(51, 51, 51);font-weight:normal;text-align:left;\" lang=\"en\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><img data-key=\"0\" src=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_large.jpg\" alt=\"\" data-origin=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333.jpg\" data-large=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_large.jpg\" data-large-width=\"750\" data-large-height=\"500\" data-preview=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_small.jpg\" data-preview-width=\"140\" data-preview-height=\"93\" /><br /><br /></strong></p>","quality_score":0.00,"pay_type":"0101","price_type":"0201","price":0.00,"discount":-1.0,"vip_discount":-1.0,"tracks_for_free":0,"seconds_for_free":0,"buy_notes":null,"selling_point":null,"is_open":"1","status":"0301","create_time":"2023-04-04 09:05:02","update_time":"2024-09-19 09:13:42","is_deleted":1},"old":{"album_title":"《夜色钢琴曲》1","update_time":"2024-04-24 11:18:48"}}

在这里插入图片描述

{"database": "tingshu_album","table": "album_info","type": "update","ts": 1726737222,"xid": 1315,"commit": true,"data": {"id": 1,"user_id": 1,"album_title": "《夜色钢琴曲》maxwell","category3_id": 1018,"album_intro": "《夜色钢琴曲》最新专辑上线啦 我的新专辑《夜色钢琴曲 最新专辑》(点击跳转)已经上线,新专辑是《夜...","cover_url": "https://imagev2.xmcdn.com/storages/b3d2-audiofreehighqps/91/8E/GMCoOSAFquG2AAU4zwEKNohZ.png","include_track_count": 54,"is_finished": "0","estimated_track_count": 164,"album_rich_intro": "<p data-flag=\"normal\" style=\"line-height:30px;font-family:Helvetica, Arial, sans-serif;\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><span data-flag=\"tag\" style=\"padding:5px;margin:10px 0px;color:rgb(255, 255, 255);display:inline-block;\">《夜色钢琴曲》最新专辑上线啦</span> </strong></p><p style=\"color:#333333;font-weight:normal;font-size:16px;line-height:30px;font-family:Helvetica,Arial,sans-serif;hyphens:auto;text-align:left;\" lang=\"en\" data-flag=\"normal\">我的新专辑<a href=\"https://www.ximalaya.com/yinyue/35219974/\" style=\"color:#4990E2;text-decoration:none;\"><b>《夜色钢琴曲 最新专辑》</b></a>(点击跳转)已经上线,新专辑是《夜色钢琴曲》的升级版,我精选了诸多经典原创作品与大家分享,愿未来的每一个夜晚,大家在钢琴曲的陪伴下,能够卸下身体的浮躁与焦虑,内心不再孤单与慌张。</p><span><br /></span><p data-flag=\"normal\" style=\"line-height:30px;font-family:Helvetica, Arial, sans-serif;text-align:justify;\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><span data-flag=\"strong\" style=\"word-break:break-all;\">赵海洋出生于1988年3月31日,专业的钢琴、作曲、编曲、钢琴教师、作品轻盈舒畅,委婉通透,曲曲经典,让人沐在他的音乐月光下,洗涤凡尘心垢。相关曲谱高清音乐某宝搜索:8919005,微博:夜色钢琴赵海洋</span></strong></p><p data-flag=\"normal\" style=\"font-size:16px;line-height:30px;font-family:Helvetica, Arial, sans-serif;color:rgb(51, 51, 51);font-weight:normal;text-align:left;\" lang=\"en\"><strong style=\"color: rgb(252, 88, 50); word-break: break-all; font-family: Helvetica, Arial, sans-serif; font-weight: normal;\"><img data-key=\"0\" src=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_large.jpg\" alt=\"\" data-origin=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333.jpg\" data-large=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_large.jpg\" data-large-width=\"750\" data-large-height=\"500\" data-preview=\"http://fdfs.xmcdn.com/group28/M05/5E/06/wKgJXFknzliyDqDtAAMkXHYILXQ333_mobile_small.jpg\" data-preview-width=\"140\" data-preview-height=\"93\" /><br /><br /></strong></p>","quality_score": 0,"pay_type": "0101","price_type": "0201","price": 0,"discount": -1,"vip_discount": -1,"tracks_for_free": 0,"seconds_for_free": 0,"buy_notes": null,"selling_point": null,"is_open": "1","status": "0301","create_time": "2023-04-04 09:05:02","update_time": "2024-09-19 09:13:42","is_deleted": 1},"old": {"album_title": "《夜色钢琴曲》1","update_time": "2024-04-24 11:18:48"}
}

11、Maxwell正常关闭所有任务

^C2024-09-19 09:31:56 INFO  MaxwellContext - Sending final heartbeat: 1726738316328
2024-09-19 09:32:01 WARN  MaxwellContext - Timed out waiting for heartbeat 1726738316328
2024-09-19 09:32:01 INFO  TaskManager - Stopping 3 tasks
2024-09-19 09:32:01 INFO  TaskManager - Stopping: com.zendesk.maxwell.schema.PositionStoreThread@7ff21fb0
2024-09-19 09:32:01 INFO  TaskManager - Stopping: com.zendesk.maxwell.bootstrap.BootstrapController@2ea6c604
2024-09-19 09:32:01 INFO  TaskManager - Stopping: com.zendesk.maxwell.replication.BinlogConnectorReplicator@24625899
2024-09-19 09:32:01 INFO  BinlogConnectorReplicator - Binlog disconnected.
2024-09-19 09:32:01 INFO  TaskManager - Stopped all tasks

相关文章:

中间件:maxwell、canal

文章目录 1、底层原理&#xff1a;基于mysql的bin log日志实现的&#xff1a;把自己伪装成slave2、bin log 日志有三种模式&#xff1a;2.1、statement模式&#xff1a;2.2、row模式&#xff1a;2.3、mixed模式&#xff1a; 3、maxwell只支持 row 模式&#xff1a;4、maxwell介…...

postman控制变量和常用方法

1、添加环境&#xff1a; 2、环境添加变量&#xff1a; 3、配置不同的环境&#xff1a;local、dev、sit、uat、pro 4、 接口调用 5、清除cookie方法&#xff1a; 6、下载文件方法&#xff1a;...

Spring Boot 中整合 Kafka

在 Spring Boot 中整合 Kafka 非常简单&#xff0c;Spring Kafka 提供了丰富的支持&#xff0c;使得我们可以轻松地实现 Kafka 的生产者和消费者。下面是一个简单的 Spring Boot 整合 Kafka 的示例。 1. 添加依赖 首先&#xff0c;在 pom.xml 中添加 Spring Kafka 的依赖&#…...

什么是开放式耳机?具有什么特色?非常值得入手的蓝牙耳机推荐

开放式耳机是当下较为热门的一种耳机类型。它具有以下特点&#xff1a; 设计结构&#xff1a; 呈现开放式的构造&#xff0c;不会完全堵住耳道。如此一来&#xff0c;外界声音能够较容易地被使用者听到&#xff0c;在使用耳机时可以保持对周围环境的察觉。比如在户外&#xf…...

编译 FFmpeg 以支持 AV1 编解码器以及其他硬件加速选项(如 NVENC、VAAPI 等)

步骤 1: 安装必要的依赖 sudo apt update sudo apt install -y \autoconf automake build-essential cmake git libass-dev libfreetype6-dev \libsdl2-dev libtool libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev \libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-…...

解释一下Java中的多线程。如何创建一个新的线程?

在Java中&#xff0c;多线程是一种机制&#xff0c;允许一个程序同时执行多个任务或处理。每个任务被称为一个线程。 这种并行执行可以极大地提高应用程序的效率和响应速度。 例如&#xff0c;在开发一个桌面应用程序时&#xff0c;你可以使用一个线程来更新用户界面&#xf…...

Java语言程序设计基础篇_编程练习题**18.30 (找出单词)

题目&#xff1a;**18.30 (找出单词) 编写一个程序&#xff0c;递归地找出某个目录下的所有文件中某个单词出现的次数。从命令行如下传递参数&#xff1a; java Exercise18_30 dirName word 习题思路 &#xff08;读取路径方法&#xff09;和18.28题差不多&#xff0c;把找…...

MyBatis中 #{} 和 ${} 的区别

1. #{id}&#xff08;参数占位符&#xff09; 作用: 使用 #{id} 时&#xff0c;MyBatis 会将 id 参数绑定为 JDBC 的参数。这种方式能够有效防止 SQL 注入攻击&#xff0c;因为它会进行参数的预处理&#xff0c;将参数值作为数据类型的绑定&#xff0c;而不是直接插入到 SQL 语…...

Android Perfetto 学习

1、如何抓取性能日志 方式1、通过手机里的System Tracing抓取 1、点击Settings->System->Developer options->System Tracing->Record trace 打开 2、操作完成后&#xff0c;点击Settings->System->Developer options->System Tracing->Record trace…...

ES数据的删除与备份

背景 需要删除索引下满足指定条件的文档数据&#xff0c;并将删除的数据进行备份。 操作步骤 新建索引 该索引结构与映射关系与原索引一致 查看原索引设置 GET /tb/_settings结果&#xff1a; {"tb" : {"settings" : {"index" : {"ro…...

论文解读《Object-Centric Learning with Slot Attention》

系列文章目录 文章目录 系列文章目录论文细节理解 1. 研究背景2. 论文贡献3. 方法框架3.1 Slot Attention模块3.2 无监督对象发现架构 4. 研究思路5. 实验6. 限制 论文细节理解 supervised property prediction tasks是什么&#xff1f; Supervised property prediction tasks…...

YOLOv8+注意力机制+PyQt5玉米病害检测系统完整资源集合

资源包含可视化的玉米病害检测系统&#xff0c;基于最新的YOLOv8注意力机制训练的玉米病害检测模型&#xff0c;和基于PyQt5制作的可视玉米病害系统&#xff0c;包含登陆页面和检测页面&#xff0c;该系统可自动检测和识别图片或视频当中出现的七类玉米病害&#xff1a;矮花叶病…...

tcp、udp通信调试工具Socket Tool

tcp、udp通信调试工具Socket Tool ]...

MedPrompt:基于提示工程的医学诊断准确率优化方法

Medprompt&#xff1a;基于提示工程的医学诊断准确率优化方法 秒懂大纲解法拆解MedPrompt 提示词全流程分析总结创意视角 论文&#xff1a;Can Generalist Foundation Models Outcompete Special-Purpose Tuning? Case Study in Medicine 秒懂大纲 ├── 1 研究背景【描述背…...

关于ollama 在mac的部署问题

安装 官网链接 直接按需求下载即可 默认模型下载地址 macOS: ~/.ollama/models Linux: /usr/share/ollama/.ollama/models Windows: C:\Users<username>.ollama\models 根据需要的平台设置相应的环境变量&#xff1a; OLLAMA_MODELS 如Mac 设置 &#xff5e;/.zshrc …...

职业技能大赛-单元测试笔记(assertThat)分享

前言 assertThat 是一种用于编写测试断言的方法,广泛应用于 Java 及其他编程语言的测试框架中,如 JUnit 和 AssertJ。它特别强调可读性和流畅性,使得测试代码更加直观易懂,从而提高了开发者在编写和维护测试时的效率。传统的断言方法通常以较为简洁但不够清晰的形式出现,例…...

AI大模型:OpenAI o1或能成为引领AI Phenomenal Ride的LLM新范式

OpenAI 发布 o1 系列大模型&#xff0c;AI 大模型进入新纪元**。**9 月 12 日&#xff0c;OpenAI 宣布开发了一系列全新AI 模型&#xff0c;其被命名为 OpenAI o1-preview&#xff0c;旨在在回应前投入更多时间思考。与之前的模型相比&#xff0c;这些模型能够更好地进行推理&a…...

天命人,如何轻松利用仿真技术打造出属于你的“金箍棒”?

近期&#xff0c;一款以西游记为背景的国产游戏&#xff0c;‌重塑了悟空这一经典角色&#xff0c;‌将其置于一个黑暗、‌魔幻的世界中。同时也是国内第一款 3A 游戏大作&#xff0c;而所谓 3A 游戏&#xff0c;简单来说就是高质量&#xff0c;高体量&#xff0c;高成本的单机…...

【Qt | QAction】Qt 的 QAction 类介绍

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; &#x1f923;本文内容&#x1f923;&a…...

写论文一定要知道的三大AI工具!5分钟完成论文初稿

在当今的学术研究和写作领域&#xff0c;AI工具已经成为不可或缺的助手。它们不仅能够提高写作效率&#xff0c;还能帮助研究者生成高质量的论文。以下是三大值得推荐的AI工具&#xff0c;它们可以帮助你在5分钟内完成论文初稿&#xff0c;并且特别推荐千笔-AIPasspaper。 千笔…...

后进先出(LIFO)详解

LIFO 是 Last In, First Out 的缩写&#xff0c;中文译为后进先出。这是一种数据结构的工作原则&#xff0c;类似于一摞盘子或一叠书本&#xff1a; 最后放进去的元素最先出来 -想象往筒状容器里放盘子&#xff1a; &#xff08;1&#xff09;你放进的最后一个盘子&#xff08…...

微信小程序之bind和catch

这两个呢&#xff0c;都是绑定事件用的&#xff0c;具体使用有些小区别。 官方文档&#xff1a; 事件冒泡处理不同 bind&#xff1a;绑定的事件会向上冒泡&#xff0c;即触发当前组件的事件后&#xff0c;还会继续触发父组件的相同事件。例如&#xff0c;有一个子视图绑定了b…...

python打卡day49

知识点回顾&#xff1a; 通道注意力模块复习空间注意力模块CBAM的定义 作业&#xff1a;尝试对今天的模型检查参数数目&#xff0c;并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...

Spark 之 入门讲解详细版(1)

1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室&#xff08;Algorithms, Machines, and People Lab&#xff09;开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目&#xff0c;8个月后成为Apache顶级项目&#xff0c;速度之快足见过人之处&…...

最新SpringBoot+SpringCloud+Nacos微服务框架分享

文章目录 前言一、服务规划二、架构核心1.cloud的pom2.gateway的异常handler3.gateway的filter4、admin的pom5、admin的登录核心 三、code-helper分享总结 前言 最近有个活蛮赶的&#xff0c;根据Excel列的需求预估的工时直接打骨折&#xff0c;不要问我为什么&#xff0c;主要…...

如何理解 IP 数据报中的 TTL?

目录 前言理解 前言 面试灵魂一问&#xff1a;说说对 IP 数据报中 TTL 的理解&#xff1f;我们都知道&#xff0c;IP 数据报由首部和数据两部分组成&#xff0c;首部又分为两部分&#xff1a;固定部分和可变部分&#xff0c;共占 20 字节&#xff0c;而即将讨论的 TTL 就位于首…...

初学 pytest 记录

安装 pip install pytest用例可以是函数也可以是类中的方法 def test_func():print()class TestAdd: # def __init__(self): 在 pytest 中不可以使用__init__方法 # self.cc 12345 pytest.mark.api def test_str(self):res add(1, 2)assert res 12def test_int(self):r…...

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

毫米波雷达基础理论(3D+4D)

3D、4D毫米波雷达基础知识及厂商选型 PreView : https://mp.weixin.qq.com/s/bQkju4r6med7I3TBGJI_bQ 1. FMCW毫米波雷达基础知识 主要参考博文&#xff1a; 一文入门汽车毫米波雷达基本原理 &#xff1a;https://mp.weixin.qq.com/s/_EN7A5lKcz2Eh8dLnjE19w 毫米波雷达基础…...

Cilium动手实验室: 精通之旅---13.Cilium LoadBalancer IPAM and L2 Service Announcement

Cilium动手实验室: 精通之旅---13.Cilium LoadBalancer IPAM and L2 Service Announcement 1. LAB环境2. L2公告策略2.1 部署Death Star2.2 访问服务2.3 部署L2公告策略2.4 服务宣告 3. 可视化 ARP 流量3.1 部署新服务3.2 准备可视化3.3 再次请求 4. 自动IPAM4.1 IPAM Pool4.2 …...