MySQL数据库实现主主同步

news2024/10/7 2:24:14

前言

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.9192.168.116.166(master1)mysql8.0
CentOS7.9192.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.32

Copyright (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 - GPL

Copyright (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,这个是第二台服务器,因此idauto_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 event
                  Master_Host: 192.168.116.166
                  Master_User: master1
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 157
               Relay_Log_File: master2-relay-bin.000002
                Relay_Log_Pos: 326
        Relay_Master_Log_File: mysql-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: demo_db
          Replicate_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 source
                  Master_Host: 192.168.116.128
                  Master_User: master2
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000004
          Read_Master_Log_Pos: 157
               Relay_Log_File: master1-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000004
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Replicate_Do_DB: demo_db
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 157
              Relay_Log_Space: 157
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 2003
                Last_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: 0
               Last_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 daemon
   Loaded: 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 ago
     Docs: man:firewalld(1)
 Main PID: 804 (code=exited, status=0/SUCCESS)

210 10:51:06 localhost.localdomain systemd[1]: Starting firewalld - dynamic f....
210 10:51:10 localhost.localdomain systemd[1]: Started firewalld - dynamic fi....
210 10:51:11 localhost.localdomain firewalld[804]: WARNING: AllowZoneDrifting ...
210 10:52:44 localhost.localdomain systemd[1]: Stopping firewalld - dynamic f....
210 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 daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2023-03-25 15:28:38 CST; 2s ago
     Docs: man:firewalld(1)
 Main PID: 70425 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─70425 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

325 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...).
325 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.
325 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...).
325 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...).
325 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 event
                  Master_Host: 192.168.116.128
                  Master_User: master2
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000004
          Read_Master_Log_Pos: 157
               Relay_Log_File: master1-relay-bin.000006
                Relay_Log_Pos: 373
        Relay_Master_Log_File: mysql-bin.000004
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: demo_db
          Replicate_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 - GPL

