学习编程 2018-02-20
http://liang-yao.cnblogs.com/p/8448362.html
导入数据库
mysql -u root -p < /usr/share/doc/rsyslog-7.4.7/mysql-createDB.sql
可以通过 rpm -ql rsyslog-mysql | grep createDB查询位置
/usr/share/doc/rsyslog-7.4.7/mysql-createDB.sql
创建用户并授予权限
grant all on Syslog.* to rsyslogs@localhost identified by '123456';
刷新权限
flush privileges;
#### MODULES ####
$ModLoad ommysql
*.*:ommysql:localhost,Syslog,rsyslogs,123456
Syslog为数据库名,rsyslogs为数据库的用户,123456为该用户密码
$ModLoad immark #immark是模块名,支持日志标记
$ModLoad imtcp #支持TCP协议
$InputTCPServerRun 514 #打开514端口以接收日志
systemctl restart rsyslog
vim /etc/rsyslog.conf
*.* @@192.168.200.101:514
systemctl restart rsyslog
cat /var/log/messages
02为log-client主机名(主机名不要相同)
wget http://download.adiscon.com/loganalyzer/loganalyzer-4.1.5.tar.gz
tar xzvf loganalyzer-4.1.5.tar.gz
cd loganalyzer-4.1.5/src/
mkdir /usr/share/nginx/html/loganalyzer
mv * /usr/share/nginx/html/loganalyzer
chown -R nginx:nginx /usr/share/nginx/html/loganalyzer/*
访问http://192.168.200.101/loganalyzer/
touch /usr/share/nginx/html/loganalyzer/config.php
chmod 666 /usr/share/nginx/html/loganalyzer/config.php
使用Log4j的SystemLogAppender可以实现远程的日志输出,为集中式的日志管理提供便利。/etc/init.d/syslog start3. 在写日志的客户机上,修改log4j配置文件: