mysql审计 社区版有吗_mysql 5.6 社区版上审计功能,不扯皮
官網
https://mariadb.com/kb/en/mariadb/about-the-mariadb-audit-plugin/
一、環境說明
MySQL 5.6.25 社區版
Mariadb 10.0.25 社區版
mysql 企業版有審計功能需要收費,社區版被閹割的不行不行了,和古時候的太監
沒啥區別了,比較重要的功能特性都沒有,不過也能湊合著用。可能說的有點過,
話糙理不糙,建議用不起企業版的可以考慮percona 和 mariadb,個人建議,僅供參考。
二、安裝
1.下載mariadb 10.0.25_x64 安裝包,解壓縮上傳server_audit.so 文件到/tmp 目錄下
2. 查看插件路徑(root@localhost)?[(none)]>?show?variables?like?‘plugin_dir‘;
+---------------+--------------------------+
|?Variable_name?|?Value????????????????????|
+---------------+--------------------------+
|?plugin_dir????|?/usr/lib64/mysql/plugin/?|
+---------------+--------------------------+
1?row?in?set?(0.00?sec)
3.cp 插件,授予執行權限#?cp?/tmp/server_audit.so?/usr/lib64/mysql/plugin/
#?chmod?+x?/usr/lib64/mysql/plugin/server_audit.so
#
4.安裝插件(root@localhost)?[(none)]>?install?plugin?server_audit?SONAME?‘server_audit.so‘;
Query?OK,?0?rows?affected?(0.00?sec)
5.查看參數(root@localhost)?[(none)]>?show?variables?like?‘%audit%‘;
+-------------------------------+-----------------------+
|?Variable_name?????????????????|?Value?????????????????|
+-------------------------------+-----------------------+
|?server_audit_events???????????|???????????????????????|
|?server_audit_excl_users???????|???????????????????????|
|?server_audit_file_path????????|?server_audit.log??????|
|?server_audit_file_rotate_now??|?OFF???????????????????|
|?server_audit_file_rotate_size?|?1000000???????????????|
|?server_audit_file_rotations???|?9?????????????????????|
|?server_audit_incl_users???????|???????????????????????|
|?server_audit_loc_info?????????|???????????????????????|
|?server_audit_logging??????????|?OFF???????????????????|
|?server_audit_mode?????????????|?1?????????????????????|
|?server_audit_output_type??????|?file??????????????????|
|?server_audit_query_log_limit??|?1024??????????????????|
|?server_audit_syslog_facility??|?LOG_USER??????????????|
|?server_audit_syslog_ident?????|?mysql-server_auditing?|
|?server_audit_syslog_info??????|???????????????????????|
|?server_audit_syslog_priority??|?LOG_INFO??????????????|
+-------------------------------+-----------------------+
16?rows?in?set?(0.00?sec)
6.修改參數(root@localhost)?[(none)]>?set?global?server_audit_logging=on;
Query?OK,?0?rows?affected?(0.00?sec)
(root@localhost)?[(none)]>?set?global??server_audit_file_rotate_now=ON;
Query?OK,?0?rows?affected?(0.00?sec)
7.查看審計日志路徑#?find?/?-name?server_audit.log
/data/mysqldata/server_audit.log?????--默認在數據路徑下#?tail?-f?/data/mysqldata/server_audit.log
20161226?22:46:38,mysql91,root,localhost,1,3,QUERY,,‘set?global?server_audit_logging=on‘,0
20161226?22:46:58,mysql91,root,localhost,1,4,QUERY,,‘show?variables?like?\‘%audit%\‘‘,0
20161226?22:48:36,mysql91,root,localhost,1,5,QUERY,,‘show?databases‘,0
20161226?22:49:27,mysql91,root,localhost,1,6,QUERY,,‘GRANT?ALL?PRIVILEGES?ON?*.*?TO?\‘roidba\‘@\‘%\‘?IDENTIFIED?BY?PASSWORD?*****‘,0
三、正式環境需要解決兩個問題
1.日志路徑要規范(root@localhost)?[(none)]>?set?global?server_audit_file_path=‘/data/mysqllogs/‘;
Query?OK,?0?rows?affected?(0.00?sec)
2.通常查詢不需要審計(mysql 測試過濾不掉,mariadb 可以)(root@localhost)?[(none)]>?set?global?server_audit_events=‘query_ddl,query_dml‘;
Query?OK,?0?rows?affected?(0.00?sec)
3.固化參數vi?/etc/my.cnf
########mariadb?10.0.25?audit?plugin#######
server_audit_logging=on
server_audit_events=‘query_dml,query_ddl‘
server_audit_file_path?=/data/mysqllogs/
server_audit_file_rotate_size=200000000
server_audit_file_rotations=200
4.建議重啟service?mysql?restart
總結
以上是生活随笔為你收集整理的mysql审计 社区版有吗_mysql 5.6 社区版上审计功能,不扯皮的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java excel 字体大小_Java
- 下一篇: python做数据和大数据区别_不懂Py