Mysql-audit audit log for MySQL using logrotate rotation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.