Mysql 内部结构 / Replication

Chapter 19 Replication

Table of Contents     

19.1 Chapter Organization

19.2 Source Code Files

19.3 Principles     

19.4 Rules     

Status of this section: up to date 2009-10-21

This chapter describes MySQL replication principles, rules, and code, as it is supposed to work in version 5.1.

The MySQL replication feature allows a server - the master - to send all changes to another server - the slave - and the slave tries to apply all changes to keep up-to-date with the master. Replication works as follows:

  • Whenever the master's database is modified, the change is written to a file, the so-called binary log, or binlog. This is done by the client thread that executed the query that modified the database.

  • The master has a thread, called the dump thread, that continuously reads the master's binlog and sends it to the slave.

  • The slave has a thread, called the IO thread, that receives the binlog that the master's dump thread sent, and writes it to a file: the relay log.

  • The slave has another thread, called the SQL thread, that continuously reads the relay log and applies the changes to the slave server.


 

19.1 层次结构 

19.2 源代码文件

19.3 原理     

19.4 规则     

本节状态:最新2009-10-21

本章介绍了MySQL复制的原则,规则和代码。它应该用在5.1版本上。

MySQL的复制功能允许服务器- master -发送的所有更改到另一台服务器-的slave -和slave试图以应用所有更新操作,以便跟上最新的master。复制的工作原理如下:

  • 每当master的数据库修改,更改写入到文件中,即所谓的二进制日志binlog。这些内容是由客户端线程执行数据库查询(这里的查询是统称,实际上只会保留DML,select并不保存)的。

  • master上有一个线程,称为dump thread,即连续读取主的二进制日志,并将其发送到slave。

  • slave有一个线程,称为IO线程(IO thread),接收了master的dump thread发送的二进制日志,并将其写入文件:在 中继日志(relay log)

  • slave上有另一个线程,称为 SQL线程(SQL thread),即连续读取中继日志并应用更改到slave的数据库上。

转载于:https://my.oschina.net/u/778602/blog/716335

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值