日誌管理之小實驗:實現loganalyzer

實驗目的:以報表圖形格式展現數據庫,便於觀看和理解php

實驗工具:三臺主機(A主機:centos7--配置數據庫    B主機:centos6--記錄日誌   C主機:centos6-1--實現以報表方式展現數據庫中的日誌)html

實驗步驟以下:mysql

1、A機器centos7(192.168.152.167):安裝並配置對應數據庫sql

①安裝數據庫包數據庫

[root@centos7 ~]# yum install mariadb-server
[root@centos7 ~]# systemctl start mariadb
[root@centos7 ~]# mysql_secure_installation 
[root@centos7 ~]# mysql -uroot -p123456 < createDB.sql

②建立數據庫用戶vim

[root@centos7 ~]# mysql -uroot -p123456 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| Syslog |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use Syslog;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [Syslog]> show tables;
+------------------------+
| Tables_in_Syslog |
+------------------------+
| SystemEvents |
| SystemEventsProperties |
+------------------------+
2 rows in set (0.00 sec)
2 rows in set (0.00 sec)

MariaDB [Syslog]> grant all on Syslog.* to loguser@'192.168.152.166' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

2、centos6(192.168.152.166)準備日誌centos

①安裝軟件包並修改配置文件服務器

[root@centos6 ~]# yum install rsyslog-mysql
[root@centos6 ~]# scp /usr/share/doc/rsyslog-mysql-5.8.10/createDB.sql 192.168.152.167:
[root@centos6 ~]# vim /etc/rsyslog.conf (配置日誌文件)
#*.info;mail.none;authpriv.none;cron.none /var/log/messages
*.info;mail.none;authpriv.none;cron.none :ommysql:192.168.152.167,Syslog,loguser,123456

②重啓rsyslog服務ide

[root@centos6 ~]# service rsyslog restart 
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
測試一下數據是否寫入:
[root@centos6 ~]# logger "this is a test log"

3、centos6-1(192.168.152.168)配置php-fpm

①在rsyslog服務器上準備amp

[root@centos6 ~]# cd /var/www/html/
[root@centos6 /var/www/html]# yum install httpd php php-mysql php-gd

②安裝並配置loganalyzer

[root@centos6 /var/www/html]# tar xvf loganalyzer-4.1.5.tar.gz
[root@centos6 /var/www/html/loganalyzer-4.1.5]# cp -r src/ /var/www/html/log
[root@centos6 /var/www/html/loganalyzer-4.1.5]# cd /var/www/html/log
[root@centos6 /var/www/html/log]# touch config.php
[root@centos6 /var/www/html/log]# chmod 666 config.php 
[root@centos6 /var/www/html/log]# service httpd restart

4、最終搭建效果以下圖

點擊finish

小編本來是在centos7上搭建的基於php-fpm的

相關文章
相關標籤/搜索