登录
首页 >  数据库 >  MySQL

msyql 开启 replication semi synchronous

来源:SegmentFault

时间:2023-02-24 16:41:03 229浏览 收藏

数据库小白一枚,正在不断学习积累知识,现将学习到的知识记录一下,也是将我的所得分享给大家!而今天这篇文章《msyql 开启 replication semi synchronous》带大家来了解一下msyql 开启 replication semi synchronous,希望对大家的知识积累有所帮助,从而弥补自己的不足,助力实战开发!

背景

通过用 go-mysql 同步到es过程中,提示如下错误

master does not support semi synchronous replication, use no semi-sync

解决

1.安装插件

mysql> show variables like '%semi%';
Empty set

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.7.30-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set

mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
Query OK, 0 rows affected

mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
Query OK, 0 rows affected

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.7.30-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set

mysql> show variables like '%semi%';
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | OFF        |
| rpl_semi_sync_master_timeout              | 10000      |
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 1          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
| rpl_semi_sync_slave_enabled               | OFF        |
| rpl_semi_sync_slave_trace_level           | 32         |
+-------------------------------------------+------------+
8 rows in set

mysql>  set global rpl_semi_sync_master_enabled=1;
Query OK, 0 rows affected

mysql> set global rpl_semi_sync_master_timeout=30000;
Query OK, 0 rows affected

mysql> show variables like '%semi%';
+-------------------------------------------+------------+
| Variable_name                             | Value      |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled              | ON         |
| rpl_semi_sync_master_timeout              | 30000      |
| rpl_semi_sync_master_trace_level          | 32         |
| rpl_semi_sync_master_wait_for_slave_count | 1          |
| rpl_semi_sync_master_wait_no_slave        | ON         |
| rpl_semi_sync_master_wait_point           | AFTER_SYNC |
| rpl_semi_sync_slave_enabled               | OFF        |
| rpl_semi_sync_slave_trace_level           | 32         |
+-------------------------------------------+------------+
8 rows in set

mysql> 

2. 修改配置文件并重启

root@base2018:/etc/mysql# vim mysql.conf.d/mysqld.cnf 

# 开启半同步
rpl_semi_sync_slave_enabled =1
rpl_semi_sync_master_enabled =1
#开启binlog
server_id=1
log_bin = mysql-bin
binlog_format = ROW
expire_logs_days = 30
log-bin = /var/log/mysql/mysql-bin.log

root@base2018:/etc/mysql# service mysql start

其他关于binlog

  1. 通过
     show binlog events\G;
    可以可视化bing log内容.(可以加很多查询参数)

理论要掌握,实操不能落!以上关于《msyql 开启 replication semi synchronous》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>