MariaDB Audit Plugin 将日志保存到 syslog
来源:互联网 发布:python 查看变量字节 编辑:程序博客网 时间:2024/05/21 17:06
Syslog 使用广泛,对日志进行独立存储。而且有很多的工具可对 syslog 数据进行聚合、监控、查询和分析。Syslog 数据可以当成是一个中央资料库。
你也可以在 MariaDB 中将日志写到 Syslog 中,步骤很简单:
首先下载 MariaDB 的 audit 插件,下载地址:http://www.skysql.com/downloads/mariadb-audit-plugin-beta
然后将 server_audit.so 文件拷贝到你的 MySQL/MariaDB 下的 lib/plugin 目录,并通过如下命令激活该插件:
1
MariaDB [(none)]> INSTALL PLUGIN server_audit SONAME
'server_audit.so'
;
1
MariaDB [test]>
SET
GLOBAL
server_audit_output_type=SYSLOG;
2
MariaDB [test]>
SET
GLOBAL
server_audit_events=
'CONNECT,QUERY'
;
3
MariaDB [test]>
SET
GLOBAL
server_audit_logging=
on
;
01
MariaDB [test]> show variables
like
'%audit%'
;
02
+
-------------------------------------+-----------------------+
03
| Variable_name | Value |
04
+
-------------------------------------+-----------------------+
05
| server_audit_events |
CONNECT
,QUERY |
06
| server_audit_excl_users | | |
07
| server_audit_file_path | server_audit.log |
08
| server_audit_file_rotate_now |
OFF
|
09
| server_audit_file_rotate_size | 1000000 |
10
| server_audit_file_rotations | 9 |
11
| server_audit_incl_users | |
12
| server_audit_logging |
ON
|
13
| server_audit_mode | 0 |
14
| server_audit_output_type | syslog |
15
| server_audit_syslog_facility | LOG_USER |
16
| server_audit_syslog_ident | mysql-server_auditing |
17
| server_audit_syslog_info | |
18
| server_audit_syslog_priority | LOG_INFO |
19
+
-------------------------------------+-----------------------+
20
14
rows
in
set
(0.00 sec)
01
MariaDB [test]> show status
like
'%audit%'
;
02
+
------------------------------ +--------------+
03
| Variable_name | Value |
04
+
----------------------------- -+--------------+
05
| server_audit_active |
ON
|
06
| server_audit_current_log | [SYSLOG] |
07
| server_audit_last_error | |
08
| server_audit_writes_failed | 0 |
09
+
-------------------------------+--------------+
10
4
rows
in
set
(0.00 sec)
1
[root@centos1 log]
# service rsyslog restart
2
Shutting down system logger: [ OK ]
3
Starting system logger: [ OK ]
1
[root@centos1 log]
# tail -f /var/log/messages
2
Sep 21 00:07:07 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,10,QUERY,,
'set global server_audit_logging=on'
,0
3
Sep 21 00:07:11 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,11,QUERY,,
'show status like \'%audit%\''
,0
4
Sep 21 00:07:21 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,12,QUERY,,
'show variables like \'%audit%\''
,0
5
Sep 21 00:10:06 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,13,QUERY,,
'set global server_audit_events=\'CONNECT,QUERY\''
,0
6
Sep 21 00:13:09 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,14,QUERY,,
'SELECT DATABASE()'
,0
7
Sep 21 00:13:09 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,16,QUERY,
test
,
'show databases'
,0
8
Sep 21 00:13:09 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,17,QUERY,
test
,
'show tables'
,0
9
Sep 21 00:13:14 centos1 mysql-server_auditing: centos1.localdomain,root,localhost,1,18,QUERY,
test
,
'show tables'
,0
日志写到 /var/log/messages 文件是由 /etc/rsyslog.conf 进行配置的:
1
*.info;mail.none;authpriv.none;
cron
.none /var/log/messages
1
if
$programname ==
'mysql-server_auditing'
then
/var/log/mariadbaudit1
英文原文:http://serge.frezefond.com/2013/09/mariadb-audit-plugin-logging-to-syslog/
- MariaDB Audit Plugin 将日志保存到 syslog
- MariaDB Audit Plugin 1.3
- MariaDB Audit Plugin 1.2
- mysql审计插件--MariaDB Audit Plugin
- 在chroot环境下将MySQL日志输出到syslog
- 配置log4j和logback将日志记录到syslog
- 将log4j日志写入syslog
- 用Log4j 将日志保存到数据库
- 使用qInstallMsgHandler将日志保存到文件
- log4j 将日志保存到数据库
- log4j将记录日志保存到数据库
- log4j将记录日志保存到数据库
- log4j将记录日志保存到数据库
- 将日志保存到文件中
- php如何将日志写进syslog
- 将log4j日志写入Linux syslog
- 配置Syslog输出到远程日志服务器
- MySQL Audit Plugin
- 快速排序(递归和非递归)
- 使用libusb库枚举mac设备下面的USB设备
- 设置core
- global.asax?app.config?webconfig??
- XAMPP在mac下启动失败,提示已经启动。
- MariaDB Audit Plugin 将日志保存到 syslog
- Linux远程访问windows时,出现"连接被对端重置"错误
- POJ 2718 Smallest Difference
- Objective-C:Categories
- undo log与redo log原理分析
- C++中extern “C”含义深层探索
- 五大COBIT5原则助力更好的云计算——APMG-2013城市路演活动(趋势引领北京/深圳站)
- ubuntu 歌名乱码问题解决方案
- 分析B树的回溯实现方式