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

Day 28 MySQL的数据备份与恢复

数据备份及恢复

1.概述

​ 所有备份数据都应放在非数据库本地,而且建议有多份副本

备份: 能够防止由于机械故障以及人为误操作带来的数据丢失,例如将数据库文件保存在了其它地方

冗余: 数据有多份冗余,但不等备份,只能防止机械故障还来的数据丢失,例如主备模式、数据库集群

备份考虑的因素:

​ 数据的一致性

​ 服务的可用性

分类:

​ 逻辑备份

​ 备份的是建表、建库、插入等操作所执行SQL语句;适用于中小型数据库,效率相对较低(mysqldump,binlog日志)

​ 物理备份

​ 直接复制数据库文件,适用于大型数据库环境,不受存储引擎的限制,但不能恢复到不同的MySQL版本(tar、xtrabackup)

备份方式分类:

​ 完全备份

​ 备份所有数据

​ 增量备份

​ 每次备份上一次备份到现在产生的新数据

image-20220925184632820

​ 差异备份

​ 只备份跟完整备份不一样的

备份方案:

①完全备份+增量备份

设定一个周期(一周或一月),每周一对数据完整备份,周二到周天做增量备份,定期清理旧的数据,只保留最新的若干份
在这里插入图片描述

②完全备份+差异备份

设定一个周期(一周或一月),每周一对数据完整备份,周二到周天做差异备份(以周一的完整备份为基准),定期清理旧的数据,只保留最新的若干份
在这里插入图片描述

2.tar备份

​ 注意:备份期间,服务不可用

备份过程:完全物理备份

​ 停止数据库

[root@xingdian ~]# systemctl stop mysqld

​ tar备份数据

[root@xingdian ~]# mkdir /backup
[root@xingdian ~]# cd /var/lib/mysql
[root@xingdian ~]# tar -zcvf /backup/`date +%F`-mysql-all.tar.gz ./*

​ 启动数据库(备份完成后启动数据库,继续为其他服务提供服务)

[root@xingdian ~]# systemctl start mysqld

恢复过程:模拟数据丢失,恢复数据

​ 停止数据库

[root@xingdian ~]# systemctl stop mysqld

​ 清理环境

[root@xingdian ~]# rm -rf /var/lib/mysql/* 

​ 导入备份数据

[root@xingdian ~]# tar -xvf /backup/2019-08-20-mysql-all.tar.gz -C /usr/lib/mysql
[root@xingdian ~]# chown mysql.mysql /var/lib/mysql/* -R

​ 启动数据库(恢复后验证数据是否恢复成功)

[root@xingdian ~]# systemctl start mysqld
3.xtrabackup备份

简介:

​ percona-xtrabackup是开源免费的支持MySQL 数据库热备份的软件;能对InnoDB和XtraDB存储引擎的数据库非阻塞地备份;它不暂停服务创建Innodb热备份;为mysql做增量备份;在mysql服务器之间做在线表迁移;使创建replication更加容易;备份mysql而不增加服务器的负载

image-20220925185829126

安装软件:

[root@xingdian ~]# yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -y
[root@xingdian ~]# yum install percona-xtrabackup-24 -y
完整备份

​ 创建备份目录:

[root@xingdian ~]# mkdir -p /xtrabackup/full/

​ 备份:

[root@xingdian ~]# innobackupex --user=root --password='QianFeng@123' /xtrabackup/full/

​ 查看备份数据:

[root@xingdian ~]# ls /xtrabackup/full/
2022-09-25_19-40-47

​ 模拟数据丢失数据恢复:(以下操作模拟数据丢失)

丢失前数据库中的数据:

[root@xingdian ~]# mysql -u root -pQianFeng@123
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 7
Server version: 5.7.39 MySQL Community Server (GPL)Copyright (c) 2000, 2022, 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.mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| t1                 |
+--------------------+
5 rows in set (0.00 sec)

数据丢失:

[root@xingdian ~]# systemctl stop mysqld
[root@xingdian ~]# rm -rf /var/lib/mysql/*
[root@xingdian ~]# rm -rf /var/log/mysqld.log 
[root@xingdian ~]# rm -rf /var/log/mysql-slow/slow.log (有则删除,无则不需要操作)

恢复前的验证:

该步骤主要是验证备份的数据是否可用

