mysql binlog事件 Rotate Event和Stop



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 executed

stop 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值