Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Implementation of managing rsyslog logs based on MySQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Summary of the experiment:

The default system for this lab host is Centos 6.9.

Host1 host is installed as a remote log client: rsyslog (default installation), rsyslog-mysql

The host2 host is installed as a log server: mysql (default installation, or mariadb 5 version can be installed)

Host3 host graphical management installation: httpd php php-mysql php-gd loganalyzer

1. Rsyslog records the log in MySQL

1. Host1 install rsyslog-mysql

Yum install rsyslog-mysql-yrpm-ql rsyslog-mysql # View generated file / lib64/rsyslog/ommysql.so # log file to database file module The log configuration file uses / usr/share/doc/rsyslog-mysql-5.8.10/ usr/share/doc/rsyslog-mysql-5.8.10/createDB.sql # to generate the database script scp / usr/share/doc/rsyslog-mysql-5.8.10/createDB.sql host2 # to send the database script to the log server

2. Host2 database configuration

Mysql_secure_installation # secure initialization of mysql-uUSERNAME-hHOST-pPASSWORD

< createDB.sql #执行创建数据库脚本,会生成Syslog数据库mysql>

GRANT ALL ON Syslog.* TO 'USER'@'HOST' IDENTIFIED BY' PASSWORD'; # create and authorize users example: GRANT ALL ON Syslog.* TO 'loguser'@'172.18.%.%' IDENTIFIED BY' magedu'

3. Host1 modify log configuration file rsyslog.conf

Vim / etc/rsyslog.conf$ModLoad ommysql # has been added to enable the module file facility.priority: ommysql:DBHOST,DBNAME,DBUSER, PASSWORD # to send the logs you want to record to the database server, as in the following example * .info: ommysql:172.18.22.77,Syslog,loguser, mageduservice rsyslog restart # restart the service

Second, display the logs in the database through loganalyzer

1. Host3 install httpd php php-mysql php-gd

Yum install httpd php php-mysql php-gd-y

2. Test whether the database is connected

Close host2, host3 Firewall and SElinuxvim / var/www/html/index.php # to edit the test file if (mysqli_connect_errno ()) {echo "failed to connect to the database!"; $mysqli=null;exit;} echo "connected to the database successfully!"; $mysqli- > close (); phpinfo () ? > service httpd start visits IP

The connection is successful as shown in the figure.

3. Configure loganalyzer

# access to change address for configuration

Click next in the first few steps to go directly to the next step. To step 7, you need to fill in the configuration by hand.

Finally, click finish to enter the management page.

4. Security enhancement

Cd / var/www/html/loganalyzerchmod 644 config.php

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report