[root@xingdian ~]# innobackupex --apply-log /xtrabackup/full/2022-09-25_19-40-47/

恢复之前需要确认配置文件内有数据库目录指定,不然xtrabackup不知道恢复到哪里

[root@xingdian ~]# cat /etc/my.cnf
datadir=/var/lib/mysql

​ 恢复数据:

[root@xingdian ~]# innobackupex --copy-back /xtrabackup/full/2022-09-25_19-40-47/

​ 修改权限:

[root@xingdian ~]# chown  mysql.mysql /var/lib/mysql -R

​ 启动服务:

[root@xingdian ~]# systemctl start mysqld

​ 验证:

[root@xingdian ~]# mysql -u root -pQianFeng@123
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 2
Server version: 5.7.39 MySQL Community Server (GPL)Copyright (c) 2000, 2022, 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.mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| t1                 |
+--------------------+
5 rows in set (0.00 sec)
增量备份

原理:每次备份上一次备份到现在产生的新数据

注意:在进行增量备份前先进行完整备份

案例:周一进行全备,周二到周天进行增量备份

​ 完整备份:(周一)

[root@xingdian ~]# innobackupex --user=root --password='QianFeng@123' /xtrabackup/full

​ 创建增量备份存放数据目录:

[root@xingdian ~]# mkdir /xtrabackup/zeng -p

​ 模拟数据增加(略)

​ 第一次增量备份:(周二)

[root@xingdian ~]# innobackupex --user=root --password='QianFeng@123' --incremental /xtrabackup/zeng/ --incremental-basedir=/xtrabackup/full/2022-09-25_19-40-47/第一次增量备份的数据:
[root@xingdian ~]# ls /xtrabackup/zeng/
2022-09-25_19-56-00

​ 模拟数据增加(略)

​ 第二次增量备份:(周三)

[root@xingdian ~]# innobackupex --user=root --password='QianFeng@123' --incremental /xtrabackup/zeng/ --incremental-basedir=/xtrabackup/zeng/2022-09-25_19-56-00/第二次增量备份的数据:
[root@xingdian ~]# ls /xtrabackup/zeng/
2022-09-25_19-56-00  2022-09-25_19-58-12

​ 后面的增量备份重复上面的操作(略)

增量备份数据恢复流程:(需要模拟数据的丢失)

​ 停止数据库:

[root@xingdian ~]# systemctl stop mysqld

​ 删除数据:

[root@xingdian ~]# rm -rf /var/lib/mysql/*
[root@xingdian ~]# rm -rf /var/log/mysqld.log其他数据根据实际情况删除

​ 依次重演回滚:

全备回滚:
[root@xingdian ~]# innobackupex --apply-log --redo-only /xtrabackup/full/2022-09-25_19-40-47/第一次增量回滚:
[root@xingdian ~]# innobackupex --apply-log --redo-only /xtrabackup/full/2022-09-25_19-40-47/ --incremental-dir=/xtrabackup/zeng/2022-09-25_19-56-00/第二次增量回滚:
[root@xingdian ~]# innobackupex --apply-log --redo-only /xtrabackup/full/2022-09-25_19-40-47/ --incremental-dir=/xtrabackup/zeng/2022-09-25_19-58-12/根据实际增量备份的次数回滚,可以想恢复到那个时间节点就回滚到那个时间节点,所有的回滚都给全备

​ 恢复数据:

[root@xingdian ~]# innobackupex --copy-back /xtrabackup/full/2022-09-25_19-40-47/

​ 修改权限:

[root@xingdian ~]# chown mysql.mysql /var/lib/mysql -R

​ 启动数据库:

[root@xingdian ~]# systemctl start mysqld

​ 验证:

[root@xingdian ~]# mysql -u root -pQianFeng@123
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 2
Server version: 5.7.39 MySQL Community Server (GPL)Copyright (c) 2000, 2022, 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.mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| t1                 |
| t2                 |
| t3                 |
+--------------------+
差异备份

原理:只备份跟完整备份不一样的

注意:在进行增量备份前先进行完整备份

案例:周一进行全备,周二到周天进行差异备份

​ 完整备份:(周一)

[root@xingdian ~]# mkdir -p /xtrabackup/full
[root@xingdian ~]# innobackupex --user=root --password=QianFeng@123 /xtrabackup/full

