Experiment-----Show logs in the database through Loganalyzer

Source: Internet
Author: User
Tags fpm prepare syslog rsyslog

Lab Environment:

Three hosts: MARIADB server ip:192.168.199.136

Rsyslog Server ip:192.168.199.137

Lap architecture, and install loganalyzer,ip:192.168.199.134

1. Prepare MARIADB Server

①yum Install Mariadb-server Installation Database

②mysql_secure_installation run security script, set root administrator, password is 123456

③systemctl Start mariadb Startup service

④ authorized Rsyslog on MySQLServer to connect to the current server:

mysql-uroot-p123456 Login database, then authorize

GRANT all on syslog.* to ' loguser ' @ ' 192.168.199.% ' identified by ' 123456 ';

650) this.width=650; "src=" https://s4.51cto.com/oss/201710/26/b95bdf8b67d7005b5e49c609d3760b00.jpg "style=" float: none; "title=" image 1.jpg "alt=" B95bdf8b67d7005b5e49c609d3760b00.jpg "/>

2. Prepare Rsyslog Server

①yum Install rsyslog-mysql installation of MySQL module related packages

② needs to create databases and tables for Rsyslog on the MySQL server, so copy the script file to the database server and run it.

Scp/usr/share/doc/rsyslog-mysql-5.8.10/createdb.sql 192.168.199.136:

MySQL Server run: mysql-uroot-p123456 </usr/share/doc/rsyslog-7.4.7/mysql-createdb.sql

Alternatively, execute directly on the Rsyslog

mysql-uloguser-p123456-h192.168.199.131</usr/share/doc/rsyslog-7.4.7/mysql-

Createdb.sql

Result: You can see that the Syslog database has been created, as well as the SystemEvents table

650) this.width=650; "src=" Https://s4.51cto.com/oss/201710/26/e1f12c1deb123891845396fa1799a7d9.jpg "title=" Picture 2.jpg "style=" Float:none; "alt=" e1f12c1deb123891845396fa1799a7d9.jpg "/>

③ Configure Rsyslog to save logs to MySQL

Vim/etc/rsyslig.conf

# # # # MODULES # #

$ModLoad Ommysql

# # # RULES # #

Facility.priority:ommysql:dbhost,dbname,dbuser, PASSWORD

Like *.info;mail.none;authpriv.none;cron.none:ommysql:192.168.199.136,syslog.

, loguser,123456 says that in addition to a specific log, the rest is placed in the database

650) this.width=650; "src=" Https://s5.51cto.com/oss/201710/26/606022bb53ad08736c731e4944450537.jpg "title=" Picture 3.jpg "style=" Float:none; "alt=" 606022bb53ad08736c731e4944450537.jpg "/>

④service Rsyslog Restart Restart log service


3 , prepare lap Environment

① Installing the necessary packages

Yum install httpd php-fpm php-mysql PHP-GD

If you are installing PHP-FPM, you need to modify the httpd configuration file to support fcgi mode. If you are installing PHP, you do not need to

Vim/etc/httpd/conf/httpd.conf

To modify the default page:

DirectoryIndex index.php index.html Index.html.var

Add four rows:

Proxyrequests OFF

Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/var/www/html/$1

AddType application/x-httpd-php. php

AddType Application/x-httpd-php-source. Phps

② Start Service

Service PHP-FPM Start

Service httpd Restart

4. Realize Loganalyzer  

① Installing Loganalyzer on the lap server

Tar xf loganalyzer-4.1.5.tar.gz download software and unzip

Cp-a loganalyzer-4.1.5/src/var/www/html/log Copy the required files to the main site log

Cd/var/www/html/log

Touch config.php creating PHP Web Files

chmod 644 config.php Modify permissions so that they can execute

Service httpd Restart Restart the httpd services to make the configuration effective

② Configuration Loganalyzer

Web Access: Http://192.168.199.134//log The following interface appears, specifically:  

650) this.width=650; "src=" https://s2.51cto.com/oss/201710/26/5a8d4b164231386d5781d0a3bf7a4388.jpg "style=" float: none; "title=" Image 4.jpg "alt=" 5a8d4b164231386d5781d0a3bf7a4388.jpg "/>

650) this.width=650; "src=" https://s2.51cto.com/oss/201710/26/358423eae4ee7b065da7455bbab50bfa.jpg "style=" float: none; "title=" Image 5.jpg "alt=" 358423eae4ee7b065da7455bbab50bfa.jpg "/>

650) this.width=650; "src=" https://s2.51cto.com/oss/201710/26/4327af6439c79b6c7ba10b8fcb80d213.jpg "style=" float: none; "title=" Image 6.jpg "alt=" 4327af6439c79b6c7ba10b8fcb80d213.jpg "/>

650) this.width=650; "src=" https://s2.51cto.com/oss/201710/26/5e63cf1275829e79e21d95a3f2eb466d.jpg "style=" float: none; "title=" Image 7.jpg "alt=" 5e63cf1275829e79e21d95a3f2eb466d.jpg "/>

Then fill in the table: MySQL Native, Syslog fields, Monitorware

192.168.199.136,syslog,systemevents,loguser,123456

And then next is done.

650) this.width=650; "src=" Https://s2.51cto.com/oss/201710/26/02ccf941c0339dd59485eeb56fe4afaa.jpg "title=" Picture 8.jpg "style=" Float:none; "alt=" 02ccf941c0339dd59485eeb56fe4afaa.jpg "/>


Thank you for browsing, if you have different views, welcome message

650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0080.gif "alt=" J_0080.gif "/>

Experiment-----Show logs in the database through Loganalyzer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.