数据库主从备份

1、简介

数据库运⾏时,⼀些因素可能会导致服务运⾏不正常,⽤户访问数据受阻。对于互联⽹公 司,尤其是购物⽹站⽽⾔,这种情况造成的损失是⽆法估量的。因此,对数据库进⾏“备份” 也是必不可少的操作。当主要的数据库死机时,系统能够快速地切换到备⽤的数据库上。本 章将详细介绍数据库集群中的主从复制原理和操作流程。

2、主从复制集群的⼯作流程如下

(1)主服务器上⾯的任何修改都会通过⾃⼰的I/O线程保存在⼆进制⽇志⾥。

(2)从服务器上⾯也会启动⼀个I/O线程,通过配置好的⽤户名和密码连接到主服务器上⾯ 请求读取⼆进制⽇志,然后把读取到的⼆进制⽇志写到本地的⼀个中继⽇志的末端,并将读 取到的主服务器端的⼆进制⽇志的⽂件名和位置记录到master-info⽂件中,以便在下⼀次读 取的时候能够清楚地告诉主服务器:我需要某个⼆进制⽇志的某个位置之后的⽇志内容,请 发给我。

(3)从服务器的SQL线程检测到中继⽇志中新增加了内容后,会⻢上解析⽇志中的内容,并 在⾃身执⾏。需要注意,每个从服务器都会收到主服务器⼆进制⽇志中的全部内容的副本, 除⾮另⾏指定,否则,从服务器将执⾏来⾃主服务器⼆进制⽇志⽂件的所有的操作语句。另 外,从服务器每次进⾏同步时,都会记录⼆进制⽇志坐标(坐标包含⽂件名和从主服务器上 读取的位置,即master-info),以便下次连接使⽤。由于每个从服务器分别记录了当前⼆进制 ⽇志的位置,因此可以断开从服务器的连接,重新连接,然后恢复处理。

(4)在从服务器上删除的数据,在主服务器上重新创建,从服务器并不会同步过来,所以不要轻易的在从服务器上做删除操作。

3、基本架构

在 MySQL 的主从复制集群中,主数据库既要负责写操作⼜要负责为从数据库提供⼆进制⽇ 志,这⽆疑增加了主数据库的压⼒。此时可以将⼆进制⽇志只给某⼀个从服务器使⽤,并在 该从服务器上开启⼆进制⽇志,将该从服务器⼆进制⽇志分发给其他的从服务器;或者,这 个从服务器不进⾏数据的复制,只负责将⼆进制⽇志转发给其他的从服务器。这样,不仅可 以减少主服务的压⼒,还可以提⾼整体架构的性能。

⼀主多从原理如图所示

4、 多源复制架构

MySQL 5.7开始⽀持多源复制架构,即多个主服务器连接同⼀个从服务器(多主⼀从)。

多源复制中加⼊了⼀个叫作Channel的概念,每⼀个Channel都是⼀个独⽴的Slave,都有 ⼀个IO线程和⼀个SQL线程, 基本原理和普通的复制⼀样。 在对 Slave执⾏ CHANGEMASTER 语句时,只需要在每个语句最后使⽤for channel 关键字来进⾏区分即 可。

需要注意,在使⽤这种架构时,需要在从数据库的my.cnf配置⽂件中将master-inforepository、relay-log-info-repository参数设置为TABLE, 否则系统会报错。 相⽐于传统的⼀主⼀从、多主多从,在多源复制架构中,管理者可以直接在从数据库中进⾏ 数据备份, 不会影响线上业务的正常运⾏。

多源复制架构将多台数据库连接在⼀起,可以实 现合并表碎⽚,管理者不需要为每个数据库都制作⼀个实例,减少了维护成本,使⽤这种⽅ 式在后期进⾏数据统计时也会⾮常⾼效。

5、多主多从复制

在⼀主的情况下,主节点发⽣故障会影响全局的写⼊,设置双主或者多主集群可以避免单点 故障的发⽣。

前⾯介绍过的⼀主⼀从架构为基础,只需要集群中再加⼊⼀个主服务器master2和⼀个从 服务器slave2即可实现双主双从和多源复制架构。

6、复制模式

MySQL主从复制的⽅式可以分为异步复制、同步复制和半同步复制。

1.异步复制