​ 模拟数据增加(略)

​ 第一次差异备份:(周二)

[root@xingdian ~]# mkdir -p /xtrabackup/jian
[root@xingdian ~]# innobackupex --user=root --password=QianFeng@123 --incremental /xtrabackup/jian --incremental-basedir=/xtrabackup/full/2022-09-25_20-10-52/查看第一次差异备份的数据:
[root@xingdian ~]# ls /xtrabackup/jian/
2022-09-25_20-12-55

​ 模拟数据增加(略)

​ 第二次差异备份:(周三)

[root@xingdian ~]# innobackupex --user=root --password=QianFeng@123 --incremental /xtrabackup/jian --incremental-basedir=/xtrabackup/full/2022-09-25_20-10-52/查看第二次差异备份的数据:
[root@xingdian ~]# ls /xtrabackup/jian/
2022-09-25_20-12-55  2022-09-25_20-14-32注意:后面的差异备份跟之前一样,根据需求可以继续差异备份

差异备份恢复流程:(模拟数据丢失)

​ 停止数据库:

[root@xingdian ~]# systemctl stop mysqld

​ 删除数据:

[root@xingdian ~]# rm -rf /var/lib/mysql/*
[root@xingdian ~]# rm -rf /var/log/mysqld.log 

​ 重演数据回滚:

完整备份回滚:
[root@xingdian ~]# innobackupex --apply-log --redo-only /xtrabackup/full/2022-09-25_20-10-52/差异备份回滚(根据差异备份的原理,如果恢复所有数据只需要将最后依次差异回滚)
[root@xingdian ~]# innobackupex --apply-log --redo-only /xtrabackup/full/2022-09-25_20-10-52/ --incremental-dir=/xtrabackup/jian/2022-09-25_20-14-32/

​ 恢复数据:

[root@xingdian ~]#  innobackupex --copy-back /xtrabackup/full/2022-09-25_20-10-52/

​ 修改权限:

[root@xingdian ~]# chown  mysql.mysql /var/lib/mysql -R

​ 启动数据库:

[root@xingdian ~]# systemctl start  mysqld

​ 数据验证:

[root@xingdian ~]# mysql -u root -pQianFeng@123
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 2
Server version: 5.7.39 MySQL Community Server (GPL)Copyright (c) 2000, 2022, 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.mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| k1                 |
| k2                 |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
9 rows in set (0.00 sec)
4.mysqldump备份

备份表:(前提有库有表)

[root@xingdian ~]# mysqldump -u root -pQianFeng@123 k1 t1 > /t1.sql

恢复表:(恢复之前模拟数据丢失)

[root@xingdian ~]# mysql -u root -pQianFeng@123 k1 < /t1.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.

验证:

[root@xingdian ~]# mysql -u root -pQianFeng@123 -e "use k1;show tables"
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------+
| Tables_in_k1 |
+--------------+
| t1           |
+--------------+

备份一个库:

[root@xingdian ~]# mysqldump -u root -pQianFeng@123 k1 > /k1.sql

-B 备份多个库:

[root@xingdian ~]# mysqldump -u root -pQianFeng@123 -B k1 k2 > /kall.sql

-A 备份所有库:

[root@xingdian ~]# mysqldump -u root -pQianFeng@123 -A > /all.sql

数据恢复:

​ 为保证数据一致性,应在恢复数据之前停止数据库对外的服务,停止binlog日志

​ binlog使用binlog日志恢复数据时也会产生binlog日志(如果开启的话,需要关闭)

mysql> set sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)

​ 模拟数据丢失(略)

[root@xingdian ~]# mysql -u root -pQianFeng@123 -D k1 < /k1.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1049 (42000): Unknown database 'k1'
出现该错误是因为在恢复的时候需要有库的存在[root@xingdian ~]# mysql -u root -pQianFeng@123 -e "create database k1"
[root@xingdian ~]# mysql -u root -pQianFeng@123 -D k1 < /k1.sql [root@xingdian ~]# mysql -u root -pQianFeng@123 -e "create database k1"
[root@xingdian ~]# mysql -u root -pQianFeng@123 -e "create database k2"
[root@xingdian ~]# mysql -u root -pQianFeng@123 -D k1 k2 < /kall.sql或者
mysql> source  /k1.sql

验证:

