Frage

I use inotify to monitor changes to mysql data files, and the storage engine is InnoDB. inotify will consistently fail to capture any events when actually the data in the InnoDB files are updated. However, when I convert the storage of the same tables to MyISAM storage engine, everything works like a charm.

Anything thoughts on what is going on?

War es hilfreich?

Lösung

It works fine for me to monitor the InnoDB tablespace:

$ inotifywatch -v -t 60 -r /var/lib/mysql/data/*

. . .

Finished establishing watches, now collecting statistics.
Will listen for events for 60 seconds.
total  access  modify  close_nowrite  open  filename
21     12      0       4              5     /var/lib/mysql/data/test/
3      1       0       1              1     /var/lib/mysql/data/imdb/
3      1       0       1              1     /var/lib/mysql/data/performance_schema/
2      0       2       0              0     /var/lib/mysql/data/ibdata1
2      0       2       0              0     /var/lib/mysql/data/ib_logfile0
1      0       1       0              0     /var/lib/mysql/data/mysqld-bin.000017

I did some more tests and it seems that when I have innodb_flush_method=O_DIRECT, and I use some DML like INSERT to change data, inotify doesn't report it.

But when I disable O_DIRECT and allow InnoDB I/O to go through the filesystem buffer, inotify does report DML changes to .ibd files.


Other details:

Linux distro: CentOS 6.5
Linux kernel version: 2.6.32
inotify version: 3.14
Filesystem for MySQL datadir: xfs

Andere Tipps

I assume you are using innodb_flush_method = O_DIRECT, which uses the O_DIRECT flag when opening files. I would assume that inotify does not work with O_DIRECT but couldn't quickly find confirmation of that.

Under a standard MySQL server configuration, InnoDB uses a single set of data files (ibdata1 et al) to store data for all InnoDB tables managed by the server. The files in database directories are only used to store metadata, such as the column layout. Additionally, InnoDB buffers writes to these data files. Changes to the database will not necessarily correspond to writes to the InnoDB data files.

If you want to watch database tables for modifications, use MySQL triggers.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top