(注:截止2014年5月19日,官方MySQL5.6.17和MariaDB10.0.11均沒有提供該功能)
版本:
5.6.17-65.0-rel65.0-log Percona Server with XtraDB (GPL), Release rel65.0, Revision 587
安裝插件:
INSTALL PLUGIN audit_log SONAME 'audit_log.so';
show plugins;你會發現
| audit_log | ACTIVE | AUDIT| audit_log.so | GPL |
變量參數:
mysql> show global variables like 'audit%';+--------------------------+--------------+| Variable_name| Value|+--------------------------+--------------+| audit_log_buffer_size| 1048576|| audit_log_file | audit.log|| audit_log_flush| OFF|| audit_log_format | NEW|| audit_log_policy | ALL|| audit_log_rotate_on_size | 0|| audit_log_rotations| 0|| audit_log_strategy | ASYNCHRONOUS |+--------------------------+--------------+8 rows in set (0.00 sec)
它先會把日志寫入內存,然后再刷入磁盤里。
audit_log_strategy參數可以調整下面4個策略
1、ASYNCHRONOUS log using memory buffer, do not drop events if buffer is full2、PERFORMANCE log using memory buffer, drop events if buffer is full3、SEMISYNCHRONOUS log directly to file, do not fsync every event4、SYNCHRONOUS log directly to file, fsync every event
這里用默認就可以。
audit_log_rotate_on_size參數表示超過定義的值,會自動輪訓,切分日志。
audit_log_rotations參數限制表示文件的數量。
效果:
參考文獻:http://www.mysqlperformanceblog.com/2014/05/16/introduction-to-the-percona-mysql-audit-log-plugin/
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com