欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MySQL审计插件的测试(mcafee和mariadb版本)详情介绍

程序员文章站 2022-03-06 16:40:03
...
测试用服务器配置:Dell R730; 24核; 64G内存; ssd磁盘。

Centos版本:6.4; MySQL版本:Community 5.6.12;测试数据库大小:24G。

sysbench 参数:64线程 10表,每个表预先初始化好一千万数据,读写混合OLTP模式。和mysql跑在同一台机器上。

测试时长:5分钟/场景。

未安装插件

OLTP test statistics:
queries performed:
read: 15377012
write: 4393432
other: 2196716
total: 21967160
transactions: 1098358 (3661.01 per sec.)
read/write requests: 19770444 (65898.21 per sec.)
other operations: 2196716 (7322.02 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

Mcafee插件 官网地址:https://github.com/mcafee/mysql-audit/wiki

使用版本:v1.0.9

安装

INSTALL PLUGIN AUDIT SONAME 'libaudit_plugin.so';

启用

set global audit_json_file=1;

停用

set global audit_json_file=0;

重启mysql

插件不会卸载,不会启用记录日志。

卸载

直接执行UNINSTALL PLUGIN AUDIT;卸载会报错: Uninstall AUDIT plugin disabled。

同时发现 Variable 'audit_uninstall_plugin' is a read only variable

需要在my.cnf中添加audit_uninstall_plugin=1,重启mysql。

重启完毕后 执行两次 UNINSTALL PLUGIN AUDIT; 可以卸载。

卸载完成后需要从my.cnf中删除audit_uninstall_plugin=1 ,否则下次mysql启动会报错:[ERROR] /data/mysql/bin/mysqld: unknown variable 'audit_uninstall_plugin=1'

日志格式:json

{"msg-type":"activity","date":"1484795122970","thread-id":"557","query-id":"61687115","user":"root","priv_user":"root","ip":"127.0.0.1","cmd":"select",
"objects":[{"db":"sysbench_test","name":"sbtest7","obj_type":"TABLE"}],"query":"SELECT c FROM sbtest7 WHERE id=5015211"}

只会记录操作成功的日志

OLTP test statistics:
queries performed:
read: 8376872
write: 2393392
other: 1196696
total: 11966960
transactions: 598348 (1994.38 per sec.)
read/write requests: 10770264 (35898.81 per sec.)
other operations: 1196696 (3988.76 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

Mariadb 插件 官网地址:https://mariadb.com/kb/en/mariadb/about-the-

使用版本:1.1.7

安装

INSTALL PLUGIN server_audit SONAME 'server_audit.so';

启用

set global server_audit_logging=1;
set global server_audit_file_rotate_size=1073741824; set global server_audit_file_rotations=4;

停用

set global server_audit_logging=0;

重启mysql

插件不会卸载,不会启用记录日志。 但是所有参数会重置,再次启用的时候需要执行需要的参数配置。

卸载

UNINSTALL PLUGIN server_audit;

卸载插件无须重启mysql。

日志格式:固定格式文本

20170119 10:39:19,localhost.localdomain,root,127.0.0.1,375,8330400,QUERY,sysbench_test,'SELECT c FROM sbtest5 WHERE id=5037936',0

所有操作都会记录。可以记录SQL注入。

OLTP test statistics:
queries performed:
read: 9098362
write: 2599532
other: 1299766
total: 12997660
transactions: 649883 (2166.16 per sec.)
read/write requests: 11697894 (38990.84 per sec.)
other operations: 1299766 (4332.32 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

小结:

mcafee的审计插件:

性能下降约46%,产生日志3.0G

卸载插件需要重启一次mysql。插件没有自动滚动,需要另外部署清理任务,会有清理任务失败导致的磁盘空间不够的风险,拉取日志到其他服务器分析与清理任务有协调困难,清理任务会有一定耦合性。

mariadb的审计插件:

性能下降约41%,产生1864M日志。

性能略好于mcafee的插件。 审计日志有自动滚动。卸载方便。 兼容性方面5.6.12的版本测试不适配1.1.7以上版本,使用的话MySQL守护进程会无限重启mysql,官方说是1.2.0以上版本要在MySQL5.6.17以上版本使用,使用前要先测试。

percona的审计插件:

没有适配5.6.17以前版本的,暂未做测试。

以上就是MySQL审计插件的测试(mcafee和mariadb版本)详情介绍的内容,更多相关内容请关注PHP中文网(www.php.cn)!

相关标签: MySQL,审计插件