异步复制为MySQL默认的复制⽅式, 主数据库执⾏完客户端提交的事务后会⽴即将结果返 给客户端,并不关⼼从数据库是否已经接收并进⾏了处理。 从⽇志的⻆度讲,在主数据库将 事务写⼊⼆进制⽇志⽂件后,主数据库只会通知dump线程发送这些新的⼆进制⽇志⽂件, 然后主数据库就会继续处理提交操作,并不考虑这些⼆进制⽇志已经传到每个从数据库节点 上。在使⽤异步复制模式时,如果主数据库崩溃,可能会出现主数据库上已经提交的事务并 没有传到从数据库上的情况,如果此时将从数据库提升为主数据库,很有可能导致新主数据 库上的数据不完整。

2.同步复制

同步复制是指主数据库向从数据库发送⼀个事务,并且所有的从数据库都执⾏了该事务后才会 将结果提交给客户端。因为需要等待所有的从数据库执⾏完该事务,所以在使⽤同步复制 时,主数据库完成⼀个事务的时间会被拉⻓,系统性能受到严重影响。

3.半同步复制

半同步复制介于同步复制与异步复制之间,主数据库只需要等待⾄少⼀个从数据库节点收到 并且更新⼆进制⽇志到中继⽇志⽂件即可,不需要等待所有从数据库给主数据库反馈。如此 ⼀来,不仅节省了很多时间,⽽且提⾼了数据的安全性。另外, 由于整个过程产⽣通信,所 以建议在低延时的⽹络中使⽤半同步复制。

环境

系统 :Redhat 9

mariadb版本:10.5.16

主机一:master 192.168.200.133

主机二:salve 192.168.200.128

步骤

先给两台设备进⾏命名为master和savle

[root@admin ~]#  hostnamectl set-hostname master
[root@admin ~]# bash
[root@master ~]# [root@localhost ~]#  hostnamectl set-hostname salve
[root@localhost ~]# bash
[root@salve ~]# 

对两台设备进⾏关闭防⽕墙和selinux操作

[root@master ~]# systemctl  stop firewalld.service 
[root@master ~]# systemctl  disable firewalld.service 
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@master ~]# setenforce  0[root@salve ~]# systemctl  stop firewalld.service 
[root@salve ~]# systemctl  disable firewalld.service 
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@salve ~]# setenforce  0

 配置本地yum仓库、并安装yum工具 配置阿里云网络源

#master
[root@master ~]# mount  /dev/sr0  /media/
mount: /media: WARNING: source write-protected, mounted read-only.
[root@master ~]# cat /etc/yum.repos.d/local.repo 
[AppStream]
name=AppStream
baseurl=file:///media/AppStream
enabled=1
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=file:///media/BaseOS
enabled=1
gpgcheck=0
[root@master ~]# 
[root@master ~]# yum -y install  yum-utils.noarch
[root@master ~]# yum-config-manager  --add-repo https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/rhel-9-beta.repo
正在更新 Subscription Management 软件仓库。
无法读取客户身份本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。添加仓库自:https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/rhel-9-beta.repo
[root@master ~]# #salve
[root@savle mnt]# mount /dev/sr1 /mnt/
[root@savle mnt]# cat /etc/yum.repos.d/local.repo 
[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
enabled=1
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
enabled=1
gpgcheck=0
[root@savle mnt]# 
[root@savle ~]# yum -y install  yum-utils.noarch
[root@savle ~]# yum-config-manager  --add-repo https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/rhel-9-beta.repo
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Adding repo from: https://mirrors.aliyun.com/redhat/rhel/rhel-9-beta/rhel-9-beta.repo
[root@savle ~]# 

修改源的enabled项为1 、以及地址项

#master
[root@master ~]# sed -i -e   's/enabled = 0/enabled = 1/g'  /etc/yum.repos.d/rhel-9-beta.repo 
[root@master ~]#  sed -i -e   's/downloads.redhat.com/mirrors.aliyun.com/g'  /etc/yum.repos.d/rhel-9-beta.repo
[root@master ~]# #savle
[root@savle ~]# sed -i -e   's/enabled = 0/enabled = 1/g'  /etc/yum.repos.d/rhel-9-beta.repo 
[root@savle ~]# sed -i -e   's/downloads.redhat.com/mirrors.aliyun.com/g'  /etc/yum.repos.d/rhel-9-beta.repo 
[root@savle ~]# 

在两台设备上 安装mariadb服务

#master
[root@master ~]# yum -y install  mariadb mariadb-server
正在更新 Subscription Management 软件仓库。
无法读取客户身份本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。上次元数据过期检查:0:02:11 前,执行于 2024年04月16日 星期二 13时27分59秒。
依赖关系解决。
=======================================================================================================================================================软件包                                         架构                       版本                                    仓库                           大小
=======================================================================================================================================================
安装:mariadb                                        x86_64                     3:10.5.16-2.el9_0                       AppStream                     1.6 Mmariadb-server                                 x86_64省略 。。。。。#savle[root@savle ~]# yum -y install  mariadb mariadb-server
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.Last metadata expiration check: 0:02:37 ago on Tue 16 Apr 2024 01:28:12 PM CST.
Dependencies resolved.
=======================================================================================================================================================Package                                        Architecture               Version                                 Repository                     Size
=======================================================================================================================================================
Installing:mariadb                                        x86_64                     3:10.5.16-2.el9_0                       AppStream                     1.6 Mmariadb-server                                 x86_64                     3:10.5.16-2.el9_0                       AppStream                     9.4 M
省略 。。。。。

对两台设备进⾏启动mariadb服务操作并设置为开机⾃启动,随后进⾏数据库 安全设置

#master
[root@master ~]# systemctl  restart  mariadb.service 
[root@master ~]# systemctl  enable  mariadb.service 
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@master ~]# 
[root@master ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.Enter current password for root (enter for none): 
OK, successfully used password, moving on...Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.You already have your root account protected, so you can safely answer 'n'.Switch to unix_socket authentication [Y/n] y   //切换到unix_socket身份验证
Enabled successfully!
Reloading privilege tables..... Success!You already have your root account protected, so you can safely answer 'n'.Change the root password? [Y/n] y //设置密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.Remove anonymous users? [Y/n]  //移除匿名用户... Success!Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n]  //禁止root远程登录... Success!By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n]   //移除test数据库- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n]   //刷新权限表... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!#savle
[root@savle ~]# systemctl  restart  mariadb.service 
[root@savle ~]# systemctl enable  mariadb.service 
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@savle ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.Enter current password for root (enter for none): 
OK, successfully used password, moving on...Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.You already have your root account protected, so you can safely answer 'n'.Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..... Success!You already have your root account protected, so you can safely answer 'n'.Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.Remove anonymous users? [Y/n] ... Success!Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] ... Success!By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.Remove test database and access to it? [Y/n] - Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n] ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!
[root@savle ~]# 

