Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建

Posted Linux那些事儿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建相关的知识,希望对你有一定的参考价值。

1、nginx安装+php支持

1)/etc/portage/package.use添加use

www-servers/nginx NGINX_MODULES_HTTP: fastcgi

2)安装Nginx

# emerge --ask www-servers/nginx

3)添加php支持

a、/etc/portage/package.use添加use

dev-lang/php fpm mysqli gd

注:mysqli让php支持mysql,gd支持loganalyzer柱形图

b、安装php

# emerge --ask dev-lang/php

c、php支持unix socket

# vi /etc/php/fpm-php7.2/fpm.d/www.conf

# systemctl enable php-fpm@7.2.service

# systemctl restart php-fpm@7.2.service

d、# vi /etc/nginx/nginx.conf

server {
                listen 127.0.0.1;
                server_name localhost;

                access_log /var/log/nginx/localhost.access_log main;
                error_log /var/log/nginx/localhost.error_log info;

                root /var/www/localhost/loganalyzer;
                location ~ \.php$ {
                       try_files $uri =404;
                       include /etc/nginx/fastcgi.conf;
                       fastcgi_pass unix:/run/php-fpm.socket;
                }

}

# systemctl enable nginx.service

# systemctl start nginx.service

2、Mysql安装

1)安装Mysql

# emerge --ask dev-db/mysql

2)配置Mysql

# emerge --config dev-db/mysql

注:这会创建数据库、设定权限和root密码

去除anonymous users和test databases

# mysql_secure_installation

登录

# mysql -u root -p -h localhost

3)启动服务

# systemctl enable mysqld.service

# systemctl start mysqld.service

3、Rsyslog安装及Mysql支持配置

1)/etc/portage/package.use添加use

app-admin/rsyslog mysql

2)安装Rsyslog

# emerge --ask app-admin/rsyslog

# systemctl enable rsyslog.service

# systemctl start rsyslog.service

3)配置/etc/rsyslog.conf

4)配置Mysql支持

# vi /usr/share/doc/rsyslog-8.33.1/scripts/mysql/createDB.sql


CREATE DATABASE Syslog;
USE Syslog;
CREATE TABLE SystemEvents
(
        ID int unsigned not null auto_increment primary key,
        CustomerID bigint,
        ReceivedAt datetime NULL,
        DeviceReportedTime datetime NULL,
        Facility smallint NULL,
        Priority smallint NULL,
        FromHost varchar(60) NULL,
        Message text,
        NTSeverity int NULL,
        Importance int NULL,
        EventSource varchar(60),
        EventUser varchar(60) NULL,
        EventCategory int NULL,
        EventID int NULL,
        EventBinaryData text NULL,
        MaxAvailable int NULL,
        CurrUsage int NULL,
        MinUsage int NULL,
        MaxUsage int NULL,
        InfoUnitID int NULL ,
        SysLogTag varchar(60),
        EventLogType varchar(60),
        GenericFileName VarChar(60),
        SystemID int NULL
);
CREATE TABLE SystemEventsProperties
(
        ID int unsigned not null auto_increment primary key,
        SystemEventID int NULL ,
        ParamName varchar(255) NULL ,
        ParamValue text NULL
);


# mysql -u root -p < /usr/share/doc/rsyslog-8.33.1/scripts/mysql/createDB.sql


mysql> grant all on Syslog.* to 'rsyslog-user'@'localhost' identified by 'gentoo'; 
注:gentoo为rsyslog-user的密码
mysql> flush privileges;

systemctl daemon-reload

systemctl restart mysqld.service

systemctl restart rsyslog.service

4、LogAnalyzer安装

1)安装

# wget http://download.adiscon.com/loganalyzer/loganalyzer-4.1.5.tar.gz

# tar zxvf loganalyzer-4.1.5.tar.gz

# cd loganalyzer-4.1.5

# mkdir /var/www/localhost/loganalyzer

# cp -r src/* /var/www/localhost/loganalyzer

# cp -r contrib/* /var/www/localhost/loganalyzer

# cd /var/www/localhost/loganalyzer

# chmod +x configure.sh secure.sh

# ./configure.sh

注:生成config.php

2)浏览器网址输入 http://127.0.0.1/index.php


Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建

Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建

Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建

Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建

Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建





    



以上是关于Gentoo+Nginx+php+Mysql+Rsyslog+LogAnalyzer日志监控系统搭建的主要内容,如果未能解决你的问题,请参考以下文章

LNMP架构 源码安装nginx+mysql+php+memcache+论坛

什么是 lnmp 实现原理。

Ubuntu系统下lnmp环境的搭建

LNMP架构搭建详细部署

源码编译安装LNMP

php递归查询