[root@xingdian ~]# mysql -u root -pQianFeng@123 -e "use k1; show tables;"
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------+
| Tables_in_k1 |
+--------------+
| t1           |
+--------------+
[root@xingdian ~]# mysql -u root -pQianFeng@123 -e "use k2; show tables;"
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------+
| Tables_in_k2 |
+--------------+
| t1           |
+--------------+
5.binlog日志备份

原理:日志方法备份恢复数据

日志默认存储位置:

​ rpm : /var/lib/mysql

​ 编译: 安装目录的var下

产生日志:

​ 方式一:编译安装

[root@xingdian ~]# mysqld_safe --log-bin --user=mysql --server-id=1 &查看binlog日志
[root@xingdian ~]# mysqlbinlog slave2-bin.000001     -v --base64-output=decode-rows时间点  :  141126 14:04:49位置点  :     at  106

​ 方式二:rpm安装(永久)

[root@xingdian ~]# vim /etc/my.cnf
log-bin=mylog
server-id=1        //做主从复制使用[root@xingdian ~]# systemctl restart mysqld查看:
[root@xingdian ~]# ls /var/lib/mysql
auto.cnf         client-key.pem  ib_logfile1   mysql               private_key.pem  sys
ca-key.pem       ib_buffer_pool  ibtmp1        mysql.sock          public_key.pem   xingdian-bin.index
ca.pem           ibdata1         mylog.000001  mysql.sock.lock     server-cert.pem  xtrabackup_info
client-cert.pem  ib_logfile0     mylog.index[root@xingdian ~]# mysqlbinlog /var/lib/mysql/mylog.000001 -v --base64-output=decode-rows
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#220925 21:12:47 server id 1  end_log_pos 123 CRC32 0x52358645  Start: binlog v 4, server v 5.7.39-log created 220925 21:12:47 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 123
#220925 21:12:47 server id 1  end_log_pos 154 CRC32 0xa84d8536  Previous-GTIDs
# [empty]
# at 154
#220925 21:13:38 server id 1  end_log_pos 219 CRC32 0xc2b00431  Anonymous_GTID  last_committed=0        sequence_number=1    rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 219
#220925 21:13:38 server id 1  end_log_pos 307 CRC32 0x635401a5  Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1664111618/*!*/;
SET @@session.pseudo_thread_id=2/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549152/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create database t1
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;方法二:
mysql>  show binlog events in  "mylog.000001";
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| Log_name     | Pos | Event_type     | Server_id | End_log_pos | Info                                  |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| mylog.000001 |   4 | Format_desc    |         1 |         123 | Server ver: 5.7.39-log, Binlog ver: 4 |
| mylog.000001 | 123 | Previous_gtids |         1 |         154 |                                       |
| mylog.000001 | 154 | Anonymous_Gtid |         1 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 219 | Query          |         1 |         307 | create database t1                    |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
4 rows in set (0.00 sec)默认查看第一个
mysql>  show binlog events;
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| Log_name     | Pos | Event_type     | Server_id | End_log_pos | Info                                  |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| mylog.000001 |   4 | Format_desc    |         1 |         123 | Server ver: 5.7.39-log, Binlog ver: 4 |
| mylog.000001 | 123 | Previous_gtids |         1 |         154 |                                       |
| mylog.000001 | 154 | Anonymous_Gtid |         1 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 219 | Query          |         1 |         307 | create database t1                    |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
4 rows in set (0.00 sec)

数据恢复:

​ 根据时间点恢复数据:

[root@xingdian ~]# mysqlbinlog --start-datetime='2022-9-25 21:12:47' --stop-datetime='2022-9-25 21:16:55' /var/lib/mysql/mylog.000001  | mysql -u root -pQianFeng@123

​ 根据位置点恢复数据:

mysql>  show binlog events;
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| Log_name     | Pos | Event_type     | Server_id | End_log_pos | Info                                  |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
| mylog.000001 |   4 | Format_desc    |         1 |         123 | Server ver: 5.7.39-log, Binlog ver: 4 |
| mylog.000001 | 123 | Previous_gtids |         1 |         154 |                                       |
| mylog.000001 | 154 | Anonymous_Gtid |         1 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 219 | Query          |         1 |         307 | create database t1                    |
| mylog.000001 | 307 | Anonymous_Gtid |         1 |         372 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 372 | Query          |         1 |         453 | drop database t1                      |
| mylog.000001 | 453 | Anonymous_Gtid |         1 |         518 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 518 | Query          |         1 |         606 | create database t1                    |
| mylog.000001 | 606 | Anonymous_Gtid |         1 |         671 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mylog.000001 | 671 | Query          |         1 |         752 | drop database t1                      |
+--------------+-----+----------------+-----------+-------------+---------------------------------------+
[root@xingdian ~]# mysqlbinlog --start-position 219 --stop-position 307 /var/lib/mysql/mylog.000001 | mysql -u root -pQianFeng@123

相关文章:

Day 28 MySQL的数据备份与恢复

数据备份及恢复 1.概述 ​ 所有备份数据都应放在非数据库本地&#xff0c;而且建议有多份副本 备份&#xff1a; 能够防止由于机械故障以及人为误操作带来的数据丢失&#xff0c;例如将数据库文件保存在了其它地方 冗余&#xff1a; 数据有多份冗余&#xff0c;但不等备份&…...

PackageKit的使用(三)疑问篇

本篇主要是一些疑问归纳&#xff0c;不做具体的函数分析&#xff0c;但是会给出关键点&#xff0c;查看源码就会很清楚了 apt source PackageKit 1. org.freedesktop.PackageKit D-Bus 接口介绍 D-Bus API Reference: PackageKit Reference Manual c库的接口可以看源码。 2.…...

【Linux】17. 进程间通信 --- 管道

1. 什么是进程间通信(进程间通信的目的) 数据传输&#xff1a;一个进程需要将它的数据发送给另一个进程 资源共享&#xff1a;多个进程之间共享同样的资源。 通知事件&#xff1a;一个进程需要向另一个或一组进程发送消息&#xff0c;通知它&#xff08;它们&#xff09;发生了…...

有哪些有效的复习方法可以帮助备考软考?

软考目前仍然是一个以记忆为主、理解为辅的考试。学过软考的朋友可能会感到困惑&#xff0c;因为软考的知识在日常工作中有许多应用场景&#xff0c;需要理解的地方也很多。但为什么我说它是理解为辅呢&#xff1f;因为这些知识点只要记住了&#xff0c;都不难理解&#xff0c;…...

【MySQL | 第九篇】重新认识MySQL锁

文章目录 9.重新认识MySQL锁9.1MySQL锁概述9.2锁分类9.2.1锁的粒度9.2.2锁的区间9.2.3锁的性能9.2.4锁的级别 9.3拓展&#xff1a;意向锁9.3.1意向锁概述9.3.2意向锁分类9.3.3意向锁作用&#xff08;1&#xff09;意向锁的兼容互斥性&#xff08;2&#xff09;例子1&#xff08…...

含义:理财风险等级R1、R2、R3、R4、R5

理财风险等级R1、R2、R3代表什么&#xff0c;为什么R1不保本&#xff0c;R2可能亏损 不尔聊投资https://author.baidu.com/home?frombjh_article&app_id1704141696580953 我们购买理财产品的时候&#xff0c;首先都会看到相关产品的风险等级。风险等级约定俗成有5级&…...

ICode国际青少年编程竞赛- Python-2级训练场-列表入门

ICode国际青少年编程竞赛- Python-2级训练场-列表入门 1、 Dev.step(3)2、 Flyer.step(1) Dev.step(-2)3、 Flyer.step(1) Spaceship.step(7)4、 Flyer.step(5) Dev.turnRight() Dev.step(5) Dev.turnLeft() Dev.step(3) Dev.turnLeft() Dev.step(7) Dev.turnLeft() Dev.…...

【设计模式】14、strategy 策略模式

文章目录 十四、strategy 策略模式14.1 map_app14.1.1 map_app_test.go14.1.2 map_app.go14.1.3 navigate_strategy.go 十四、strategy 策略模式 https://refactoringguru.cn/design-patterns/strategy 需求: client 知道很多不同的策略, 希望在运行时切换. 场景示例: 就像高…...

C++类和对象(基础篇)

前言&#xff1a; 其实任何东西&#xff0c;只要你想学&#xff0c;没人能挡得住你&#xff0c;而且其实学的也很快。那么本篇开始学习类和对象&#xff08;C的&#xff0c;由于作者有Java基础&#xff0c;可能有些东西过得很快&#xff09;。 struct在C中的含义&#xff1a; …...

