MySQL数据库实现主主同步
前言
MySQL主主同步实际上是在主从同步的基础上将从数据库
也提升成主数据库
,让它们可以互相读写数据库,从数据库变成主数据库;主从相互授权连接,读取对方binlog日志并更新到本地数据库的过程,只要对方数据改变,自己就跟着改变。
1. 主主同步的优与劣
事实上每个技术都有它的优劣势,我们要在功能之间选择更适合自己使用的技术服务。
主主同步的优势
- 提高数据可用性:MySQL主主同步可以将多个MySQL服务器之间的数据同步,当其中一个服务器出现故障时,其他服务器可以继续提供服务,从而提高了数据的可用性。
- 增强数据的安全性:MySQL主主同步可以实现数据的备份和复制,当其中一个服务器出现数据丢失或损坏时,其他服务器可以提供备份数据,从而增强了数据的安全性。
- 支持读写分离:MySQL主主同步可以实现读写分离,即将读请求和写请求分发到不同的MySQL服务器上,从而提高了数据库的读写性能。
主主同步的劣势
- 数据同步延迟:MySQL主主同步存在数据同步延迟的问题,即在数据同步过程中,可能会出现数据不一致的情况。当一个MySQL服务器修改了数据后,其他服务器需要一定的时间才能完成数据同步,因此可能会出现数据同步延迟的问题。
- 需要协调多个MySQL服务器:MySQL主主同步需要协调多个MySQL服务器之间的数据同步,因此需要更多的管理和维护工作,包括配置、监控和故障处理等。
- 数据库性能下降:MySQL主主同步可能会降低数据库的性能,特别是在数据同步过程中,可能会占用过多的系统资源,从而影响数据库的性能。
综上所述,MySQL主主同步具有提高数据可用性、增强数据安全性、支持读写分离等优点,但也存在数据同步延迟、需要协调多个MySQL服务器和数据库性能下降等缺点。因此,在选择数据库同步方式时,需要根据实际情况综合考虑。
一. 部署MySQL数据库
还是一样需要先将两台服务器同时都安装上MySQL8.0数据库,这里就快速的演示一下。
1.1 前期准备
为了整个实验步骤比较顺利,需要先将防火墙和selinux提前关闭。
iptables -F
systemctl stop firewalld.service
setenforce 0
这里第二台服务器不在作为从,而是两台都是作为主数据库。
系统 | IP | 数据库版本 |
---|---|---|
CentOS7.9 | 192.168.116.166(master1) | mysql8.0 |
CentOS7.9 | 192.168.116.128(master2) | mysql8.0 |
1.2 安装数据库
两台服务器都需要安装好数据库,这个是前提,也是必须安装的。
详细步骤可参考《安装部署MySQL8.0》
#备份源
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak#下载网络源
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo#清空现有的文件和软件包
[root@localhost yum.repos.d]# rpm -qa | grep mysql
[root@localhost yum.repos.d]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost yum.repos.d]# rpm -e mariadb-libs --nodeps[root@localhost yum.repos.d]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/usr/lib64/mysql
[root@localhost yum.repos.d]# rm -rf /etc/selinux/targeted/active/modules/100/mysql /usr/lib64/mysql#下载安装MySQL8.0
[root@localhost yum.repos.d]# rpm -ivh https://repo.mysql.com/mysql80-community-release-el7.rpm
[root@localhost yum.repos.d]# yum install mysql-community-server -y
[root@localhost yum.repos.d]# systemctl restart mysqld#找到初始化密码,为下一步登录修改密码做准备
[root@localhost yum.repos.d]# grep -iwa "Password" /var/log/mysqld.log
2023-03-07T06:56:53.564861Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: h-Ijft/b/9W*#修改数据库密码
[root@localhost yum.repos.d]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32Copyright (c) 2000, 2023, 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> alter user 'root'@'localhost' identified by 'Admin#123';
Query OK, 0 rows affected (0.00 sec)mysql> exit
安装好之后,就可以开始配置主主同步了。
1.3 思路
将第一台服务器设定为主master1,第二台服务器设定为主master2
主master1与主master2先做一遍主从同步,让它们互为主从关系,第二遍反过来,让主作从,让从作主。
在这个基础上,肯定是需要修改配置文件的,那么我们就先修改master1的。
二. 配置主master1
增加辨识度,提前先将第一台服务器修改主机名
[root@localhost ~]# hostname master1
[root@localhost ~]# bash
[root@master1 ~]#
2.1 修改配置文件
[root@master1 ~]# vim /etc/my.cnf
[root@master1 ~]# sed 4,+5p -n /etc/my.cnf
[mysqld]
server-id=11
log-bin=mysql-bin
auto_increment_increment=2
auto_increment_offset=1
replicate-do-db=demo_db
- server-id=11 #数据库的唯一ID
- log-bin=mysql-bin #存放日志文件位置
- auto_increment_increment=2 #控制主键自增的步长,几台服务器就设置几
- auto_increment_offset=1 #设置自增起始值。这个是第1台,那么为1,下一台则为2。
- replicate-do-db=demo_db #选择要同步的数据库。
修改好配置文件后,记得记得一定要重启服务,因为修改配置文件等于重新给变量赋值;不重启服务,文件的inode值不会同步到内核中,因此重启服务就是让新的inode值让内核知道的一个过程。
[root@master1 ~]# systemctl restart mysqld
2.2 创建用户master1
在数据库中创建一个master1的用户
[root@master1 ~]# mysql -uroot -p'Admin#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 8
Server version: 8.0.32 MySQL Community Server - GPLCopyright (c) 2000, 2023, 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> create user 'master1'@'%' identified with mysql_native_password by '#Master1';
Query OK, 0 rows affected (0.01 sec)mysql> grant replication slave on *.* to 'master1'@'%';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> show grants for 'master1'@'%';
+-------------------------------------------------+
| Grants for master1@% |
+-------------------------------------------------+
| GRANT REPLICATION SLAVE ON *.* TO `master1`@`%` |
+-------------------------------------------------+
1 row in set (0.00 sec)
create user 'master1'@'%' identified with mysql_native_password by '#Master1';
- 这一条语句的意思就是创建一个master1这个用户,用户的名称是可以自己定义的;@'%'表示可以远程登录数据库,identified with mysql_native_password by这个语句则是MySQL8.0的固定写法,表示就是给他设置密码。
grant replication slave on *.* to 'master'@'%';
- 这条语句则是表示给这个用户授权数据库的权限,*.基本上就是给所有权限,第一个表示所有数据库,第二个是表示数据库表。
flush privileges;
- 这条语句表示刷新数据库,让之前设置的内容可以同步到数据库中。
show grants for 'master1'@'%';
- 查看之前设置的权限是否已经写入到数据库中,有显示内容表示已经写入成功了。
接下来继续查看master1的状态
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 157 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
- File 就是我们刚刚设置的log-bin的存放文件,用来记录mysql操作的日志文件。
- Position 表示是偏移量
- Binlog_Do_DB 需要进行同步的数据库
- Binlog_Ignore_DB 不进行同步的数据库
每操作一步数据库,这个偏移量的值都会发生变化,因此查看状态后,master1数据库最好就不要继续再操作任何内容了。
那么接下来就开始修改第二台数据库。
三. 配置slave1从数据库
此配置在第二台服务器上进行操作
修改主机名
[root@localhost ~]# hostname master2
[root@localhost ~]# bash
[root@master2 ~]#
3.1 修改配置文件
修改配置文件/etc/my.cnf
,这个是第二台服务器,因此id
和auto_increment_offset
都需要调整为2。
[root@master2 ~]# vim /etc/my.cnf
[root@master2 ~]# sed 4,+5p -n /etc/my.cnf
[mysqld]
server-id=12
log-bin=mysql-bin
auto_increment_increment=2
auto_increment_offset=2
replicate-do-db=demo_db
还是一样,修改好配置文件一定要重启服务
[root@master2 ~]# systemctl restart mysqld
3.2 绑定主master1数据库
mysql> change master to master_host='192.168.116.166',-> master_user='master1',-> master_password='#Master1',-> master_log_file='mysql-bin.000002',-> master_log_pos=157;
Query OK, 0 rows affected, 8 warnings (0.00 sec)mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.116.166Master_User: master1Master_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 157Relay_Log_File: master2-relay-bin.000002Relay_Log_Pos: 326Relay_Master_Log_File: mysql-bin.000002Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: demo_dbReplicate_Ignore_DB: Replicate_Do_Table:
......
1 row in set, 1 warning (0.00 sec)
以上的语句内容实际上只有几句是需要执行的,一起来看下。
这一条信息的模板可以直接复制,需要在等号后面将IP,自己定义的用户名,密码,日志文件,偏移量进行修改。
change master to master_host='192.168.116.166', #填写您自己的IP
master_user='master1', #填写您自己在第一台服务器上创建的用户名称
master_password='#Master1', #填写在第一台服务器上创建的用户密码
master_log_file='mysql-bin.000002', #填写第一台服务器上master的日志信息
master_log_pos=157; #填写在第一台服务器上master的偏移量
使用这条语句查看从数据库的状态;
show slave status \G
看到这两个值为yes表示是已经同步成功了。
四. 配置master2数据库
接下来在现在这台master2服务器继续配置
4.1 创建用户master2
创建一个名为master2
的用户
mysql> create user 'master2'@'%' identified with mysql_native_password by '#Master2';
Query OK, 0 rows affected (0.01 sec)mysql> grant replication slave on *.* to 'master2'@'%';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
查看master2的状态
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000004 | 157 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
到这里就可以不用继续操作了,也可以直接退出mysql管理系统。
再回到第一台服务器上继续同步第二台的数据库用户
五. 配置slave2数据库
其实slave2也就是master1,还是使用相同的方式进行绑定。
5.1 绑定同步主master2数据库
mysql> change master to master_host='192.168.116.128', master_user='master2',-> master_password='#Master2',master_log_file='mysql-bin.000004',-> master_log_pos=157;
Query OK, 0 rows affected, 8 warnings (0.00 sec)mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.02 sec)mysql> show slave status \G
*************************** 1. row ***************************Slave_IO_State: Connecting to sourceMaster_Host: 192.168.116.128Master_User: master2Master_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000004Read_Master_Log_Pos: 157Relay_Log_File: master1-relay-bin.000001Relay_Log_Pos: 4Relay_Master_Log_File: mysql-bin.000004Slave_IO_Running: ConnectingSlave_SQL_Running: YesReplicate_Do_DB: demo_dbReplicate_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: 157Relay_Log_Space: 157Until_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: NULL
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 2003Last_IO_Error: error connecting to master 'master2@192.168.116.128:3306' - retry-time: 60 retries: 1 message: Can't connect to MySQL server on '192.168.116.128:3306' (113)Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids:
......
1 row in set, 1 warning (0.00 sec)
可以看到,在查看slave状态时,有个值并不是yes。
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
这里可以看到错误的原因,当然影响到IO的值是Connecting的原因很多,我们逐一进行排查。
5.2 解决方案
遇到错误不可怕,可以思考一下之前执行的步骤,先返回查看上一步步骤执行是否正确,若正确,在看看是否是selinux,防火墙,网络等问题。
配置失败的原因:
- 网络不通–可以尝试ping下网站域名
- 防火墙,selinux没有关–重新执行关闭的操作
- 用户密码输错–重新再配置一遍,确认清楚再输入
- IP错误–确认是否是本地服务器的IP
- 偏移量和日志文件错误–重启服务后再重新配置一遍
两台服务器都需要做下排查
[root@master1 ~]# hostname -I
192.168.116.166 192.168.122.1
[root@master1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: inactive (dead) since 五 2023-02-10 10:52:45 CST; 1 months 12 days agoDocs: man:firewalld(1)Main PID: 804 (code=exited, status=0/SUCCESS)2月 10 10:51:06 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
2月 10 10:51:10 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
2月 10 10:51:11 localhost.localdomain firewalld[804]: WARNING: AllowZoneDrifting ...
2月 10 10:52:44 localhost.localdomain systemd[1]: Stopping firewalld - dynamic f....
2月 10 10:52:45 localhost.localdomain systemd[1]: Stopped firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@master1 ~]# ping -c 1 www.baidu.com
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=53 time=37.8 ms--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 37.807/37.807/37.807/0.000 ms
[root@master1 ~]# getenforce
Permissive
[root@master1 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination Chain FORWARD (policy ACCEPT)
target prot opt source destination Chain OUTPUT (policy ACCEPT)
target prot opt source destination
第一台服务器测试正常
接下来测试第二台服务器
[root@master2 ~]# hostname -I
192.168.116.128 192.168.122.1 [root@master2 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: active (running) since 六 2023-03-25 15:28:38 CST; 2s agoDocs: man:firewalld(1)Main PID: 70425 (firewalld)Tasks: 2CGroup: /system.slice/firewalld.service└─70425 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...e.
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...e.
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
3月 25 15:28:39 master2 firewalld[70425]: WARNING: COMMAND_FAILED: '/usr/sbin/ipt...).
Hint: Some lines were ellipsized, use -l to show in full.
发现是第二台服务器防火墙没有关闭,大概率是这些的问题影响的,接下来将防火墙给关了。
[root@master2 ~]# systemctl stop firewalld.service
关闭之后,在第一台服务器上继续绑定服务器。
是防火墙的问题就比较好办,先将slave给关闭了,重新设置一下,再开启。
stop slave;
reset slave;
start slave;
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> reset slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.04 sec)mysql> show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.116.128Master_User: master2Master_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000004Read_Master_Log_Pos: 157Relay_Log_File: master1-relay-bin.000006Relay_Log_Pos: 373Relay_Master_Log_File: mysql-bin.000004Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: demo_dbReplicate_Ignore_DB:
......
1 row in set, 1 warning (0.00 sec)
查看两个值都为yes表示已经同步成功。
六. 测试结果
以上就是主主同步的全部内容了,到这里是时候该验证一下是否已经完全成功。
我们在第一台master1上创建之前选择同步的数据库,接下来给这个数据库创建表,再给表内插入几行信息。
6.1 第一台数据库测试
[root@master1 ~]# mysql -uroot -pAdmin#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 32
Server version: 8.0.32 MySQL Community Server - GPLCopyright (c) 2000, 2023, 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> create database demo_db;
Query OK, 1 row affected (0.01 sec)mysql> use demo_db
Database changed
mysql> create table demo_tb(id int not null,name varchar(20) default 'username');
Query OK, 0 rows affected (0.02 sec)mysql> insert into demo_tb values(1,'zhangsan'), (2,'lisi'), (3,'kunkun');
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
6.2 第二台数据库测试
[root@master2 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.32 MySQL Community Server - GPLCopyright (c) 2000, 2023, 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 |
+--------------------+
| demo_db |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)mysql> select * from demo_db.demo_tb;
+----+----------+
| id | name |
+----+----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | kunkun |
+----+----------+
3 rows in set (0.01 sec)mysql> use demo_db
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> insert into demo_tb values(4,'liao'),-> (5,'chengpi'),-> (6,'mahua');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
在第一台数据库上看看第二台插入的内容是否也能成功写入。
mysql> select * from demo_tb;
+----+----------+
| id | name |
+----+----------+
| 1 | zhangsan |
| 2 | lisi |
| 3 | kunkun |
| 4 | liao |
| 5 | chengpi |
| 6 | mahua |
+----+----------+
6 rows in set (0.00 sec)
查看第二台数据库输入的内容,也能同步到第一台上,说明已经成功。
总结
以上就是本文的全部内容了,如果有看过昨天那篇《MySQL数据库实现主从同步》就会发现主主同步,也只是在主从同步上再反过来操作一次主从同步。若觉得以上内容还行的,可以点赞支持一下!
相关文章:
![](https://img-blog.csdnimg.cn/fb9b2d9a258c4d3ba7cfe09aab99ff09.jpeg#pic_center)
MySQL数据库实现主主同步
前言 MySQL主主同步实际上是在主从同步的基础上将从数据库也提升成主数据库,让它们可以互相读写数据库,从数据库变成主数据库;主从相互授权连接,读取对方binlog日志并更新到本地数据库的过程,只要对方数据改变,自己就…...
![](https://www.ngui.cc/images/no-images.jpg)
JavaScript传参的6种方式
JavaScript传参的方式1. 传递基本类型参数2. 传递对象类型参数3. 使用解构赋值传递参数4. 使用展开运算符传递参数5. 使用可选参数6. 使用剩余参数JavaScript是一门非常灵活的语言,其参数传递方式也同样灵活。在本篇文章中,会详细介绍JavaScript中的参数…...
![](https://img-blog.csdnimg.cn/718458a73bf3420798d06a99336a70fe.png)
蓝桥之统计子矩阵
样例说明 满足条件的子矩阵一共有 19 , 包含: 大小为 11 的有 10 个。 大小为 12 的有 3 个。 大小为13 的有 2 个。 大小为 14 的有 1 个。 大小为 21 的有 3 个。 前缀和二维数组 前缀和暴力搜索 import java.util.*; public class Main{private static int ans0;pub…...
![](https://www.ngui.cc/images/no-images.jpg)
Java的基础面试题
一.java基础1.JDK和JRE有什么区别?JDK是java开发工具包,JRE是java运行时环境(包括Java基础类库,java虚拟机)2.和equals的区别是什么?比较的是两者的地址值,equals比较的是两者的内容是否一样3.两…...
![](https://img-blog.csdnimg.cn/aebef283f3a64aad864cdffecd581aa3.png#pic_center)
J1939故障码诊断说明
1:1939整体协议说明 这里主要说明1939不同的协议,对应不同的网络分层 注意了,这里只进行文档解析说明,具体查看去搜素协议的关键字进行理解 2:DMx和FMI 说明 想知道每个代号的具体含义,可以去 saeJ1939…...
![](https://img-blog.csdnimg.cn/8998adf969494f90914bf46d6e8ef934.png#pic_center)
XCPC第十三站,贪心问题
一.区间选点 我们采取这样的策略来选点:step(1)将区间按照右端点的大小从小到大排序;step(2)从前往后依次枚举每个区间,如果当前区间中已经包含点,直接pass,否则选当前区…...
![](https://img-blog.csdnimg.cn/31c78566e0e0402b9b1c3abce16b940e.png)
一文让你吃透 Vue3中的组件间通讯 【一篇通】
文章目录前情回顾前言1. 父组件 > 子组件通讯传递2. 子组件 > 父组件通讯传递3. 爷孙组件,后代组件通讯数据总结前情回顾 在本专栏前一章节中,我为大家带来了 Vue3 新特性变化上手指南 的归纳梳理,主要介绍了 Vue3 的 Proxy 响应式原理…...
![](https://www.ngui.cc/images/no-images.jpg)
EVE遭遇大规模DDOS攻击,玩家和官方都傻眼了
如果你恰好是一名《星战前夜》(EVE)的国际服玩家(虽然这个几率很小),又恰好因为疫情一直待在家里,那你就真是倒霉透顶了。因为从1月底开始,EVE的服务器就一直受到大规模的DDOS攻击,而…...
![](https://img-blog.csdnimg.cn/d03eedf736c14feabe7e3d01a21dd919.png)
【数据结构】二叉树及相关习题详解
新年新气象! 祝大家兔年 财源滚滚! 万事胜意! 文章目录前言1. 树的一些基础概念1.1 树的一些基本概念1.2 树的一些重要概念2. 二叉树的一些基本概念2.1 二叉树的结构2.2 两种特殊的二叉树3. 二叉树的性质4. 二叉树的存储5. 二叉树的基本操作5.1 构造一棵二叉树5.2 二叉树的遍历…...
![](https://img-blog.csdnimg.cn/img_convert/b3d78d5ce29046dfa2bfb959bd78c3a9.png)
锂电池充电的同时也能放电吗?
大家应该都有这样经历,我们的手机在充电的同时也能边使用,有的同学就会说了,这是因为手机电池在充电的同时也在放电。如果这样想我们可能就把锂电池类比了一个蓄水池,以为它在进水的同时也能出水,其实这个比喻是错误的…...
![](https://img-blog.csdnimg.cn/img_convert/922d1a3b06704aab9aef154b23989869.png)
通信工程考研英语复试专有名词翻译
中文英文频分多址Frequency Division Multiple Access码分多址Code Division Multiple Access时分多址Time Division Multiple Access移动通信mobile communication人工智能artificial intelligence水声通信Middle-Range Uwa Communication正交频分复用Orthogonal frequency di…...
![](https://img-blog.csdnimg.cn/ce588b4c14fa459797854759a528ac1f.png)
注意力机制(四):多头注意力
专栏:神经网络复现目录 注意力机制 注意力机制(Attention Mechanism)是一种人工智能技术,它可以让神经网络在处理序列数据时,专注于关键信息的部分,同时忽略不重要的部分。在自然语言处理、计算机视觉、语…...
![](https://www.ngui.cc/images/no-images.jpg)
【2023Unity游戏开发教程】零基础带你从小白到超神19——射线检测
文章目录 射线检测从某点发射一条射线从摄像机发射一条射线射线检测 游戏中的红外线,默认肉眼是看不到的,从某个初始点开始,沿着特定的方向发射一条不可见且无限长的射线,通过此射线检测是否有任何模型添加了Collider碰撞器组件。一旦检测到碰撞,停止射线继续发射。 碰撞检…...
![](https://img-blog.csdnimg.cn/1b921ab9984e4de6a56fbd8e21584728.png)
内存泄漏和内存溢出的区别
参考答案 内存溢出(out of memory):指程序在申请内存时,没有足够的内存空间供其使用,出现 out of memory。内存泄露(memory leak):指程序在申请内存后,无法释放已申请的内存空间,内存泄露堆积会导致内存被…...
![](https://www.ngui.cc/images/no-images.jpg)
文本三剑客之sed编辑器
文本三剑客:都是按行读取后处理。 grep 过滤行内容。awk 过滤字段。sed 过滤行内容;修改行内容。sed编辑器 sed是一种流编辑器,流编辑器会在编辑器处理数据之前基于预先提供的一组规则来编辑数据流。 sed编辑器可以根据命令来处理数据流中…...
![](https://img-blog.csdnimg.cn/514963c6d84945c385e591752b89fb02.png)
深度学习:GPT1、GPT2、GPT-3
深度学习:GPT1、GPT2、GPT3的原理与模型代码解读GPT-1IntroductionFramework自监督学习微调ExperimentGPT-2IntroductionApproachConclusionGPT-3GPT-1 Introduction GPT-1(Generative Pre-training Transformer-1)是由OpenAI于2018年发布的…...
![](https://img-blog.csdnimg.cn/bc7f8b5cd20b4ffabc707b6bf0c88373.png)
使用Docker 一键部署SpringBoot和SpringCloud项目
使用Docker 一键部署SpringBoot和SpringCloud项目 1. 准备工作2. 创建Dockerfile3. 创建Docker Compose文件4. 构建和运行Docker镜像5. 验证部署6. 总结Docker是一个非常流行的容器化技术,可以方便地将应用程序和服务打包成容器并运行在不同的环境中。在本篇博客中,我将向您展…...
![](https://img-blog.csdnimg.cn/844af129ad1146f2a05f5048d354aff7.png)
【数据结构】用栈实现队列
💯💯💯 本篇总结利用栈如何实现队列的相关操作,不难观察,栈和队列是可以相互转化的,需要好好总结它们的特性,构造出一个恰当的结构来实现即可,所以本篇难点不在代码思维,…...
![](https://img-blog.csdnimg.cn/3afb635dbeab437f9180eda75382f05f.png)
[Netty源码] 服务端启动过程 (二)
文章目录1.ServerBootstrap2.服务端启动过程3.具体步骤分析3.1 创建服务端Channel3.2 初始化服务端Channel3.3 注册selector3.4 端口绑定1.ServerBootstrap ServerBootstrap引导服务端启动流程: //主EventLoopGroup NioEventLoopGroup master new NioEventLoopGroup(); //从E…...
![](https://www.ngui.cc/images/no-images.jpg)
Week 14
代码源每日一题Div2 106. 订单编号 原题链接:订单编号 思路:这题本来没啥思路,直到获得了某位佬的提示才会做( 我们可以用set来维护一些区间,这些区间为 pair 类型,表示没有使用过的编号,每次…...
![](https://img-blog.csdnimg.cn/6aa685942b77487a82ba2a55ae150914.png#pic_center)
【微信小程序】-- 使用 Git 管理项目(五十)
💌 所属专栏:【微信小程序开发教程】 😀 作 者:我是夜阑的狗🐶 🚀 个人简介:一个正在努力学技术的CV工程师,专注基础和实战分享 ,欢迎咨询! &…...
![](https://www.ngui.cc/images/no-images.jpg)
leetcode每日一题:134. 加油站
系列:贪心算法 语言:java 题目来源:Leetcode134. 加油站 题目 在一条环路上有 n 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i1 个加油站需要消耗汽油 cost[…...
![](https://img-blog.csdnimg.cn/img_convert/54b958bb366b59b4284c0ec2f13790ab.png)
开放式基金实时排行 API 数据接口
开放式基金实时排行 API 数据接口 多维度参数返回,实时数据,类型参数筛选。 1. 产品功能 返回实时开放式基金排行数据可定义查询基金类型参数;多个基金属性值返回多维指标,一次查询毫秒级返回;数据持续更新与维护&am…...
![](https://img-blog.csdnimg.cn/504aa1a6591b45bc92273693fe60071f.png)
Android开发中synchronized的实现原理
synchronized的三种使用方式 **1.修饰实例方法,**作用于当前实例加锁,进入同步代码前要获得当前实例的锁。 没有问题的写法: public class AccountingSync implements Runnable{//共享资源(临界资源)static int i0;/*** synchronized 修饰实例方法*/p…...
![](https://www.ngui.cc/images/no-images.jpg)
【华为OD机试 2023最新 】 统一限载货物数最小值(C++)
题目描述 火车站附近的货物中转站负责将到站货物运往仓库,小明在中转站负责调度2K辆中转车(K辆干货中转车,K辆湿货中转车)。 货物由不同供货商从各地发来,各地的货物是依次进站,然后小明按照卸货顺序依次装货到中转车,一个供货商的货只能装到一辆车上,不能拆装,但是…...
![](https://img-blog.csdnimg.cn/9d2118e4d10843adae5c350ef27f7b2d.png)
【生活工作经验 十】ChatGPT模型对话初探
最近探索了下全球大火的ChatGPT,想对此做个初步了解 一篇博客 当今社会,自然语言处理技术得到了迅速的发展,人工智能技术也越来越受到关注。其中,基于深度学习的大型语言模型,如GPT(Generative Pre-train…...
![](https://img-blog.csdnimg.cn/675e6a7223364124adc93b803af73dd6.png)
基于Spring Boot房产销售平台的设计与实现【源码+论文】分享
开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 5.7 数据库工具:Navicat11 开发软件:eclipse/myeclipse/idea Maven包:Maven3.3.9 摘要 信息技术的发展…...
![](https://img-blog.csdnimg.cn/24ec1eb9e0a04924a0bf417e305f6322.jpeg)
不同类型的电机的工作原理和控制方法汇总
电机控制是指对电机的启动、调速(加速、减速)、运转方向和停止进行的控制,不同类型的电机有着不同的工作原理和控制方法。 一、无刷电机 无刷电机是由电机主体和电机驱动板组成的一种没有电刷和换向器的机电一体化产品。在无刷电机中…...
![](https://img-blog.csdnimg.cn/24b696d76d374a9992017e1625389592.gif)
计算机网络管理 TCP三次握手的建立过程,Wireshark抓包分析并验证TCP三次握手建立连接的报文
⬜⬜⬜ ---🟧🟨🟩🟦🟪 (*^▽^*)欢迎光临 🟧🟨🟩🟦🟪---⬜⬜⬜ ✏️write in front✏️ 📝个人主页:陈丹宇jmu 🎁欢迎各位→…...
![](https://img-blog.csdnimg.cn/img_convert/aac7bd8f15d34416929c0c47ca30b811.png)
HTTP/2.x:最新的网页加载技术,快速提高您的SEO排名
2.1 http2概念HTTP/2.0(又称HTTP2)是HTTP协议的第二个版本。它是对HTTP/1.x的更新,旨在提高网络性能和安全性。HTTP/2.0是由互联网工程任务组(IETF)标准化的,并于2015年发布。2.2 http2.x与http1.x区别HTTP…...
![](/images/no-images.jpg)
苹果cms网站模板下载/关键词热度
1 Elasticsearch的常见概念 索引(Index) 相当于关系型数据库中的database,是一个独立的Lucene实例。 类型(Type) 相当于关系型数据库中的table,一个索引中可以有多个type。 文档(Document) 相当于关系型数据中的row,文档由字段构成&…...
![](/images/no-images.jpg)
做网站然后推广/简述seo的概念
UDP 是User Datagram Protocol的简称, 中文名是用户数据报协议,是OSI(Open System Interconnection,开放式系统互联) 参考模型中一种无连接的传输层协议,提供面向事务的简单不可靠信息传送服务,…...
![](https://img-blog.csdnimg.cn/20200928203058171.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW96aGVnYWE=,size_16,color_FFFFFF,t_70#pic_center)
网站建设学什么/百度一下浏览器下载安装
SpringBoot使用缓存注解 文章目录 SpringBoot使用缓存注解缓存注解入门三个步骤一、入门体验缓存注解1. 创建SpringBoot项目,仅导入web和cache的依赖2. 在启动类上加上EnableCaching注解3.在方法上使用缓存注解演示效果,多次访问该方法二、整合mysql环境…...
![](https://img-blog.csdnimg.cn/92ac169c6d704fada830afa6b189087b.gif)
怎么取网页视频网站元素/网页模板建站系统
🏆今日学习目标: 🍀JDBC事务 Hibernate事务 EJB事务详解 ✅创作者:林在闪闪发光 ⏰预计时间:30分钟 🎉个人主页:林在闪闪发光的个人主页 🍁林在闪闪发光的个人社区,欢迎你…...
![](/images/no-images.jpg)
枣庄市建设局网站/seo是广告投放吗
使用Java完成Excel文件的上传、内容的解析和以及保存操作。重点主要在于使用org.apache.poi包下的Workbook类完成对Excel内容的解析首先pom文件引入Apache poi,org.apache.poipoi-ooxml3.9Apache POI提供API给Java程序对Microsoft Office(Excel、Word、PowerPoint等…...
![](https://img-blog.csdnimg.cn/img_convert/e0ed1ebb179bddf47b26d9099dbfca53.png)
自己怎么建h5商城网站/网站按天扣费优化推广
训练大纲(第121天)大家如果想快速有效的学习,思想核心是“以建立知识体系为核心”,具体方法是“守破离”。确保老师课堂上做的操作,反复练习直到熟练。第241次(httpPool&Hystrix)学习主题:httpPool&Hystrix学习目标&#…...