top_log_event/STOP_EVENT
A Stop_log_event is written under these circumstances:
A master writes the event to the binary log when it shuts down
A slave writes the event to the relay log when it shuts down or when a RESET SLAVE statement is executedstop event出现两种情况:
1 是master shut down的时候会在binlog文件结尾出现
2 是备机在关闭的时候会写入relay log结尾;或者RESET SLAVE命令执行
二 ROTATE EVENT
Rotate_log_event/ROTATE_EVENT
When a binary log file exceeds a size limit, a ROTATE_EVENT is written at the end of the file that points to the next file in the squence. This event is information for the slave to know the name of the next binary log it is going to receive.
ROTATE_EVENT is generated locally and written to the binary log on the master. It is written to the relay log on the slave when FLUSH LOGS occurs, and when receiving a ROTATE_EVENT from the master. In the latter case, there will be two rotate events in total originating on different servers.
There are conditions under which the terminating log-rotation event does not occur. For example, the server might crash.
Fixed data part:
8 bytes. The position of the first event in the next log file. Always contains the number 4 (meaning the next event starts at position 4 in the next binary log). This field is not present in v1; presumably the value is assumed to be 4.
Variable data part:
The name of the next binary log. The filename is not null-terminated. Its length is the event size minus the size of the fixed parts.当binlog文件超过指定大小(在哪指定?),ROTATE EVENT会写在文件最后,指向下一个binlog文件。这个事件通知slave,应该去读取下一个binlog文件了。
master会写ROTATE EVENT到本地文件;在slave上运行FLUSA LOGS指令,或者收到master的ROTATE EVENT事件,slave 会将ROTATE EVENT写到relay log里。
也存在binlog文件没有ROTATE EVENT的情况,比如server crash的时候。
参考 : http://dev.mysql.com/doc/internals/en/event-data-for-specific-event-types.html
本文介绍了MySQL中两种重要的日志事件:STOP_EVENT 和 ROTATE_EVENT。STOP_EVENT 在服务器关闭时生成,标记在binlog和relaylog文件中。ROTATE_EVENT 则在binlog文件达到大小限制时生成,用于指示下一个binlog文件。
2361

被折叠的 条评论
为什么被折叠?