Oracle导入数据中文乱码问题处理,修改客户端字符编码跟数据库的一致

前提&#xff1a;SQL文件打开其中中文字符是正常显示&#xff0c;保证导出文件中文字符正常。通过sqlplus命令导入SQL文件出现乱码&#xff0c;这是因为客户端跟数据库的字符集不一致导致出现乱码问题。 要SQL导入的中文正常&#xff0c;要确保执行导入命令的客户端字符编码跟…...

【与 Apollo 共创生态:展望自动驾驶全新未来】

1、引言 历经七年的不懈追求与创新&#xff0c;Apollo开放平台已陆续推出了13个版本&#xff0c;汇聚了来自全球170多个国家与地区的16万名开发者及220多家合作伙伴。随着Apollo开放平台的不断创新与发展&#xff0c;Apollo在2024年4月19日迎来了Apollo开放平台的七周年大会&a…...

【webrtc】MessageHandler 5: 基于线程的消息处理:以PeerConnection信令线程为例

peerconn的信令是通过post 消息到自己的信令线程消息来处理的PeerConnectionMessageHandler 是具体的处理器G:\CDN\rtcCli\m98\src\pc\peer_connection_message_handler.hMachinery for handling messages posted to oneself PeerConnectionMessageHandler 明确服务于 signalin…...

计算机网络 3.2网络体系结构

第二节 网络体系结构 一、网络协议 1.定义&#xff1a; ①通信双方共同遵守的规则。 ②为网络数据交换制定的规则、约定与标准。 ③网络实体之间通信时有关信息传输顺序、信息格式、信息内容的约定或规则。 2.协议三要素&#xff1a; 语法&#xff1a;确定协议元素的格式…...

连接HiveMQ代理器实现MQTT协议传输

先下载MQTTX: MQTTX: Your All-in-one MQTT Client Toolbox 使用线上免费的MQTTX BROKER:The Free Global Public MQTT Broker | Try Now | EMQ 打开MQTTX&#xff0c;创建连接&#xff0c;点击NEW SUBSCRIPTION,创建一个主题&#xff0c;这里使用test/topic,在下面Json中填写…...

springcloud报错:Failed to start bean‘webServerStartStop‘

如果你正在使用nacos进行服务注册&#xff0c;然后报一下错误&#xff1a; 那就说明的nacos没有打开&#xff0c;所以找到你的下载nacos的文件夹 好了&#xff0c;错误完美解决~...

el-checkbox 无法动态设置勾选状态

问题 cheked 值动态变化&#xff0c;但是勾选状态无法动态改变 解决 v-model 与:checked 同时使用 <el-checkbox class"add-shop-check" v-model"renderData[0].isCheck" :checked"renderData[0].isCheck" change"checked > selec…...

车规级低功耗汽车用晶振SG-9101CGA

车规级晶振SG-9101CGA属于爱普生9101系列&#xff0c;是一款可编程晶振。SG-9101CGA车规级晶振采用2.5x2.0mm封装&#xff0c;利用PLL技术生产&#xff0c;此款振荡器的频率范围从0.67M~170MHZ任一频点可选&#xff0c;步进1ppm&#xff0c;采用标准CMOS输出&#xff0c;最大输…...

企业是保留传统的MES还是换新的MES?

在选择上MES系统的时候&#xff0c;企业可以根据自身所处行业不同、当前阶段不同&#xff0c;以及业务需求的差异&#xff0c;对症下药&#xff0c;选择适合自己的解决方案。对于有些企业本来就有MES系统&#xff0c;但是已经过时过旧&#xff0c;就要考虑换新的MES系统了. 保留…...

2024年第六届世界软件工程研讨会(WSSE 2024)即将召开!

2024年第六届世界软件工程研讨会&#xff08;WSSE 2024&#xff09;将于2024年9月13-15日在日本京都举行。软件工程领域的发展离不开各位专家学者和业界精英的共同努力和贡献。WSSE 2024将就软件工程领域的最新研究成果、实践经验和发展趋势进行深入交流和探讨&#xff0c;汇聚…...

Linux网络编程:TCP编程实现

