Day 29 MySQL的主从复制集群

一:主从复制

1.主从复制概念

什么是主从复制:

​ 主从复制,是用来建立一个和主数据库完全一样的数据库环境,称为从数据库;主数据库一般是准实时的业务数据库

主从复制的作用:

​ 做数据的热备,作为后备数据库,主数据库服务器故障后,可切换到从数据库继续工作,避免数据丢失

​ 架构的扩展,业务量越来越大,I/O访问频率过高,单机无法满足,多库的存储,降低磁盘I/O访问的频率,提高单个机器的I/O性能

​ 读写分离,使数据库能支撑更大的并发

主从复制的原理:

​ 数据库有个bin-log二进制文件,记录了所有sql语句

​ 我们的目标就是把主数据库的bin-log文件的sql语句复制到从库

​ 让其在从数据的relay-log(中继日志)重做日志文件中再执行一次这些sql语句即可

image-20220926231910240

总结:

​ 从库slave生成两个线程,i/o线程和sql线程,i/o将变更记录写到二进制日志文件中,再写到中继日志中,sql线程读取中继日志,解析操作,最终数据统一

注意:

​ I/O进程:负责通信

​ SQL进程:负责写数据,根据log日志写数据

2.主从复制部署
环境准备
节点IP地址
Master10.0.0.128
Slave10.0.0.42

注意:

​ 所有节点关闭防火墙和selinux

​ 保证yum仓库可用

​ 保证网络畅通

​ 如果是克隆的服务器需要修改每台数据库的server-uuid:vim /var/lib/mysql/auto.cnf

修改主机名:(所有节点)(可选操作)

[root@xingdian ~]# hostnamectl set-hostname master
[root@xingdian ~]# hostnamectl set-hostname slave

添加本地解析:(所有节点)(可选操作)

