上一篇文章《UDF+Trigger实时监控Mysql数据更新》介绍了用UDF+Trigger的方式来监控Mysql数据的更新,这次介绍下使用binlog监控数据更新的方法。The binary log is a set of log files that contain information about data modifications made to a MySQL server instance.
其主要有以下两个用途:主从同步
数据恢复
mysql主从同步原理 利用binlog来监控mysql数据的更新,以更新缓存。原理类似于mysql的主从同步。先简单介绍下mysql主从同步的原理: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 sen