关闭SeLinux

1、  环境

centos7 Rsyslogloganalyzer+数据库服务器 IP地址为:10.41.1.87

客户端:10.41.1.85

2、  Rsyslog的安装与配置

安装数据库:

yum install mariadb-server

启动数据库

systemctl start mariadb.service

[root@localhost ~]# netstat -lntup|grep 3306

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1688/mysqld

配置数据库

    mysql_secure_installation#默认root没有密码

安装数据库驱动包

yum install rsyslog-mysql   #rsyslog链接数据库需要使用此驱动包

rpm -ql rsyslog-mysql      #看看安装了哪些文件

[root@localhost ~]# rpm -ql rsyslog-mysql

/usr/lib64/rsyslog/ommysql.so

/usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql

创建日志用户

    mysql -uroot -p

    grant all on Syslog.* to loguser@'10.41.%.%' identified by '111111';

    flush privileges

验证:

mysql -uloguser -p111111 -h10.41.1.87

导入数据库:

    mysql -uloguser -h10.41.1.87 -p </usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql

查看:

mysql -uloguser -p111111 -h10.41.1.87

show databases; //查看是否有Syslog数据库

use Syslog;

show tables;

配置rsyslog服务器可以使用mysql

#### MODULES ####

$ModLoad ommysql

##信息模板

$template MySQLInsert,"insert into SystemEvents (Message, Facility, FromHost,Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%fromhost-ip%', %syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')",SQL

#### RULES ####

*.info;mail.none;authpriv.none;cron.none    :ommysql:10.41.1.87,Syslog,loguser,111111;MySQLInsert

# *.info;mail.none;authpriv.none;cron.none :ommysql:10.41.1.87,Syslog,loguser,111111

说明:

    ommysql  :模块   

    10.41.1.87 服务器IP       

    Syslog   数据库名

    loguser  登入用户

    111111   密码   

重启服务:

systemctl restart rsyslog

本机测试:

logger "this is a test log"

use Syslog

select count(*) from SystemEvents;

select * from SystemEvents;

select * from SystemEvents\G

3、  apache安装

yum install httpd php php-mysql  php-gd

systemctl start httpd

netstat -lntup|grep 80

4、  loganalyzer-4.1.7安装

tar zxf loganalyzer-4.1.7.tar.gz

mkdir /var/www/html/log

mv  loganalyzer-4.1.7/src/* /var/www/html/log

cd /var/www/html/log

chmod +x  ~/loganalyzer-4.1.7/contrib/configure.sh

chmod +x  ~/loganalyzer-4.1.7/contrib/secure.sh

~/loganalyzer-4.1.7/contrib/configure.sh

~/loganalyzer-4.1.7/contrib/secure.sh

chown -R apache.apache ..//log

web配置:

配置loganalyzer数据库:

Rsyslog+loganalyzer+mysql日志服务器_linux

 

添加loganalyzeradmin用户和密码

 

SystemEvents页面中为小写,改为大写开头,不然提示错误。

Rsyslog+loganalyzer+mysql日志服务器_linux_02

5、  客户端配置

Tcp

rsyslog.conf:

#### MODULES ####

$ModLoad imtcp

$InputTCPServerRun 514

$template myFormat,"10.41.1.85_34 %syslogpriority% %timestamp% %hostname% %syslogtag% %msg%"

#### RULES ####

*.*             @@10.41.1.87:514;myFormat#两个“@

UDP

$template myFormat,"192.168.82.129_34 %syslogpriority% %timestamp% %hostname% %syslogtag% %msg%"

*.* @192.168.92.1:9898;myFormat#一个”@”

6、  汉化包

[root@localhost lang]# pwd

/var/www/html/log/lang

mkdir zh

cd zh

上传中文汉化包