admin管理员组

文章数量:1658586

2019独角兽企业重金招聘Python工程师标准>>>

5.7.2 支持单库增强型多线程slave(多个sql work线程),mariadb 10.0.5支持

  • 原理

    • slave利用事务组提交的特性(To provide parallel execution of transactions in the same schema, MariaDB 10.0 and MySQL 5.7 take advantage of the binary log group commit optimization),在slave 多个sql worker线程进行并行回放
    • master依据group commit的并行性,在binary log进行标记,slave使用master提供的信息并行执行事务
  • 注意事项

    • 级联复制场景,其他slave将会出现并行性更小(并行度不一样),使用binlog server做替代方案
  • 配置

    • mysql 5.7
      • slave_parallel_type=logical_clock 默认为database,使用db并行方式,logical_clock使用逻辑时钟的并行模式
      • slave_parallel_workers=16 设置worker线程数
      • binlog_group_commit_sync_delaybinlog_group_commit_sync_no_delay_count 在master延时事务提交,增加group commit事务数
    • mariadb参数
      • slave_parallel_threads=16 也支持多源复制
      • slave_parallel_mode=conservative 10.1.3开始支持optimistic模式,通过启发性方式减少冲突,如果发生冲突,将事务进行回滚 ;Conservative默认值,使用group commit发现潜在的并行事件,在一个group commit中的事务写到binlog时拥有相同的commit id(cid);minimal仅仅commit阶段是并行,其他事务应用发生是串行的,同时也关闭out-of-order(使用不同domain id)并行复制
      • binlog_commit_wait_countbinlog_commit_wait_usec 调整master进行group commit的事务数
      • slave_parallel_max_queued 限制每个线程的队列事件数,提高worker线程处理能力
      • slave_domain_parallel_threads worker线程由所有多源master连接共享,建议大于slave_parallel_threads
  • 查看状态

    • show processlist 检查worker线程的状态
    • mariadb的状态变量BINLOG_COMMITSBINLOG_GROUP_COMMITS
  • 性能测试

  • 参考
    • MySQL 5.7 Enhanced MTS: configuring slave for Intra-database parallelization
    • mariadb Parallel Replication
    • Better Parallel Replication for MariaDB and MySQL
    • Evaluating MariaDB & MySQL Parallel Replication Part 2: Slave Group Commit
    • MySQL 5.7: Enhanced Multi-threaded slaves
    • MWL#184: Parallel replication of group-committed transactions
    • No application changes needed: 10 times faster slave with MariaDB 10 parallel replication - Kristian Nielsen

转载于:https://my.oschina/anthonyyau/blog/663137

本文标签: EnhancedMTSMultiSlavethreaded