对两台设备进⾏主从同步设置 并重启服务

#master
[root@master ~]# vim /etc/my.cnf.d/mariadb-server.cnf 16 [mysqld]17 datadir=/var/lib/mysql   //存储数据库文件的目录。这通常包括所有的数据库文件、表文件、索引文件等。18 socket=/var/lib/mysql/mysql.sock //定义了UNIX套接字文件的路径19 log-error=/var/log/mariadb/mariadb.log   //指定了MariaDB的错误日志文件的路径20 pid-file=/run/mariadb/mariadb.pid   //置了进程ID(PID)文件的路径21 log_bin=mysql_bin                //指定二进制日志功能日志文件名为mysql_bin22 binlog_ignore_db=mysql          //这行配置指定了在二进制日志中忽略的数据库23 server_id=200                    //优先级,越小越优先
[root@master ~]# systemctl  restart  mariadb.service 
[root@master ~]##savle[root@savle ~]# vim /etc/my.cnf.d/mariadb-server.cnf 16 [mysqld]17 datadir=/var/lib/mysql   //存储数据库文件的目录。这通常包括所有的数据库文件、表文件、索引文件等。18 socket=/var/lib/mysql/mysql.sock //定义了UNIX套接字文件的路径19 log-error=/var/log/mariadb/mariadb.log   //指定了MariaDB的错误日志文件的路径20 pid-file=/run/mariadb/mariadb.pid   //置了进程ID(PID)文件的路径21 log_bin=mysql_bin                //指定二进制日志功能日志文件名为mysql_bin22 binlog_ignore_db=mysql          //这行配置指定了在二进制日志中忽略的数据库23 server_id=201                    //优先级,越小越优先[root@savle ~]# systemctl  restart  mariadb.service [root@savle ~]# 

在master上对savle⽤户进⾏授权操作,使其能够访问数据库

[root@master ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.5.16-MariaDB-log MariaDB Server   Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> create user 'savle'@'%' identified by '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'savle'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)MariaDB [(none)]> 
MariaDB [(none)]> create database  test;    //创建数据库用于测试从服务器同步
Query OK, 1 row affected (0.000 sec)MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.000 sec)MariaDB [(none)]> 

 在savle上开启同步设置

