SpringBoot+MyBatis+MySQL读写分离

时间:2021-09-13 19:41:04   收藏:0   阅读:27

一、主从配置

1.环境

操作系统:CentOS-7

MySQL:mysql-5.7

192.168.15.129  master

192.168.15.130  slave

2.主库配置

3.从库配置

4.异常解决

[ERROR] Slave I/O for channel ‘‘: Got fatal error 1236 from master when reading data from binary log: ‘Client requested master to start replication from position > file size‘, Error_code: 1236

解决方法:

mysql> flush logs;
Query OK, 0 rows affected (0.02 sec)

mysql> show master status;
+---------------------+----------+--------------+------------------+-------------------+
| File                | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------------+----------+--------------+------------------+-------------------+
| dbmaster-bin.000005 |      120 |              |                  |                   |
+---------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

记住fileposition这两个选项

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

mysql> change master to master_log_file =‘dbmaster-bin.000005‘,master_log_pos=120;
Query OK, 0 rows affected (0.01 sec)

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

搞定收工!

二、读写分离

gitee源码地址:https://gitee.com/kk-dad/msrepl

原文:https://www.cnblogs.com/qqkkOvO/p/15260810.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!