Seconds_Behind_Master的计算
2016-05-03 09:43
381 查看
MySQL复制中seconds_behind_master的计算 1.seconds_behind_master定义为从库相对于主库的延迟时间。 具体的计算公式为: clock_of_slave - last_timestamp_executed_by_SQL_thread-clock_diff_with_master. 备注:位于rpl_mi.h中定义了clock_diff_with_master,该值为从库相对于主库的时间差。 /* The difference in seconds between the clock of the master and the clock of the slave (second - first). It must be signed as it may be <0 or >0. clock_diff_with_master is computed when the I/O thread starts; for this the I/O thread does a SELECT UNIX_TIMESTAMP() on the master. "how late the slave is compared to the master" is computed like this: clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master */ long clock_diff_with_master; // clock_diff_with_master // mi->clock_diff_with_master= (long) (time((time_t*) 0) - strtoul(master_row[0], 0, 10)); master_row[0]就是在主库上执行SELECT UNIX_TIMESTAMP()的操作。 从如下到(rpl_slave.cc)可以看出: start_slave_thread-> //启动start slave handle_slave_io-> //启动start io thread get_master_version_and_clock //获取当前slave和主机之间的时间差(clock_diff_with_master) /* Used to defer stopping the SQL thread to give it a chance to finish up the current group of events. The timestamp is set and reset in @c sql_slave_killed(). */ time_t last_event_start_time; //slave端最后执行的reply log的最后一个事件的时间
相关文章推荐
- innnodb 线程在做什么?
- Mysql Join_buffer_size的使用原理
- C 内存池的实现
- C实现队列
- mysqld执行的函数栈
- MySQL高性能以及高安全测试
- C 实现简单的栈
- Java web 之mysql连接
- iOS_导航栏的navigationBar.hidden与navigationBarHidden的区别
- dbms_scheduler介绍
- 在PHP中调用接口
- 数塔问题
- perl 操作mysql 数据库
- Drupal的主题----第一章:Drupal的介绍
- vs 2013 密钥
- 浏览器对网址中的&与&解释时间各不同
- Git命令大全
- Android Service相关知识
- 第四部分 串行接口UART和Console
- MySQL缓存的查询和清除命令使用详解