1. 程式人生 > >日誌管理之小實驗:實現loganalyzer

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

spa 16px www oracle createdb analyzer name yum quick

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

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

實驗步驟如下:

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

①安裝數據庫包

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

②創建數據庫用戶

[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)

二、centos6(192.168.152.166)準備日誌

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

[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服務

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

技術分享

三、centos6-1(192.168.152.168)配置

①在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

四、最終搭建效果如下圖

技術分享

技術分享

技術分享

點擊finish

技術分享

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

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