Copyright (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 - GPL

Copyright (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 -A

Database 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数据库实现主从同步》就会发现主主同步,也只是在主从同步上再反过来操作一次主从同步。若觉得以上内容还行的,可以点赞支持一下!
在这里插入图片描述

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

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

相关文章

K均值聚类分析流程

K均值聚类分析流程 一、案例背景 在某体育赛事中,意大利、韩国、罗马尼亚、法国、中国、美国、俄罗斯七个国家的裁判对300名运动员进行评分,现在想要通过评分上的差异将300名选手进行分类,计划将选手分为高水平、中水平、低水平三个类别。因…

Unity2D 商业游戏案例 - 梦幻西游(第二季 框架设计篇)

00 网址 来源 siki学院的(1年有限期到期前下载的项目,现在已经过期,所以自己理清项目) 所以更多的不是学习这个项目,而是学习理清该类型的项目的思路 Unity2D 商业游戏案例 - 梦幻西游(第二季 框架设计篇&…

python+vue 在线考试系统的设计与实现

1.用户登录 用户要通过本系统查询对课程信息进行下载,必须先输入用户名和密码进行登陆。为了避免非其他人员都可以获得登陆权限,登陆系统不设注册过程,所有用户和教师的登陆信息将事先由管理人员直接对数据库进行录入。 2.教师 教师登录系统后…

【排序】排序这样写才对Ⅱ -冒泡排序与快速排序Ⅰ

Halo,这里是Ppeua。平时主要更新C语言,C,数据结构算法......感兴趣就关注我吧!你定不会失望。 🌈个人主页:主页链接 🌈算法专栏:专栏链接 我会一直往里填充内容哒! &…

【Spring6】| Spring6整合JUnit

目录 一:Spring6整合JUnit 1. Spring对JUnit4的支持 2. Spring对JUnit5的支持 一:Spring6整合JUnit 1. Spring对JUnit4的支持 准备工作:pom.xml 注:以前是直接使用单元测试Junit,现在使用Spring对Junit的整合&…

快递电子运单上,电话应隐藏6位以上,禁止显示这些信息

我国快递年业务量达千亿件,快递电子运单是应用于快递外包装的重要单据,每年耗用量很大。在强化个人信息保护方面,《快递电子运单》国家标准要求快递企业、电商经营主体等采取措施,避免在电子运单上显示完整的收寄件人个人信息。 …

【机器学习】P14 Tensorflow 使用指南 Dense Sequential Tensorflow 实现

Tensorflow 第一节:使用指南Tensorflow 安装神经网络一些基本概念隐藏层和输出层:神经元的输出公式Tensorflow 全连接层 Dense 与 顺序模型 SequentialDense LayerSequential Model代码实现一个神经网络实现方式一:手写神经网络* 实现方式二&…

JavaScript基础入门全解析(上)

JavaScript基础语法 什么是JavaScript(简称js) 1.首先了解前端页面的组成(前端页面的三层结构) ●HTML 表示了你的页面内有什么,组成页面的骨架 (结构层) ●CSS 表示了你的页面中每一个内容是…

Linux系统中安装新版本nacos(centos7)

1. 背景需求 由于一些限制,在客户现场的Linux操作系统中,没有安装docker k8s等容器,无法直接使用镜像安装,而且客户要求只能在原始的操作系统中安装最新版的nacos,(为什么需要安装最新版的nacos,因为检测国网检测到之前版本的nacos有漏洞,需要安装新版的nacos). 2. 下载nacos…

Windows10+Cmake+VS2019编译opencv

主要参考:Windows10CmakeVS2019编译opencv(超级详细)_vs编译opencv_乐安世家的博客-CSDN博客 OpenCV:Releases - OpenCV 想直接简单使用的话,不需要自己编译,下载编译好的就可以 假如需要用到opencv-contr…

【Python入门第四十九天】Python丨NumPy 数组拆分

拆分 NumPy 数组 拆分是连接的反向操作。 连接(Joining)是将多个数组合并为一个,拆分(Spliting)将一个数组拆分为多个。 我们使用 array_split() 分割数组,将要分割的数组和分割数传递给它。 实例 将数…

Docker教程:如何将Helix QAC创建为一个容器并运行?

在这个Docker教程中,你将了解到如何将Helix QAC创建为一个容器化的镜像并运行。 Docker的基本定义是一个开源且流行的操作系统级虚拟化(通常称为“容器化”)技术,它是轻量级且可移植的,主要在Linux和Windows上运行。D…

Linux主机 SSH 通过密钥登录

我们一般使用 PuTTY 等 SSH 客户端来远程管理 Linux 服务器。但是,一般的密码方式登录,容易有密码被暴力破解的问题。所以,一般我们会将 SSH 的端口设置为默认的 22 以外的端口,或者禁用 root 账户登录。其实,有一个更…

换电脑 NoteExpress 数据备份迁移

前言 主要操作是跟着这篇博客做的:NoteExpress数据库备份和转移。但也有一些不一样的地方 旧电脑NoteExpress(NE)版本3.7,新电脑版本3.8 旧电脑 导出配置文件 桌面找到图标,打开位置,点击配置备份(绿色的图标&#…

水库安全运行智慧管理平台解决方案筑牢防汛“安全墙”

解决方案 水库安全运行智慧管理系统解决方案,系统主要由降雨量监测站、水库水位监测站、大坝安全监测中的渗流量、渗流压力和变形监测站及视频和图像监测站等站点组成,同时建立规范、统一的监测平台,集数据传输、信息共享、数据储存于一体&a…

图解HTTP阅读笔记:第4章 返回结果的HTTP状态码

《图解HTTP》第四章读书笔记 图解HTTP第4章:返回结果的HTTP状态码4.1 状态码告知从服务器端返回的请求结果4.2 2XX成功4.2.1 200 OK4.2.2 204 No Content4.2.3 206 Parital Content4.3 3XX重定向4.3.1 301 Moved Permanently4.3.2 302 Found4.3.3 303 See Other4.3.…

服务(第三篇)Apache配置与应用

httpd服务支持的虚拟主机类型包括以下三种: 1.基于域名:为每个虚拟主机使用不同的域名,但是其对应的 IP 地址是相同的。 2.基于IP地址:为每个虚拟主机使用不同的域名,且各自对应的IP地址也不相同。这种方式需要为服务器配备多个网…

Femto基站及其射频方案

关于部署3G femto基站 3GPP定义第三代移动通信的目的是要为客户提供全方位的移动多媒体体验。但很多条件下,这一目的并未实现,尤其是在边远地区或居民聚集区。 一个可行的解决方案是在家庭范围内部署无需宏node-B基站即可提供最大移动数据速率的家用基站…

26基于模型预测控制MPC的永磁同步电机MATLAB代码

资源地址: 基于模型预测控制(MPC)的永磁同步电机Matlab代码-电子商务文档类资源-CSDN文库 主要内容: 包含单电流环MPC仿真(仅电流环使用MPC策略,速度环使用PI调节器)、速度环和电流环MPC仿真…

C ++匿名函数:揭开C++ Lambda表达式的神秘面纱

潜意识编程:揭秘C Lambda表达式的神秘面纱 Subconscious Programming: Unveiling the Mystery of C Lambda Expressions 引言:Lambda表达式的魅力 (The Charm of C Lambda Expressions)Lambda表达式简介与基本概念 (Introduction and Basic Concepts of …