rsyslog记录日志于mysql:
前提:准备好msql server或mariadb server;
(1) 安装rsyslog连接至mysql server的驱动模块;
# yum install rsyslog-mysql
(2) 在mysql server准备rsyslog专用的用户账号;
GRANT ALL ON Syslog.* TO 'rsyslog'@'127.0.0.1' IDENTIFIED BY 'rsyslogpass';
GRANT ALL ON Syslog.* TO 'rsyslog'@'local' IDENTIFIED BY 'rsyslogpass';
(3) 生成所需要的数据库和表;
mysql -ursyslog -h127.0.0.1 -prsyslogpass < /usr/share/doc/rsyslog-7.4.7/mysql-createDB.sql
(4) 配置rsyslog使用ommysql模块
#### MODULES ####
……
$ModLoad ommysql
(5) 配置RULES,将所期望的日志信息记录于mysql中;
facility.priority :ommysql:DBHOST,DB,DBUSER,DBUSERPASS
(6) 重启rsyslog服务;
(7) loganalyzer
WebGUI, 运行amp环境中;
(a) 准备amp环境
# yum install httpd php php-mysql php-gd
# systemctl start httpd.service
(b) 安装loganalyzer
# tar xf loganalyzer-VERSION.tar.gz
# cd loganalyzer-VERSION
# cp -a src /var/www/html/loganalyzer-VERSION
# cd /var/www/html
# ln -sv loganalyzer-VERSION log
# cd log
# touch config.php
# chmod 666 config.php
打开浏览器,配置;
MySQL Native, Syslog Field
Table Type:"Monitorware“
# chmod 644 config.php
原创文章,作者:songzizhe,如若转载,请注明出处:http://www.178linux.com/55864