(注:截止2014年5月19日,官方MySQL5.6.17和MariaDB10.0.11均沒(méi)有提供該功能)
版本:
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;你會(huì)發(fā)現(xiàn)
| audit_log | ACTIVE | AUDIT| audit_log.so | GPL |
變量參數(shù):
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)
它先會(huì)把日志寫入內(nèi)存,然后再刷入磁盤里。
audit_log_strategy參數(shù)可以調(diào)整下面4個(gè)策略
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
這里用默認(rèn)就可以。
audit_log_rotate_on_size參數(shù)表示超過(guò)定義的值,會(huì)自動(dòng)輪訓(xùn),切分日志。
audit_log_rotations參數(shù)限制表示文件的數(shù)量。
效果:
參考文獻(xiàn):http://www.mysqlperformanceblog.com/2014/05/16/introduction-to-the-percona-mysql-audit-log-plugin/
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com