[root@master ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.128 master
10.0.0.42 slave[root@slave ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.128 master
10.0.0.42 slave
Master部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

主服务器部署:

[root@master ~]# vi /etc/my.cnf
log-bin = my1log
server-id = 1

创建授权账户:

[root@master ~]# 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 3
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> grant all on *.* to 'slave'@'%' identified by 'QianFeng@123';
mysql> flush privileges;
mysql> exit
Bye

重启服务:

[root@master ~]# systemctl restart mysqld

注意:

replication slave:

​ 拥有此权限可以查看从服务器,从主服务器读取二进制日志

super权限:

​ 允许用户使用修改全局变量的SET语句以及CHANGE MASTER语句

reload权限:

​ 必须拥有reload权限,才可以执行flush [tables | logs | privileges]

Slave部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

从服务器部署:

[root@slave ~]# vi /etc/my.cnf
log-bin = my2log
server-id = 2

重启服务:

[root@slave ~]# systemctl restart mysqld

获取主服务器信息:(主服务器操作)

[root@master ~]# 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-log 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 binlog events;
+---------------+-----+----------------+-----------+-------------+---------------------------------------+
| Log_name      | Pos | Event_type     | Server_id | End_log_pos | Info                                  |
+---------------+-----+----------------+-----------+-------------+---------------------------------------+
| my1log.000001 |   4 | Format_desc    |         1 |         123 | Server ver: 5.7.39-log, Binlog ver: 4 |
| my1log.000001 | 123 | Previous_gtids |         1 |         154 |                                       |
+---------------+-----+----------------+-----------+-------------+---------------------------------------+
2 rows in set (0.00 sec)

指定主服务器信息:(从服务器操作)

[root@slave ~]# 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-log 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> edit-> ;
Query OK, 0 rows affected, 2 warnings (0.01 sec)注意:edit中添加的内容
CHANGE MASTER TOMASTER_HOST='master',MASTER_USER='slave',  MASTER_PASSWORD='QianFeng@123',MASTER_PORT=3306,MASTER_LOG_FILE='my1log.000001',MASTER_LOG_POS=4, MASTER_CONNECT_RETRY=10;  参数解释:
CHANGE MASTER TOMASTER_HOST='mysql-master-1.blackmed.cn/ip',MASTER_USER='slave',  //主服务器用户MASTER_PASSWORD='big',MASTER_PORT=3306,MASTER_LOG_FILE='master2-bin.001', //日志文件MASTER_LOG_POS=4, //日志位置MASTER_CONNECT_RETRY=10;  //默认尝试次数
获取参数:
mysql> help change master to

启动slave:

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

注意:

​ stop slave;停止slave

​ reset master;删除所有的binglog日志文件,并将日志索引文件清空,重新开始所有新的日志文件;用于第一次进行搭建主从库时,进行主库binlog初始化工作

​ reset slave;用于删除SLAVE数据库的relaylog日志文件,并重新启用新的relaylog文件

查看主从状态:

mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: masterMaster_User: slaveMaster_Port: 3306Connect_Retry: 10Master_Log_File: my1log.000001Read_Master_Log_Pos: 154Relay_Log_File: slave-relay-bin.000002Relay_Log_Pos: 361Relay_Master_Log_File: my1log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 154Relay_Log_Space: 568Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 85c6acc4-3db0-11ed-b302-000c29311164Master_Info_File: /var/lib/mysql/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 
1 row in set (0.00 sec)

注意:

​ Slave_IO_Running: Yes

​ Slave_SQL_Running: Yes

验证:

​ 主服务器创建数据:

mysql> create database t1;
Query OK, 1 row affected (0.00 sec)

​ 从服务器查看数据:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| t1                 |
+--------------------+
5 rows in set (0.00 sec)

二:GTID主从复制

1.GTID概念

​ GTID基于事务ID复制

​ GTID全局事务标识(global transaction identifiers)+

​ 是用来代替传统复制的方法,GTID复制与普通复制模式的最大不同就是不需要指定二进制文件名和位置

​ 不再使用MASTER_LOG_FILE+MASTER_LOG_POS开启复制。而是使用MASTER_AUTO_POSTION=1的方式开始复制

2.GTID组成

​ GTID = source_id:transaction_id

​ source_id源id,用于鉴别原服务器,即mysql服务器唯一的server_uuid,由于GTID会传递到slave,所以也可以理解为源ID

​ transaction_id事务id,为当前服务器上已提交事务的一个序列号,通常从1开始自增长的序列,一个数值对应一个事务

示例:

​ 3E11FA47-71CA-11E1-9E33-C80AA9429562:23

​ 前面的一串为服务器的server_uuid

​ 后面的23为transaction_id

3.GTID工作原理

​ master更新数据时,会在事务前产生GTID,一同记录到binlog日志中

​ slave端的i/o 线程将变更的binlog,写入到本地的relay log中

​ sql线程从relay log中获取GTID,然后对比slave端的binlog是否有记录

​ 如果有记录,说明该GTID的事务已经执行,slave会忽略

​ 如果没有记录,slave就会从relay log中执行该GTID的事务,并记录到binlog

4.主从部署

​ 注意:实验之前环境初始化,不要有残留的数据

环境准备
节点IP地址
Master10.0.0.128
Slave10.0.0.42

注意:

​ 所有节点关闭防火墙和selinux

​ 保证yum仓库可用

​ 保证网络畅通

​ 如果是克隆的服务器需要修改每台数据库的server-uuid

修改主机名:(所有节点)(可选操作)

[root@xingdian ~]# hostnamectl set-hostname master
[root@xingdian ~]# hostnamectl set-hostname slave

添加本地解析:(所有节点)(可选操作)

[root@master ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.128 master
10.0.0.42 slave[root@slave ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.128 master
10.0.0.42 slave
Master部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

主服务器部署:

[root@master ~]# vim /etc/my.cnf
log-bin
server-id=1
gtid_mode = ON
enforce_gtid_consistency=1

创建授权用户:

[root@master ~]# 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 3
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> grant all on *.* to slave@'%' identified by 'QianFeng@123';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye

重启服务:

[root@master ~]# systemctl restart mysqld
Slave部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

从服务器部署:

[root@slave ~]# vim /etc/my.cnf
log-bin
server-id=2
gtid_mode = ON
enforce_gtid_consistency=1
relay_log_recovery  = on
master-info-repository=TABLE
relay-log-info-repository=TABLE
//这两个参数会将master.info和relay.info保存在表中,默认是Myisam引擎,官方建议用

重启服务:

[root@slave ~]# systemctl restart mysqld

配置连接主服务器:

[root@slave ~]# 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-log 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> change master to-> master_host='master',-> master_user='slave',-> master_password='QianFeng@123',-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

启动Slave:

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

主从状态验证:

mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: masterMaster_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: master-bin.000001Read_Master_Log_Pos: 154Relay_Log_File: slave-relay-bin.000002Relay_Log_Pos: 369Relay_Master_Log_File: master-bin.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 154Relay_Log_Space: 576Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 00813e87-4321-11ed-a33c-000c29311164Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 
1 row in set (0.00 sec)

数据验证:

主服务器创建数据:

[root@master ~]# 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 3
Server version: 5.7.39-log 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> create database qfcloud;
Query OK, 1 row affected (0.00 sec)mysql> exit
Bye

从服务器查验数据:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| qfcloud            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

三:GTID双主双从

1.环境准备

注意:

​ 实验之前环境初始化,不要有残留的数据

​ 先做双主,M-M互为主从,从是双主的从

节点IP地址
Master-110.0.0.128
Master-210.0.0.46
Slave-110.0.0.42
Slave-210.0.0.45

注意:

​ 所有节点关闭防火墙和selinux

​ 保证yum仓库可用

​ 保证网络畅通

如果是克隆的服务器需要修改每台数据库的server-uuid
在这里插入图片描述

2.Master-1部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

主服务器一部署:

[root@master-1 ~]# vim /etc/my.cnf
log-bin = my1log
server-id = 1
gtid_mode=ON
enforce_gtid_consistency=1

创建授权账户:

[root@master-1 ~]# 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 4
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> grant all on *.* to 'slave'@'%' identified by 'QianFeng@123';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye

重启服务:

[root@master-1 ~]# systemctl restart mysqld
3.Master-2部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

主服务器二部署:

[root@master-2 ~]# vim /etc/my.cnf
log-bin = my2log
server-id = 2 
gtid_mode=ON
enforce_gtid_consistency=1

创建授权账户:

[root@master-2 ~]# 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 4
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> grant all on *.* to 'slave'@'%' identified by 'QianFeng@123';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye

重启服务:

[root@master-2 ~]# systemctl restart mysqld
4.双主互为主从

Master-1:

[root@master-1 ~]# 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 3
Server version: 5.7.39-log 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> change master to-> master_host='master-2',-> master_user='slave',-> master_password='QianFeng@123',-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-2Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my2log.000001Read_Master_Log_Pos: 154Relay_Log_File: master-1-relay-bin.000002Relay_Log_Pos: 361Relay_Master_Log_File: my2log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 154Relay_Log_Space: 571Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 2Master_UUID: 1b453d94-452e-11ed-b744-000c2936b606Master_Info_File: /var/lib/mysql/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 
1 row in set (0.00 sec)mysql> exit
Bye

Master-2:

[root@master-2 ~]# 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 3
Server version: 5.7.39-log 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> change master to-> master_host='master-1',-> master_user='slave',-> master_password='QianFeng@123',-> master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-1Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my1log.000001Read_Master_Log_Pos: 587Relay_Log_File: master-2-relay-bin.000002Relay_Log_Pos: 794Relay_Master_Log_File: my1log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 587Relay_Log_Space: 1004Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 146f4cae-452e-11ed-b87f-000c29311164Master_Info_File: /var/lib/mysql/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 
1 row in set (0.00 sec)mysql> exit
Bye
5.Slave-1部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

从服务器一部署:

[root@slave-1 ~]# vim /etc/my.cnf
log-bin = my3log    
server-id = 3
gtid_mode=ON
enforce_gtid_consistency=1
relay_log_info_repository = TABLE
master_info_repository    = TABLE
relay_log_recovery        = on当slave从库宕机后,假如relay-log损坏了,导致一部分中继日志没有处理,则自动放弃所有未执行的relay-log,并且重新从master上获取日志,这样就保证了relay-log的完整性

重启服务:

[root@slave-1 ~]# systemctl restart mysqld

从连接主服务器:

[root@slave-1 ~]# 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-log 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> CHANGE MASTER TO-> MASTER_HOST='master-1',-> MASTER_USER='slave',-> MASTER_PASSWORD='QianFeng@123',-> MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-1';
Query OK, 0 rows affected, 2 warnings (0.00 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-1Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my1log.000001Read_Master_Log_Pos: 587Relay_Log_File: slave-1-relay-bin-master@002d1.000002Relay_Log_Pos: 794Relay_Master_Log_File: my1log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 587Relay_Log_Space: 1016Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 146f4cae-452e-11ed-b87f-000c29311164Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: master-1Master_TLS_Version: 
1 row in set (0.00 sec)mysql> CHANGE MASTER TO-> MASTER_HOST='master-2',-> MASTER_USER='slave',-> MASTER_PASSWORD='QianFeng@123',-> MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-2';
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-1Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my1log.000001Read_Master_Log_Pos: 587Relay_Log_File: slave-1-relay-bin-master@002d1.000002Relay_Log_Pos: 794Relay_Master_Log_File: my1log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 587Relay_Log_Space: 1016Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 146f4cae-452e-11ed-b87f-000c29311164Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: master-1Master_TLS_Version: 
*************************** 2. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-2Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my2log.000001Read_Master_Log_Pos: 154Relay_Log_File: slave-1-relay-bin-master@002d2.000002Relay_Log_Pos: 361Relay_Master_Log_File: my2log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 154Relay_Log_Space: 583Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 2Master_UUID: 1b453d94-452e-11ed-b744-000c2936b606Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: master-2Master_TLS_Version: 
2 rows in set (0.00 sec)
6.Slave-2部署

安装数据库:(略)

启动数据库:(略)

修改数据库初始密码:(略)

从服务器二部署:

[root@slave-2 ~]# vim /etc/my.cnf
log-bin = my4log    
server-id = 4
gtid_mode=ON
enforce_gtid_consistency=1
relay_log_info_repository = TABLE
master_info_repository    = TABLE
relay_log_recovery        = on

重启服务:

[root@slave-2 ~]# systemctl restart mysqld

从连接主服务器:

[root@slave-2 ~]# 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-log 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> CHANGE MASTER TO-> MASTER_HOST='master-1',-> MASTER_USER='slave',-> MASTER_PASSWORD='QianFeng@123',-> MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-1';
Query OK, 0 rows affected, 2 warnings (0.01 sec)mysql> start slave;
Query OK, 0 rows affected (0.00 sec)mysql> CHANGE MASTER TO-> MASTER_HOST='master-2',-> MASTER_USER='slave',-> MASTER_PASSWORD='QianFeng@123',-> MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-2';
Query OK, 0 rows affected, 2 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 master to send eventMaster_Host: master-1Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my1log.000001Read_Master_Log_Pos: 587Relay_Log_File: slave-2-relay-bin-master@002d1.000002Relay_Log_Pos: 794Relay_Master_Log_File: my1log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 587Relay_Log_Space: 1016Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1Master_UUID: 146f4cae-452e-11ed-b87f-000c29311164Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: master-1Master_TLS_Version: 
*************************** 2. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: master-2Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: my2log.000001Read_Master_Log_Pos: 154Relay_Log_File: slave-2-relay-bin-master@002d2.000002Relay_Log_Pos: 361Relay_Master_Log_File: my2log.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_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: 154Relay_Log_Space: 583Until_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: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 2Master_UUID: 1b453d94-452e-11ed-b744-000c2936b606Master_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: 146f4cae-452e-11ed-b87f-000c29311164:1-2Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: master-2Master_TLS_Version: 
2 rows in set (0.00 sec)
7.验证

主服务器创建数据:

[root@master-1 ~]# 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 9
Server version: 5.7.39-log 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> create database qfcloud;
Query OK, 1 row affected (0.00 sec)mysql> exit
Bye

其他服务器验证:

[root@master-2 ~]# 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 8
Server version: 5.7.39-log 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 |
| qfcloud            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)[root@slave-1 ~]# 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 8
Server version: 5.7.39-log 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 |
| qfcloud            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)[root@slave-2 ~]# 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-log 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 |
| qfcloud            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

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

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

相关文章

GPU云渲染平台选择应该看什么?瑞云渲染带你了解

在选择GPU云渲染平台时,关键的考量因素包括渲染速度、支持的软件兼容性、价格性价比以及用户服务质量。了解这些指标将帮助用户在众多选项中做出明智的选择,以优化渲染效率和成本效益。 一、GPU与渲染有什么关系 GPU与渲染有着密切的关系,在…

springboot增删改查

我的记录 RestController RequestMapping("/user") public class UserController {Autowiredprivate UserService userService;GetMapping("/list")public List<User> list(){return userService.list();}//新增PostMapping("/save")publi…

AS-VJ900实时视频拼接系统产品介绍:两画面视频拼接方法和操作

目录 一、实时视频拼接系统介绍 &#xff08;一&#xff09;实时视频拼接的定义 &#xff08;二&#xff09;无缝拼接 &#xff08;三&#xff09;AS-VJ900功能介绍 1、功能 2、拼接界面介绍 二、拼接前的准备 &#xff08;一&#xff09;摄像机选择 &#xff08;二&a…

基于FPGA实现的HDMI TO MIPI扩展显示器方案

FPGA方案&#xff0c;HDMI IN接收原始HDMI 信号&#xff0c;输出显示到LCD 屏上 客户应用&#xff1a;扩展显示器 主要特性&#xff1a; 1.支持2K以下任意分辨率显示 2.支持OSD 叠加多个图层 3.支持MIPI/EDP/LVDS/RGB屏 4.支持放大缩小匹配屏分辨率 5.零延时&#xff0c;输…

《ESP8266通信指南》15-MQTT连接、订阅MQTT主题并打印消息(基于Lua|适合新手|非常简单)

往期 《ESP8266通信指南》14-连接WIFI&#xff08;基于Lua&#xff09;-CSDN博客 《ESP8266通信指南》13-Lua 简单入门&#xff08;打印数据&#xff09;-CSDN博客 《ESP8266通信指南》12-Lua 固件烧录-CSDN博客 《ESP8266通信指南》11-Lua开发环境配置-CSDN博客 《ESP826…

【前端基础】CSS样式+Vue中绘制时间轴

深度选择器 在 Vue.js 中&#xff0c;/deep/、>>>、:deep 和 ::v-deep 这些都是深度选择器&#xff0c;用于修改子组件的样式。它们主要用于解决作用域样式和组件样式之间的冲突问题。 1. /deep/ 或 >>> /deep/ 和 >>> 是相同的选择器&#xff0c;…

【智能算法】正切搜索算法(TSA)原理及实现

目录 1.背景2.算法原理2.1算法思想2.2算法过程 3.结果展示4.参考文献5.代码获取 1.背景 2022年&#xff0c;A Layeb受到正切函数启发&#xff0c;提出了正切搜索算法&#xff08;Tangent Search Algorithm, TSA&#xff09;。 2.算法原理 2.1算法思想 TSAT基于正切函数的数学…

vue3对象数组格式的动态表单校验

如你有一个表单&#xff0c;表单内容是对象&#xff0c;但是对象内还有可动态循环的数组进行动态表单校验。 效果如图&#xff1a;查看源码 页面内容&#xff1a; <div class"arrForm-Box"><el-form :model"state.formData" :rules"rule…

mysql数据库调优篇章1--日志篇

目录 1.认识数据库中日志的作用2.增加mysql数据库中my.ini 基本配置3.增加my.ini中参数配置4.查看已经执行过的sql语句过去执行时间5.找出慢查询的sql6.常用参数查询命令7.认识慢查询日志记录8.认识通用日志记录&#xff08;记录增删改查操作&#xff09;9.认识二进制文件binlo…

一文了解spring事务特性

推荐工具 objectlog 对于重要的一些数据&#xff0c;我们需要记录一条记录的所有版本变化过程&#xff0c;做到持续追踪&#xff0c;为后续问题追踪提供思路。objectlog工具是一个记录单个对象属性变化的日志工具,工具采用spring切面和mybatis拦截器相关技术编写了api依赖包&a…

数据结构学习/复习12

一、排序概念与应用 二、插入排序 三、希尔排序 当间隔数为1时则为插入排序 1.一组一组排 2.多组并排 3.间隔数变化直至为1 四、性能测速代码

Java类加载器介绍

在Java中&#xff0c;类加载器是一种动态加载类的机制&#xff0c;它负责在运行时查找、加载和链接类文件。当Java应用程序需要创建某个类的对象时&#xff0c;类加载器会在运行时查找该类对应的.class文件&#xff0c;并将其加载到Java虚拟机中。Java类加载器通常分为三层&…

【Android】Kotlin学习之数据容器(数组for循环遍历)

数组遍历 1. for ( item in arr){…} 2. for ( i in arr.indeces ) {…} (遍历下标) 3. for ((index, item) in arr.withInfex()) {…} (遍历下标和元素) 4. arr.forEach {} ( 遍历元素 ) 5. arr.forEachIndexed{index, item -> …}

Python尝试安装 pyaudio 时遇到的错误信息表示安装过程失败,原因是找不到 Python.h 头文件

环境&#xff1a; Python 3.8.10 WSL2 问题描述&#xff1a; 尝试安装 pyaudio 时遇到的错误信息表示安装过程失败&#xff0c;原因是找不到 Python.h 头文件 error: subprocess-exited-with-error Building wheel for pyaudio (pyproject.toml) did not run successfully…

大模型微调之 在亚马逊AWS上实战LlaMA案例(七)

大模型微调之 在亚马逊AWS上实战LlaMA案例&#xff08;七&#xff09; 微调SageMaker JumpStart上的LLaMA 2模型 这是在us-west-2的测试结果。 展示了如何使用SageMaker Python SDK部署预训练的Llama 2模型&#xff0c;并将其微调到你的数据集&#xff0c;用于领域适应或指令…

【Nginx】如何在 Nginx 中阻止来自特定国家的 IP 地址访问

文章目录 前言一、准备工作二、查看 Nginx 服务器都拥有哪些模块2.1 先查看本地nginx是否有ngx_http_geoip2模块2.2 安装nginx并配置ngx_http_geoip2模块2.2.1下载所需版本的nginx到服务器2.2.2 先安装所需依赖2.2.3 解压文件2.2.4 下载ngx_http_geoip2模块2.2.5 编译安装nginx…

通用型产品发布解决方案(后端环境搭建)

文章目录 后端renren脚手架配置1.解压后放到项目目录下2.新建商品模块1.创建一个新模块 sunliving-commodity2.删除两个不必要的文件3.pom.xml 引入依赖 3.maven进行聚合管理1.将刚才配置的pom.xml文件复制到父项目下并进行修改2.手动将这个pom.xml加入项目&#xff08;如果右下…

算法设计与分析 动态规划/回溯

1.最大子段和 int a[N]; int maxn(int n) {int tempa[0];int ans0;ansmax(temp,ans);for(int i1;i<n;i){if(temp>0){tempa[i];}else tempa[i];ansmax(temp,ans);}return ans; } int main() {int n,ans0;cin>>n;for(int i0;i<n;i) cin>>a[i];ansmaxn(n);co…

H5 处理点击元素高亮、自定义按钮、去除焦点边框

1、设置移动设备上点击元素时出现的高亮颜色 *{-webkit-tap-highlight-color: transparent; }2、如果你想要自定义按钮的样式&#xff0c;你可以使用 -webkit-appearance: none; 来移除按钮的默认样式 .button {-webkit-appearance: none;appearance: none; /* 兼容性更好的通…

光检测器——光纤通信学习笔记七

光检测器 光检测器的基本介绍 作用&#xff1a;把接受到的光信号转换成电信号 光接收器的灵敏度、光源的发光功率和光纤的损耗三者决定了光纤通信的传输距离&#xff1b; 光电二极管 光电转换的基本原理 之前提到&#xff0c;PN结由于内部载流子的扩散运动形成了内部电场&…