17.2.1 Replication Implementation Details 复制实现细节:
17.2 Replication Implementation 复制是基于master server 跟踪所有改变到他的数据库(更新,删除等等)在它的binary log. binary log 作为些所有事件修改数据的结构或者内容从server 开始启动 典型的,SELECT 语句是不被记录的因为它们既不修改数据库也不修改内容 每个slave 连接到master 请求一个binary log的拷贝。 也就是说,它从master 拉数据,相比master 推数据到slave. slave也执行从binary log 执行events 。 这个重复原始的改变 就像它们在master上一样。 表时被创建或者它们的结果修改,数据被插入,删除,和更新根据改变发生在master上一样 因为每个slave 是独立的,replay master 的binary log的改变发生在每个slave (slave是连接到Master) 此外,因为每个slave 接收一份Binary log的拷贝只要通过从master 请求, slave 是可以读取和更新数据库的拷贝以自己的步伐可以启动和停止复制进程 不影响更新最新的数据库状态在主或者从一侧 master binary log 是些到一个本地的的relay log 在slave端在它被处理前。 Vsftp:/data01/mysql# ls -ltr *relay*
-rw-rw---- 1 mysql mysql 120 Nov 14 10:27 Vsftp-relay-bin.000001
-rw-rw---- 1 mysql mysql 25 Nov 14 10:27 Vsftp-relay-bin.index
-rw-rw---- 1 mysql mysql 221 Nov 14 21:59 mysqld-relay-bin.000006
-rw-rw---- 1 mysql mysql 52 Nov 14 21:59 mysqld-relay-bin.index
-rw-rw---- 1 mysql mysql 198021585 Nov 15 09:14 mysqld-relay-bin.000007 slave 也记录信息关于当前的master binary log和local relay log的位置 17.2.1 Replication Implementation Details 复制实现细节: MySQL 复制功能是实现使用3个进程,一个在master server和2个在slave上。 1.Binlog dump thread,master 创建一个线程来发送binary log 内容到一个slave 当slave连接时。 这个线程可以是被在SHOW PROCESSLIST 的输出在master上 zabbix:/data01/mysql# mysql -uroot -p1234567 -e "SHOW PROCESSLIST" | 198968 | backup | 192.168.11.187:45976 | NULL | Binlog Dump | 46595 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL |
| 204759 | root | localhost | NULL | Query | 0 | init | SHOW PROCESSLIST | binary log dump thread 需要一个lock 在master的binary log 对于读取每个event 发送到slave. 当event 被读取,lock是被释放,甚至在event被发送到slave之前 Slave I/O thread. 当一个START SLAVE 语句是执行在一个slave server,slave 创建一个I/O thread, 连接到master 和告诉master 发送更新记录在master的binary logs. slave I/O thread 读取更新 master的Binlog Dump thread 发送的 复制他们到本地的文件 slave的relay log thread 的状态是显示为Slave_IO_running 在SHOW SLAVE STATUS的输出 或者SHOW STATUS. 的 Slave_running Slave SQL thread slave创建一个SQL thread 来读取relay log 被 slave I/O thread写入的, 执行其中包含的事件 在先前的描述,有三个线程么每个master/slave 连接。一个master 有多个slaves 创建一个binary log dump thread 对于米格连接的slave, 每个slave 有它自己的I/O和SQL threads. 一个slave 使用2个threads 来分别的读取更新从master 和执行它们到单独的任务。 因此,读取任务的语句是不会减慢如果语句执行是慢的, 例如,如果slave server 没有运行一段时间,它的I/O thread 可以快速的获取binary log 内容从master 当slave 开始后, 即使SQL thread 远远落后,如果slave 停止 在SQL thread 已经执行所有取得的SQL之前, I/O thread 已经至少获取了一切这样一个安全的语句的拷贝是存储在本地的slave的relay logs里, 准备用于执行 等下次slave 启动的时候 SHOW PROCESSLIST 语句提供了信息高速你 Master上发生了什么,slave上关于复制 slave:
mysql> SHOW PROCESSLIST ;
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------------+------------------+
| 11 | system user | | NULL | Connect | 51213 | Waiting for master to send event | NULL |
| 12 | system user | | NULL | Connect | -140 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 14 | root | localhost | NULL | Query | 0 | init | SHOW PROCESSLIST |
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------------+------------------+
3 rows in set (0.00 sec) 下面的例子阐述3个线程在SHOW PROCESSLIST的输出 在master server上,SHOW PROCESSLIST 输出像这样: mysql> SHOW PROCESSLIST\G
*************************** 1. row ***************************
Id: 2
User: root
Host: localhost:32931
db: NULL
Command: Binlog Dump
Time: 94
State: Has sent all binlog to slave; waiting for binlog to
be updated
Info: NULL 在这里, 线程2 是一个 Binlog Dump replication thread 服务一个连接的slave. 状态信息表明所有的更新已经发送到slave ,master是等待更多的更新发生。 如果你看到 no Binlog Dump threads 在master server上, 这意味着复制是没有被运行,没有slave 是当前连接的。 On a slave server, the output from SHOW PROCESSLIST looks like this: 在slave server上,SHOW PROCESSLIST 输出像这样: mysql> SHOW PROCESSLIST\G
*************************** 1. row ***************************
Id: 10
User: system user
Host:
db: NULL
Command: Connect
Time: 11
State: Waiting for master to send event
Info: NULL
*************************** 2. row ***************************
Id: 11
User: system user
Host:
db: NULL
Command: Connect
Time: 11
State: Has read all relay log; waiting for the slave I/O
thread to update it
Info: NULL 状态信息表明 thread 10 是I/O thread 和master server通讯, 线程11是SQL thread 处理更新存储在relay logs.
17.2.1 Replication Implementation Details 复制实现细节:的更多相关文章
- 17.2?Replication Implementation 复制实施:
17.2?Replication Implementation 复制实施: 17.2.1 Replication Implementation Details 17.2.2 Replication R ...
- 17.2.2 Replication Relay and Status Logs 复制Relay 和状态日志;
17.2.2 Replication Relay and Status Logs 复制Relay 和状态日志: 17.2.2.1 The Slave Relay Log 17.2.2.2 Slave ...
- 17.1.4 Replication and Binary Logging Options and Variables 复制和Binary logging 选项和变量
17.1.4 Replication and Binary Logging Options and Variables 复制和Binary logging 选项和变量 下面的章节包含信息关于mysql ...
- 17.1.2?Replication Formats 复制格式:
17.1.2?Replication Formats 复制格式: 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Ba ...
- 17.1.2 Replication Formats
17.1.2 Replication Formats 复制格式 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Bas ...
- Accessor Search Implementation Details
[Accessor Search Implementation Details] Key-value coding attempts to use accessor methods to get an ...
- [Angular] Extract Implementation Details of ngrx from an Angular Application with the Facade Pattern
Extracting away the implementation details of ngrx from your components using the facade pattern cre ...
- 第七篇 Replication:合并复制-订阅
本篇文章是SQL Server Replication系列的第七篇,详细内容请参考原文. 订阅服务器就是复制发布项目的所有变更将传送到的服务器.每一个发布需要至少一个订阅,但是一个发布可以有多个订阅. ...
- 第六篇 Replication:合并复制-发布
本篇文章是SQL Server Replication系列的第六篇,详细内容请参考原文. 合并复制,类似于事务复制,包括一个发布服务器,一个分发服务器和一个或多个订阅服务器.每一个发布服务器上可以定义 ...
随机推荐
- JS操作CSS样式
一.样式表(css) 使用样式表可以更好的显示WEB文档,也可以结合javascript从而实现很好的控制样式表. 样式(css)与内容(html): HTML是处理文档结构的,HTML可以实现如何把 ...
- 通过Web.config中的configSections配置自己系统的全局常量
通过Web.config中的configSections配置自己系统的全局常量 随着系统的庞大,你的全局信息保存在appsitting里可能会比较乱,不如为模块写个自定义的全局常量吧 首先在Web.C ...
- pat_1014
1014. 福尔摩斯的约会 (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大侦探福尔摩斯接到一张奇怪的字 ...
- Spring Boot应用的健康监控
在之前的系列文章中我们学习了如何进行Spring Boot应用的功能开发,以及如何写单元测试.集成测试等,然而,在实际的软件开发中需要做的不仅如此:还包括对应用程序的监控和管理. 正如飞行员不喜欢盲目 ...
- Ladder免费试用版
Ladder这款vpn软件最近在play中国区排名非常高,节节高升,可见大家还真需要这东西,软件做的不错,大家可以在试用版中升级到正式版. 下载地址
- PHP学习笔记(八)
关于PHP中的缓存函数ob_start() and ob_end_flush(). PHP输出机制:输出内容->缓存->输出到浏览器.ob_start(callback function) ...
- mysql学习笔记2
drop database 数据库名称;————删除数据库 show columns from 数据表名[from 数据库名]:(或者 show columns from 数据库.数据表名:)———— ...
- Linux Master/Baremetal Remote 配置下的裸机调试
为了实现在ZC702开发板上的两颗Cortex-A9处理器上实现Linux Master/Baremetal Remote 配置,并对Remote端的裸机程序进行调试,需要注意的几点如下: 一.建立p ...
- python的一个表达式的计算(超简单)
运行的过程如下: 输入计算表达式:3+5 计算结果:8 然后再次显示计算表达式,等待输入完成后,再次显示结果,依此循环. 作为初学者再适合不过,代码也简单,如下所示: #!/usr/bin/env ...
- 使用远程链接数据库工具无法链接到 linxu 系统上的数据库配置 1045
1.远程连接上Linux系统,确保Linux系统已经安装上了MySQL数据库.登陆数据库.mysql -uroot -p(密码). 2. 创建用户用来远程连接 GRANT ALL PRIVILEGES ...