Home > Database > Mysql Tutorial > Percona5.6首次提供了审计日志功能_MySQL

Percona5.6首次提供了审计日志功能_MySQL

WBOY
Release: 2016-06-01 13:13:44
Original
1068 people have browsed it

如果有一天数据库里丢失了一条记录,开发让你查什么时候被谁从哪个IP,执行了delete操作,那么在之前的版本是无法查到的,而Percona最新版本5.6.17首次提供了审计日志功能。

(注:截止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
Copy after login

安装插件:

INSTALL PLUGIN audit_log SONAME 'audit_log.so';
Copy after login

show plugins;你会发现

| audit_log | ACTIVE | AUDIT| audit_log.so | GPL |
Copy after login

变量参数:

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)
Copy after login

它先会把日志写入内存,然后再刷入磁盘里。

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
Copy after login

wKiom1N5vAqRo1b3AACNoXALaCw271.jpg

这里用默认就可以。

audit_log_rotate_on_size参数表示超过定义的值,会自动轮训,切分日志。

audit_log_rotations参数限制表示文件的数量。

效果:

wKiom1N5vKzTVn3KAAHPmV2d8Fs718.jpg

参考文献:http://www.mysqlperformanceblog.com/2014/05/16/introduction-to-the-percona-mysql-audit-log-plugin/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template