准备两个节点
node3: rsyslog
node2: 数据库
准备相应的包
[[email protected] php-fpm.d]#yum install rsyslog-mysql
将数据拷贝到数据库节点,让其创建表
[[email protected] php-fpm.d]#scp /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql node2:/data/
在mysql server上授权rsyslog能连接至当前服务器
[[email protected] data]#mysql < mysql-createDB.sql #:导入数据库和表 MariaDB [powerdns]> GRANT ALL ON Syslog.* TO ‘syslog‘@‘192.168.37.%‘ IDENTIFIED BY ‘centos‘; Query OK, 0 rows affected (0.00 sec) MariaDB [powerdns]> flush privileges; Query OK, 0 rows affected (0.00 sec)
配置rsyslog文件
[[email protected] php-fpm.d]#vim /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514 #打开远程端口
$ModLoad ommysql #:启用模块 *.info;mail.none;authpriv.none;cron.none :ommysql:192.168.37.22,Syslog,syslog,centos #:配置连接账号
重启服务
[[email protected] php-fpm.d]#systemctl restart rsyslog
通过loganalyzer展示数据库中的日志
准备好LAMP组合
解压LogAnalyzer
[[email protected] source]#tar xf loganalyzer-4.1.7.tar.gz
添加虚拟主机
[[email protected] src]#vim /app/httpd24/conf/extra/httpd-vhosts.conf <virtualhost *:80> ServerName logs.magedu.com DocumentRoot "/data/logs/" <Directory "/data/logs/"> require all granted </Directory> ProxyPassMatch "^/(.*\.php)$" "fcgi://127.0.0.1:9000/data/logs/" </Virtualhost>
创建文件,并将解压好的文件移到到文档目录
[[email protected] src]#mkdir /data/logs[[email protected] src]#mv /data/source/loganalyzer-4.1.7/src/* /data/logs/
进到文档目录创建文件并修改权限
[[email protected] src]#cd /data/logs/ [[email protected] logs]#touch config.php [[email protected] logs]#chmod 666 config.php
重启服务
[[email protected] logs]#apachectl restart
测试
原文地址:https://www.cnblogs.com/maxuebin/p/11251590.html
时间: 2024-10-06 10:09:58