Recently found in a server MySQL audit (http://jim123.blog.51cto.com/4763600/1955487) plug-in log no data, just started to think that is configured to the problem in the database check to see that there is no problem, Later found in the MySQL audit specified file path issued by the existing rotation log, the preliminary analysis is in the use of the system logrotate (http://jim123.blog.51cto.com/4763600/1880582) to do the log rotation to/etc/ LOGROTATE.D directory to find the custom rotation of the log, found in doing audit log rotation is not stopped audit_json_file log write, resulting in a change in the wrong:
/data/mysqldata/mysql-audit.json { prerotate # stop mysql audit if test -x /usr/local/mysql/bin/mysql && /usr/local/mysql/bin/mysqladmin ping &>/dev/null then /usr/local/mysql /bin/mysql -e "set global audit_json_file=off;" fi endscript create 0600 mysql mysql notifempty daily rotate 5 missingok compress postrotate # just if mysqld is really running and start mysql audit if test -x / usr/local/mysql/bin/mysqladmin && /usr/local/mysql/bin/mysqladmin ping &>/dev/null then /usr/local/mysql/bin/ mysqladmin flush-logs && /usr/local/mysql/bin/mysql -e "set global audit_json_file=on;" fi endscript}
After you have modified it, then test the post-rotation audit log to write normally. There are two points to be mentioned here: first of all, it is important to note that when using the MySQL audit plugin for auditing, when the multi-audit log modification without stopping Audit_json_file causes the log to fail to write after the error, so the Audit_json_ When the file log is changed for rotation, set GLOBAL Audit_json_file=off is required to close the audit before it is done, and then you must write the ~/in the home directory of your root user. my.cnf password file, where MySQL and mysqladmin two commands are required to have, this has been mentioned before, need to see: http://jim123.blog.51cto.com/4763600/1900634
This article from "Jim's Technical Essay" blog, declined to reprint!
Mysql-audit audit log for MySQL using logrotate rotation