目录 1、前言 2、函数介绍 2.1 socket函数 与 通信域 2.2 bind函数 与 通信结构体 2.2.1 domain通信地址族 与 通信结构体 2.2.2 IPv4地址族结构体 2.2.3 通用地址族结构体 2.2.4 示例&#xff1a;为套接字fd绑定通信结构体addr 2.3 listen函数 与 accept函数 …...

conda相比python好处

Conda 作为 Python 的环境和包管理工具&#xff0c;相比原生 Python 生态&#xff08;如 pip 虚拟环境&#xff09;有许多独特优势&#xff0c;尤其在多项目管理、依赖处理和跨平台兼容性等方面表现更优。以下是 Conda 的核心好处&#xff1a; 一、一站式环境管理&#xff1a…...

Ubuntu系统下交叉编译openssl

一、参考资料 OpenSSL&&libcurl库的交叉编译 - hesetone - 博客园 二、准备工作 1. 编译环境 宿主机&#xff1a;Ubuntu 20.04.6 LTSHost&#xff1a;ARM32位交叉编译器&#xff1a;arm-linux-gnueabihf-gcc-11.1.0 2. 设置交叉编译工具链 在交叉编译之前&#x…...

【Redis技术进阶之路】「原理分析系列开篇」分析客户端和服务端网络诵信交互实现(服务端执行命令请求的过程 - 初始化服务器)

服务端执行命令请求的过程 【专栏简介】【技术大纲】【专栏目标】【目标人群】1. Redis爱好者与社区成员2. 后端开发和系统架构师3. 计算机专业的本科生及研究生 初始化服务器1. 初始化服务器状态结构初始化RedisServer变量 2. 加载相关系统配置和用户配置参数定制化配置参数案…...

HTML 列表、表格、表单

1 列表标签 作用&#xff1a;布局内容排列整齐的区域 列表分类&#xff1a;无序列表、有序列表、定义列表。 例如&#xff1a; 1.1 无序列表 标签&#xff1a;ul 嵌套 li&#xff0c;ul是无序列表&#xff0c;li是列表条目。 注意事项&#xff1a; ul 标签里面只能包裹 li…...

c++ 面试题(1)-----深度优先搜索(DFS)实现

操作系统&#xff1a;ubuntu22.04 IDE:Visual Studio Code 编程语言&#xff1a;C11 题目描述 地上有一个 m 行 n 列的方格&#xff0c;从坐标 [0,0] 起始。一个机器人可以从某一格移动到上下左右四个格子&#xff0c;但不能进入行坐标和列坐标的数位之和大于 k 的格子。 例…...

工程地质软件市场:发展现状、趋势与策略建议

一、引言 在工程建设领域&#xff0c;准确把握地质条件是确保项目顺利推进和安全运营的关键。工程地质软件作为处理、分析、模拟和展示工程地质数据的重要工具&#xff0c;正发挥着日益重要的作用。它凭借强大的数据处理能力、三维建模功能、空间分析工具和可视化展示手段&…...

基础测试工具使用经验

背景 vtune&#xff0c;perf, nsight system等基础测试工具&#xff0c;都是用过的&#xff0c;但是没有记录&#xff0c;都逐渐忘了。所以写这篇博客总结记录一下&#xff0c;只要以后发现新的用法&#xff0c;就记得来编辑补充一下 perf 比较基础的用法&#xff1a; 先改这…...

大模型多显卡多服务器并行计算方法与实践指南

一、分布式训练概述 大规模语言模型的训练通常需要分布式计算技术,以解决单机资源不足的问题。分布式训练主要分为两种模式: 数据并行:将数据分片到不同设备,每个设备拥有完整的模型副本 模型并行:将模型分割到不同设备,每个设备处理部分模型计算 现代大模型训练通常结合…...

《基于Apache Flink的流处理》笔记

思维导图 1-3 章 4-7章 8-11 章 参考资料 源码&#xff1a; https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...

认识CMake并使用CMake构建自己的第一个项目

1.CMake的作用和优势 跨平台支持&#xff1a;CMake支持多种操作系统和编译器&#xff0c;使用同一份构建配置可以在不同的环境中使用 简化配置&#xff1a;通过CMakeLists.txt文件&#xff0c;用户可以定义项目结构、依赖项、编译选项等&#xff0c;无需手动编写复杂的构建脚本…...