MariaDB [(none)]> change master to master_host='192.168.200.133',master_user='savle',master_password='123456';
Query OK, 0 rows affected (0.011 sec)
MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> show slave status \G;        // \G参数使得输出结果以垂直格式显示
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.200.133Master_User: savleMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql_bin.000001Read_Master_Log_Pos: 798Relay_Log_File: mariadb-relay-bin.000002Relay_Log_Pos: 1097Relay_Master_Log_File: mysql_bin.000001Slave_IO_Running: Yes      //此项为yes即可Slave_SQL_Running: Yes      //此项为yes即可Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 798Relay_Log_Space: 1408Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 200Master_SSL_Crl: Master_SSL_Crlpath: Using_Gtid: NoGtid_IO_Pos: Replicate_Do_Domain_Ids: Replicate_Ignore_Domain_Ids: Parallel_Mode: optimisticSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesSlave_DDL_Groups: 3
Slave_Non_Transactional_Groups: 0Slave_Transactional_Groups: 0
1 row in set (0.000 sec)ERROR: No query specifiedMariaDB [(none)]> 
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |   //刚刚主服务器创建的test数据库
+--------------------+
4 rows in set (0.001 sec)MariaDB [(none)]> 

#回到主服务器再次进行测试

[root@master ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.5.16-MariaDB-log MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> create  database abc;
Query OK, 1 row affected (0.001 sec)MariaDB [(none)]> #进入savle
[root@savle ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.5.16-MariaDB-log MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| abc                |   //发现已经同步过来了
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.000 sec)MariaDB [(none)]> 

mysql的主从备份就到此结束啦!!!

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

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

相关文章

MediaStream使用webRtc多窗口传递

最近在做音视频通话,有个需求是把当前会话弄到另一个窗口单独展示,但是会话是属于主窗口的,多窗口通信目前不能直接传递对象,所以想着使用webRtc在主窗口和兄弟窗口建立连接,把主窗口建立会话得到的MediaStream传递给兄…

Unity之XR Interaction Toolkit如何在VR中实现渐变黑屏效果

前言 做VR的时候,有时会有跳转场景,切换位置,切换环境,切换进度等等需求,此时相机的画面如果不切换个黑屏,总会感觉很突兀。刚好Unity的XR Interaction Toolkit插件在2.5.x版本,出了一个TunnelingVignette的效果,我们今天就来分析一下他是如何使用的,然后我们自己再来…

MAC电脑M1安装OpenCV

最近在学习研究OpenCV,奈何只有mac电脑。安装OpenCV感觉还是挺麻烦的,所以记录一下,难免以后会忘记。 安装OpenCV我参考的帖子 https://www.bilibili.com/read/cv23613225/ 一、首先安装Anaconda 目前已安装不做赘述 二、启动命令窗口 方…

ArcGIS无法链接在线地图或错误: 代理服务器从远程服务器收到了错误地址(验证服务器是否正在运行)。

这几天我们分享了! 谷歌卫星影像图归来!ArcGIS直连!快来获取_谷歌影像lyr-CSDN博客文章浏览阅读666次,点赞11次,收藏9次。大概。_谷歌影像lyrhttps://blog.csdn.net/kinghxj/article/details/137521877一套图源搞定&a…

【办公类-22-04】20240418 UIBOT模拟上传每天两篇,获取流量券,并删除内容

背景需求: 前文制作了用UIBOT获取CSCN的3天、5天、7天、12天奖励流量券, 【办公类-22-03】20240417 UIBOT模拟上传获取流量券,并删除内容-CSDN博客文章浏览阅读253次,点赞6次,收藏3次。【办公类-22-03】20240417 UIB…

详解运算符重载,赋值运算符重载,++运算符重载

目录 前言 运算符重载 概念 目的 写法 调用 注意事项 详解注意事项 运算符重载成全局性的弊端 类中隐含的this指针 赋值运算符重载 赋值运算符重载格式 注意点 明晰赋值运算符重载函数的调用 连续赋值 传引用与传值返回 默认赋值运算符重载 前置和后置重载 前…

华为OD机试 - 分披萨 - 动态规划(Java 2024 C卷 200分)

华为OD机试 2024C卷题库疯狂收录中,刷题点这里 专栏导读 本专栏收录于《华为OD机试(JAVA)真题(A卷B卷C卷)》。 刷的越多,抽中的概率越大,每一题都有详细的答题思路、详细的代码注释、样例测试…

抖去推短视频矩阵系统----源头开发

为什么一直说让企业去做短视频矩阵?而好处就是有更多的流量入口,不同平台或账号之间可以进行资源互换,最终目的就是获客留咨,提单转化。你去看一些做得大的账号,你会发现他们在许多大的平台上,都有自己的账…

HTML5 <video> 标签属性、API 方法、事件、自定义样式详解与实用示例

HTML5 <video> 标签为网页内嵌视频提供了强大且便捷的功能。以下是对 <video> 标签的主要属性、API 方法、事件、自定义样式及其使用示例的详细介绍&#xff1a; 一、属性 1. src 定义&#xff1a;指定视频文件的 URL。示例&#xff1a;<video src"my_v…

【C++杂货铺】继承

目录 &#x1f308;前言&#x1f308; &#x1f4c1; 继承的概念和定义 &#x1f4c2; 概念 &#x1f4c2; 定义 &#x1f4c1; 基类和派生类对象赋值转换 &#x1f4c1; 继承中的作用域 &#x1f4c1; 派生类的默认成员函数 构造函数 析构函数 拷贝构造函数 赋值重载…

有公网IP,如何设置端口映射实现访问?

很多中小型公司或个人会根据自身需求自建服务器&#xff0c;或者将自己内网的服务、应用发布到外网&#xff0c;实现异地访问&#xff0c;如远程桌面、网站、数据库、公司的管理系统、FTP、管家婆、监控系统等等。 没接触过的人可能会觉得这个很难&#xff0c;实际上使用快解析…

Golang插件系统实现

插件可以在解耦的基础上灵活扩展应用功能&#xff0c;本文介绍了如何基于Golang标准库实现插件功能&#xff0c;帮助我们构建更灵活可扩展的应用。原文: Plugins with Go 什么是插件 简单来说&#xff0c;插件就是可以被其他软件加载的软件&#xff0c;通常用于扩展应用程序的功…

[入门]测试层级-ApiHug准备-测试篇-005

&#x1f917; ApiHug {Postman|Swagger|Api...} 快↑ 准√ 省↓ GitHub - apihug/apihug.com: All abou the Apihug apihug.com: 有爱&#xff0c;有温度&#xff0c;有质量&#xff0c;有信任ApiHug - API design Copilot - IntelliJ IDEs Plugin | Marketplace 这里的测…

学习STM32第十五天

SPI外设 一、简介 STM32F4XX内部集成硬件SPI收发电路&#xff0c;可以由硬件自动执行时钟生成、数据收发等功能&#xff0c;减轻CPU负担&#xff0c;可配置8位/16位数据帧&#xff0c;高位&#xff08;最常用&#xff09;/低位先行&#xff0c;三组SPI接口&#xff0c;支持DMA…

第一篇【传奇开心果系列】我和AI面对面聊编程:深度比较PyQt5和tkinter.ttk

传奇开心果系列博文 系列博文目录我和AI面对面聊编程系列 博文目录前言一、今天我们面对广大读者选择PyQt5和tkinter.ttk做比较这个话题目的是什么&#xff1f;二、举一个最简单的pyqt5信号和插槽的例子三、这和tkinter的点击事件有什么区别&#xff1f;四、如何选择&#xff1…

MySQL Explan执行计划详解

Explan执行计划 首先我们采用explan执行计划 执行一条sql&#xff0c;发现返回了12个列&#xff0c;下面会详细解释每一列 1、ID列 id列的值是代表了select语句执行顺序&#xff0c;是和select相关联的&#xff1b;id列的值大的会优先执行&#xff0c;如果id列为空最后执行&a…

数据库的创建

数据库分类 通过查看对象资源管理器来区分数据库类型 数据库物理文件的组成 : 数据库文件 日志文件 创建一个主数据文件和一个日志文件

上线流程及操作

上节回顾 1 搜索功能-前端&#xff1a;搜索框&#xff0c;搜索结果页面-后端&#xff1a;一种类型课程-APIResponse(actual_courseres.data.get(results),free_course[],light_course[])-搜索&#xff0c;如果数据量很大&#xff0c;直接使用mysql&#xff0c;效率非常低--》E…

淘宝商品数据抓取新策略:API接口助力获取标题、分类与店铺名

随着电子商务的迅猛发展&#xff0c;淘宝作为中国最大的网络购物平台&#xff0c;其商品数据对于众多商家、研究者和市场分析师来说具有极高的价值。然而&#xff0c;如何高效、准确地抓取淘宝商品数据&#xff0c;尤其是商品标题、分类和店铺名等关键信息&#xff0c;一直是一…

nginx部署上线

1. windows配置nginx 打包命令 npm run build:prod 1. 安装 nginx mac windows 2. mac / windows 环境下ngnix部署启动项目 2. nginx 解决 history 的 404 问题 3. nginx配置代理解决生产环境跨域问题