首页 > 代码库 > Rsyslog+LogAnalyzer+MySQL部署日志服务器
Rsyslog+LogAnalyzer+MySQL部署日志服务器
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
实验:Rsyslog+LogAnalyzer+MySQL部署日志服务器
环境centos 7 ip:10.1.23.101
1.安装程序包
# yum install rsyslog-mysql -y
2.启动配置数据库
# GRANT ALL ON Syslog.* TO ‘rsyslog‘@‘127.0.0.1‘ IDENTIFIED BY ‘123‘;
# GRANT ALL ON Syslog.* TO ‘rsyslog‘@‘local‘ IDENTIFIED BY ‘123‘;
3.生成需要的数据库和表
#rpm -ql ryslog-mysql
# mysql -ursyslog -h127.0.0.1 -prsyslogpass < /usr/share/doc/rsyslog-7.4.7/mysql-createDB.sql
4.配置rsyslog服务和连接mariadb数据库
(1)启用数据库输出模块
$ModLoad ommysql
(2)配置RUELS,将期望的日志信息记录于mysql
(3)重启rsyslog
5. 准备loganalyzer
(1)准备amp环境
# yum install httpd php php-mysql php-gd
# systemctl start httpd.service
(2)安装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
(3)浏览器配置
http://http://10.1.23.101/log/
点击NEXT,直到Step 7,配置如下界面
进入界面
本文出自 “zhang1003995416” 博客,谢绝转载!
Rsyslog+LogAnalyzer+MySQL部署日志服务器