MySQL主从同步数据库环境部署

本次部署的是MySQL主从环境的数据库信息

IP用途
134.80.21.140Master
134.80.21.141Slave

下面部署的详细配置

1.卸载系统自带的Mariadb

[root@mysql-master ~]# rpm -qa |grep -i mariadb
mariadb-libs-5.5.68-1.el7.x86_64
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps

2.检查mysql是否存在,如果存在,卸载重装

[root@mysql-master ~]# rpm -qa |grep -i mysql
[root@mysql-master ~]#

3.查看mysql的用户组是否存在,如果不存在,则创建

[root@mysql-master ~]# cat /etc/group |grep -i mysql
[root@mysql-master ~]# cat /etc/passwd |grep -i mysql
[root@mysql-master ~]# groupadd mysql
[root@mysql-master ~]# useradd -g mysql mysql
[root@mysql-master ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

4.下载mysql的安装包,如果是内网环境的话,上传mysql的安装包即可

[root@mysql-master opt]# ls -ltr
total 640572
-rw-r--r--. 1 root root 655943415 Jan 26 22:04 mysql-5.7.44-linux-glibc2.12-i686.tar.gz
[root@mysql-master opt]# tar -xvf mysql-5.7.44-linux-glibc2.12-i686.tar.gz
[root@mysql-master opt]# ls -ltr
total 640572
-rw-r--r--. 1 root root 655943415 Jan 26 22:04 mysql-5.7.44-linux-glibc2.12-i686.tar.gz
drwxr-xr-x. 9 root root       129 Jan 26 22:06 mysql-5.7.44-linux-glibc2.12-i686
解压后将安装目录拷贝到指定的安装目录下
[root@mysql-master opt]# mv mysql-5.7.44-linux-glibc2.12-i686 /usr/local/
[root@mysql-master opt]# cd /usr/local/
[root@mysql-master local]# mv mysql-5.7.44-linux-glibc2.12-i686 mysql

5.更改属组

[root@mysql-master local]# chown -R mysql:mysql mysql

6.在/etc下创建配置文件

[root@mysql-master mysql]# cd /etc/
[root@mysql-master etc]# touch my.cnf
[root@mysql-master etc]# vi my.cnf
[root@mysql-master etc]#
[root@mysql-master etc]#
[root@mysql-master etc]# cat my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
[root@mysql-master etc]# chmod 777 my.cnf
创建数据库数据文件存放的路径并赋权datadir=/data
[root@mysql-master etc]# mkdir -p /data
[root@mysql-master etc]# chown -R mysql:mysql /data

7.安装mysql

[root@mysql-master etc]# cd /usr/local/mysql/
[root@mysql-master mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data
mysql_install_db: [Warning] World-writable config file '/etc/my.cnf' is ignored.
2024-01-26 22:29:26 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2024-01-26 22:29:29 [WARNING] The bootstrap log isn't empty:
2024-01-26 22:29:29 [WARNING] mysqld: [Warning] World-writable config file '/etc/my.cnf' is ignored.[root@mysql-salve mysql]# cd support-files/
[root@mysql-salve support-files]# ll
total 24
-rw-r--r--. 1 mysql mysql   773 Oct 11 07:42 magic
-rwxr-xr-x. 1 mysql mysql  1061 Oct 11 08:01 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql   894 Oct 11 08:01 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Oct 11 08:01 mysql.server
[root@mysql-salve support-files]# cp -p mysql.server /etc/init.d/mysqld
[root@mysql-salve support-files]# chmod +x /etc/init.d/mysqld
[root@mysql-master data]# /etc/init.d/mysqld restart
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.ERROR! MySQL server PID file could not be found!
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Logging to '/usr/local/mysql/data/mysql-master.err'.SUCCESS!
  1. 设置开机自启
[root@mysql-master data]# chkconfig --level 35 mysqld on
[root@mysql-master data]# chkconfig --list mysqldNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@mysql-master data]# chmod +x /etc/rc.d/init.d/mysqld
[root@mysql-master data]# chkconfig --add mysqld
[root@mysql-master data]# chkconfig --list mysqldNote: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

9.设置环境变量

export PATH=$PATH:/usr/local/mysql/bin
[root@mysql-master data]# source /etc/profile

10.获得mysql初始密码

[root@mysql-master data]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2024-01-26 22:52:06
Glx%;pC3plj(
修改密码
[root@mysql-master data]# mysql -uroot -p
mysql: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44Copyright (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.

更改root用户的密码

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> use mysql
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> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
添加远程访问权限
mysql> select host,user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
重启mysql服务
[root@mysql-salve mysql]# /etc/init.d/mysqld restart
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Shutting down MySQL.. SUCCESS!
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.SUCCESS!

开启3306的端口

[root@mysql-salve mysql]# firewall-cmd --add-port=3306/tcp
success
[root@mysql-salve mysql]# firewall-cmd --query-port=3306/tcp
yes
[root@mysql-salve mysql]# firewall-cmd --reload
success

设置数据库的主从同步

1.开启主库的binlog日志

[root@mysql-master ~]# cat /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M#开启GTID
gtid_mode=ON
enforce_gtid_consistency=true#节点ID,确保唯一
server-id = 1
#开启mysql的binlog日志功能
log-bin = mysql-bin
#控制数据库的binlog刷到磁盘上去 , 0不控制,性能最好,1每次事物提交都会刷到日志文件中,性能最差,最安全
sync_binlog = 1
#binlog日志格式
binlog_format = row
#binlog过期清理时间
expire_logs_days = 7
#binlog每个日志文件大小
max_binlog_size = 100m
#binlog缓存大小
binlog_cache_size = 4m
#最大binlog缓存大小
max_binlog_cache_size = 512m
#不生成日志文件的数据库,多个忽略数据库可以用逗号拼接,或者 复制黏贴下述配置项,写多行
binlog-ignore-db = mysql
# 表中自增字段每次的偏移量
auto-increment-offset = 1
# 表中自增字段每次的自增量
auto-increment-increment = 1
#跳过从库错误
slave-skip-errors = all重启数据库
[root@mysql-master etc]# /etc/init.d/mysqld restart
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Shutting down MySQL.. SUCCESS!
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.SUCCESS!

从库配置

[root@mysql-salve ~]# cat /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
#开启GTID
gtid_mode=ON
enforce_gtid_consistency=trueserver-id = 2
relay-log = mysql-relay-bin#开启mysql的binlog日志功能
log-bin = mysql-bin
#控制数据库的binlog刷到磁盘上去 , 0不控制,性能最好,1每次事物提交都会刷到日志文件中,性能最差,最安全
sync_binlog = 1
#binlog日志格式
binlog_format = row
#binlog过期清理时间
expire_logs_days = 7
#binlog每个日志文件大小
max_binlog_size = 100m
#binlog缓存大小
binlog_cache_size = 4m
#最大binlog缓存大小
max_binlog_cache_size = 512m
#不生成日志文件的数据库,多个忽略数据库可以用逗号拼接,或者 复制黏贴下述配置项,写多行
binlog-ignore-db = mysql
# 表中自增字段每次的偏移量
auto-increment-offset = 1
# 表中自增字段每次的自增量
auto-increment-increment = 1
#跳过从库错误
slave-skip-errors = all重启数据库
/etc/init.d/mysqld restart

配置主从同步账号(在master库执行即可)
在主数据库上创建并授权复制账号: 在主库(Master)上,你需要创建一个专门用于从库(Slave)连接和进行复制的账号,并赋予其相应的权限。执行如下SQL命令:

mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.21.141' IDENTIFIED BY '000000';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

在从库配置同步信息

mysql> CHANGE MASTER TO->   MASTER_HOST='192.168.21.140',->   MASTER_USER='replication',->   MASTER_PASSWORD='000000',->   MASTER_LOG_FILE='mysql-bin.000001',->   MASTER_LOG_POS=154;
Query OK, 0 rows affected, 1 warning (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: 192.168.21.140Master_User: replicationMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 601Relay_Log_File: mysql-relay-bin.000002Relay_Log_Pos: 767Relay_Master_Log_File: mysql-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: 601Relay_Log_Space: 974Until_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: 70369f8b-bcc7-11ee-8f94-000c2977f1bdMaster_Info_File: /usr/local/mysql/data/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)mysql>

验证主从同步

mysql> create database aaa;
Query OK, 1 row affected (0.01 sec)mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| aaa                |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)在从库查询
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| aaa                |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

通过上面的配置,从库能复制master主库中的数据了,但是我在验证从库中发现,从库中有修改表数据的权限,我的想法是为了数据的一致性,数据的变更只能主库操作,从库只是用来查询,实现这个需要在从库的配置中加上两个参数:

在MySQL从库的配置文件(如my.cnf或my.ini)中添加以下行以强制数据库实例处于只读模式:
read_only = 1
super_read_only = on

read_only 参数会使得所有非超级用户只能执行读操作,而 super_read_only 参数则进一步限制了超级用户也不能在该实例上执行写操作,除非关闭此参数。

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M#开启GTID
gtid_mode=ON
enforce_gtid_consistency=trueserver-id = 2
relay-log = mysql-relay-bin#开启mysql的binlog日志功能
log-bin = mysql-bin
#控制数据库的binlog刷到磁盘上去 , 0不控制,性能最好,1每次事物提交都会刷到日志文件中,性能最差,最安全
sync_binlog = 1
#binlog日志格式
binlog_format = row
#binlog过期清理时间
expire_logs_days = 7
#binlog每个日志文件大小
max_binlog_size = 100m
#binlog缓存大小
binlog_cache_size = 4m
#最大binlog缓存大小
max_binlog_cache_size = 512m
#不生成日志文件的数据库,多个忽略数据库可以用逗号拼接,或者 复制黏贴下述配置项,写多行
binlog-ignore-db = mysql
# 表中自增字段每次的偏移量
auto-increment-offset = 1
# 表中自增字段每次的自增量
auto-increment-increment = 1
#跳过从库错误
slave-skip-errors = allread_only = 1
super_read_only = on#在数据库的/etc/my.cnf配置文件中添加read_only = 1和super_read_only = on这两个参数设置为只读需要重启mysql服务才会生效,比较复杂,可以直接在数据库中set global read_only=ON;set global super_read_only=ON;这两个命令可以在不重启数据库的基础上将从库设置为只读
set global read_only=ON;
set global super_read_only=ON;重启从库
[root@mysql-salve mysql]# /etc/init.d/mysqld restart

验证从库只能查询了

主从数据库切换验证
切换步骤:
1 切断应用对主库的流量
2 主库备库设置只读
3 查看备库复制进程状态
4 比对主备两边的GTID是否一致
5 确认是否真正同完
6 从库停掉复制进程并清空主从信息
7 从库关闭只读开启读写,转为新主库
8 主库设置执行新主库的复制链路,转为新备库,完成主从切换
9 应用流量切向新主库

主库备库设置只读

mysql> set global read_only=ON;
Query OK, 0 rows affected (0.00 sec)mysql> set global super_read_only=ON;
Query OK, 0 rows affected (0.00 sec)

3 查看备库复制进程状态

mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.21.140Master_User: replicationMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 6791Relay_Log_File: mysql-relay-bin.000004Relay_Log_Pos: 5783Relay_Master_Log_File: mysql-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: 6791Relay_Log_Space: 5990Until_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: 70369f8b-bcc7-11ee-8f94-000c2977f1bdMaster_Info_File: /usr/local/mysql/data/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)

4 比对主备两边的GTID是否一致
5 确认是否真正同完

mysql> show processlist;
+----+-------------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
| Id | User        | Host                 | db    | Command     | Time | State                                                         | Info             |
+----+-------------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
| 11 | replication | 192.168.21.141:53564 | NULL  | Binlog Dump | 5998 | Master has sent all binlog to slave; waiting for more updates | NULL             |
| 14 | root        | 192.168.21.1:50717   | aaa   | Sleep       |  233 |                                                               | NULL             |
| 25 | root        | mysql-master:44018   | mysql | Query       |    0 | starting                                                      | show processlist |
| 26 | root        | 192.168.21.1:52591   | aaa   | Sleep       |  238 |                                                               | NULL             |
| 27 | root        | 192.168.21.1:52592   | aaa   | Sleep       |  238 |                                                               | NULL             |
+----+-------------+----------------------+-------+-------------+------+---------------------------------------------------------------+------------------+
5 rows in set (0.00 sec)
mysql> show processlist;
+----+-------------+-------------------+------+---------+------+--------------------------------------------------------+------------------+
| Id | User        | Host              | db   | Command | Time | State                                                  | Info             |
+----+-------------+-------------------+------+---------+------+--------------------------------------------------------+------------------+
|  1 | system user |                   | NULL | Connect | 6013 | Waiting for master to send event                       | NULL             |
|  2 | system user |                   | NULL | Connect | 2124 | Slave has read all relay log; waiting for more updates | NULL             |
| 12 | root        | mysql-salve:54946 | NULL | Query   |    0 | starting                                               | show processlist |
+----+-------------+-------------------+------+---------+------+--------------------------------------------------------+------------------+
3 rows in set (0.00 sec)

6 从库停掉复制进程并清空主从信息

mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)mysql> reset slave all;
Query OK, 0 rows affected (0.01 sec)

7 从库关闭只读开启读写,转为新主库

mysql> set global read_only=off;
Query OK, 0 rows affected (0.00 sec)mysql> set global super_read_only=off;
Query OK, 0 rows affected (0.00 sec)

8 主库设置执行新主库的复制链路,转为新备库,完成主从切换

在备库上执行同步用户的创建
mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.21.140' IDENTIFIED BY '000000';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> FLUSH PRIVILEGES;
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 |      948 |              | mysql            |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
在140主节点改成从节点进行数据同步
mysql> CHANGE MASTER TO->   MASTER_HOST='192.168.21.141',->   MASTER_USER='replication',->   MASTER_PASSWORD='000000',->   MASTER_LOG_FILE='mysql-bin.000002',->   MASTER_LOG_POS=948;
Query OK, 0 rows affected, 1 warning (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: 192.168.21.141Master_User: replicationMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 1395Relay_Log_File: mysql-master-relay-bin.000002Relay_Log_Pos: 767Relay_Master_Log_File: mysql-bin.000002Slave_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: 1395Relay_Log_Space: 981Until_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: 852f4006-bccd-11ee-8376-000c29a331acMaster_Info_File: /usr/local/mysql/data/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)
验证数据同步即可

9 应用流量切向新主库

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

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

相关文章

指数计算(填空)

解题思路: 7的2020次方很大,需要用BigInteger来进行运算。 pow用来算指数运算。 remainder用来算BigInteger之间的取余。 解题代码: public static void main(String[] args) {BigInteger xnew BigInteger ("7");BigInteger ynew…

开源直播电商系统的实现方式(仿抖音电商模式)

当下,传统的图文电商模式正在走向没落,以“抖音”为首的直播电商模式备受用户追捧,它具有直观与互动的特点,拥有传统电商所不具备的优势。而且,当前正是直播电商的红利期,很多主播和品牌商都通过直播电商业…

阿里云上传文件

阿里云上传文件1&#xff08;未分模块&#xff09; 1、pom文件加入依赖 <!--阿里云 OSS 依赖--> <dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.15.1</version> </d…

Bug: git stash恢复误drop的提交

Bug: git stash恢复误drop的提交 前几天在写ut时突然需要通过本地代码临时出一个包&#xff0c;但是本地ut又不想直接作为一个commit提交&#xff0c;所以为了省事就将ut的代码暂时stash起来。出完包后想apply stash&#xff0c;但是手误操作点成了drop stash&#xff0c;丢失了…

并发编程【2】

01.什么是僵尸进程&#xff0c;孤儿进程 僵尸进程是指在进程已经终止但是其父进程尚未终止信息&#xff08;退出状态码&#xff09;的情况下。保留在进程表中的进程。僵尸进程不占用实际的系统资源&#xff0c;但会占用一个进程ID&#xff0c;并且会在系统中产生垃圾。 孤儿是指…

蒙特卡洛模拟之合成控制法

蒙特卡洛模拟之合成控制法&#xff08;Monte Carlo Simulation in Synthetic Control Method&#xff09;是一种用于评估政策效果的统计方法。该方法通过对比实验组和合成控制组之间的差异&#xff0c;从而估计政策的影响。 合成控制法是一种非实验性的政策评估方法&#xff0…

01.领域驱动设计:微服务设计为什么要选择DDD学习总结

目录 1、前言 2、软件架构模式的演进 3、微服务设计和拆分的困境 4、为什么 DDD适合微服务 5、DDD与微服务的关系 6、总结 1、前言 我们知道&#xff0c;微服务设计过程中往往会面临边界如何划定的问题&#xff0c;不同的人会根据自己对微服务的理 解而拆分出不同的微服…

mysql-线上常用运维sql

1.表备份 INSERT INTO table1 SELECT * FROM table2; 2.用一个表中的字段更新另一张表中的字段 UPDATE table2 JOIN table1 ON table2.id table1.id SET table2.column2 table1.column1; 3.在MySQL中&#xff0c;查询一个表的列字段值是否包含另一个表的字段&#xff0c;…

vue2 事件总线

原图下载&#xff1a;https://download.csdn.net/download/weixin_47401101/88788636

面向Java开发者的ChatGPT提示词工程(11)扩写

什么是扩写&#xff1f; 扩写是指将较短的文本交给GPT生成更长的文本。比如&#xff1a;根据一组基本指令&#xff0c;写出一封完整的电子邮件&#xff1b;或者根据一系列主题&#xff0c;创作出一篇包含这些主题的文章。 这样的技术&#xff0c;有着广阔的应用场景&#xff…

【蒸馏】目标检测蒸馏的不完全整理和个人笔记

其实仔细想想模型蒸馏的监督信号无非来自原先损失函数&#xff08;分类&#xff0c;bbox&#xff09;或者是相关组件&#xff08;backbone&#xff0c;FPN&#xff09;&#xff0c;在这里我不太想用传统的logit蒸馏和feature map蒸馏来表示上面两种蒸馏方式&#xff0c; 主要是…

深入浅出 diffusion(4):pytorch 实现简单 diffusion

1. 训练和采样流程 2. 无条件实现 import torch, time, os import numpy as np import torch.nn as nn import torch.optim as optim from torchvision.datasets import MNIST from torchvision import transforms from torch.utils.data import DataLoader from torchvision.…

LayoutInflater.inflate全面解读

方法解析 LayoutInflater.inflate() 是 Android 系统中用于将 XML 布局文件转换成相应的 View 的方法。在 Android 开发中&#xff0c;我们经常使用此方法来动态创建和填充布局。 public View inflate(LayoutRes int resource, Nullable ViewGroup root, boolean attachToRoo…

LVGL v9学习笔记 | 12 - 弧形控件的使用方法(arc)

一、arc控件 arc控件的API在lvgl/src/widgets/arc/lv_arc.h 中声明,以lv_arc_xxx命名。 arc控件由背景圆弧和前景圆弧组成,前景圆弧的末端有一个旋钮,前景圆弧可以被触摸调节。 1. 创建arc对象 /*** Create an arc object* @param parent pointer to an object, it w…

Pyecharts 风采:从基础到高级,打造炫酷象形柱状图的完整指南【第40篇—python:象形柱状图】

文章目录 引言安装PyechartsPyecharts象形柱状图参数详解1. Bar 类的基本参数2. 自定义图表样式3. 添加标签和提示框 代码实战&#xff1a;绘制多种炫酷象形柱状图进阶技巧&#xff1a;动态数据更新与交互性1. 动态数据更新2. 交互性设计 拓展应用&#xff1a;结合其他图表类型…

深度学习-使用Labelimg数据标注

数据标注是计算机视觉和机器学习项目中至关重要的一步&#xff0c;而使用工具进行标注是提高效率的关键。本文介绍了LabelImg&#xff0c;一款常用的开源图像标注工具。用户可以在图像中方便而准确地标注目标区域&#xff0c;为训练机器学习模型提供高质量的标注数据。LabelImg…

Unity中URP下逐顶点光照

文章目录 前言一、之前额外灯逐像素光照的数据准备好后&#xff0c;还有最后的处理二、额外灯的逐顶点光照1、逐顶点额外灯的光照颜色2、inputData.vertexLighting3、surfaceData.albedo 前言 在上篇文章中&#xff0c;我们分析了Unity中URP下额外灯&#xff0c;逐像素光照中聚…

vue3 codemirror关于 sql 和 json格式化的使用以及深入了解codemirror 使用json格式化提示错误的关键代码

文章目录 需求说明0、安装1. 导入js脚本2.配置3.html处使用4.js处理数据&#xff08;1&#xff09;json格式化处理&#xff08;2&#xff09;sql格式化处理 5. 解决问题1:json格式化错误提示报错&#xff08;1&#xff09;打开官网&#xff08;2&#xff09;打开官网&#xff0…

qt学习:http+访问百度智能云api实现人脸识别

目录 登录到百度智能云,找到人脸识别 完成操作指引 开通 添加人脸库 查看人脸搜索与库管理的api文档 ​编辑 查看自己应用的api key 查看回应的数据格式 编程实战 配置ui界面 添加模块,头文件和定义变量

C#中类型装换

在C#中&#xff0c;可以使用Convert.ChangeType()方法进行类型转换。这个方法可以将一个对象转换为指定的类型。 以下是使用Convert.ChangeType()方法的示例&#xff1a; using System;public class MyClass {public int MyProperty { get; set; } }public class Program {pu…