測試用伺服器設定: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;
UNINSTALL PLUGIN server_audit;
20170119 10:39:19,localhost.localdomain,root,127.0.0.1,375,8330400,QUERY,sysbench_test,'SELECT c FROM sbtest5 WHERE id=5037936',0
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.)