通过loganalyzer展示数据库中的日志

一、安装mysql
# yum -y install mariadb-server
# systemctl enable --now mariadb && systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2021-12-25 03:56:37 EST; 2min 38s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 31604 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCE>
Process: 31470 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited>
Process: 31445 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 31573 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 11303)
Memory: 87.3M
CGroup: /system.slice/mariadb.service
└─31573 /usr/libexec/mysqld --basedir=/usr
二、安装rsyslog
# yum -y install rsyslog-mysql
#将sql脚本复制到数据库服务器
# scp /usr/share/doc/rsyslog/mysql-createDB.sql 10.0.0.28:/root/
三、配置mysql服务器
3.1 导入数据库
# mysql -uroot < mysql-createDB.sql
# mysql -e "show databases;"
+--------------------+
| Database |
+--------------------+
| Syslog |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3.2 创建授权用户
# mysql -e "create user rsyslog@'10.0.0.%' identified by '123456';"
# mysql -e "grant all on Syslog.* to 'rsyslog'@'10.0.0.%';"
# mysql -e "select user,host from mysql.user;"
+---------+--------------+
| user | host |
+---------+--------------+
| rsyslog | 10.0.0.% |
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
| root | mysql-server |
+---------+--------------+
四、配置rsyslog服务器
4.1 配置日志服务器将日志发送至指定数据库
[root@ rsyslog-server ~]#vim /etc/rsyslog.conf
####MODULES#### #在 MODULES 语言下面添加
module(load="ommysql")
#在RULES语句块下面添加
#### RULES ####
#facility.priority :ommysql:DBHOST,DBNAME,DBUSER, PASSWORD
*.info :ommysql:10.0.0.28,Syslog,rsyslog,123456
[root@ rsyslog-server ~]# systemctl restart rsyslog.service
4.2 测试
#在日志服务器上生成日志
# logger "this is a test log"
#在数据库上查询到上面的测试日志
$> mysql -e "select count(*) from Syslog.SystemEvents;"
+----------+
| count(*) |
+----------+
| 1907 |
+----------+
# 可以看到测试日记已经存到Mysql的Syslog库中
# mysql -e "select * from Syslog.SystemEvents\G" | grep -C10 "this is a test log"
GenericFileName: NULL
SystemID: NULL
*************************** 1904. row ***************************
ID: 1904
CustomerID: NULL
ReceivedAt: 2021-12-25 17:25:29
DeviceReportedTime: 2021-12-25 17:25:29
Facility: 1
Priority: 5
FromHost: reyslog
Message: this is a test log
NTSeverity: NULL
Importance: NULL
EventSource: NULL
EventUser: NULL
EventCategory: NULL
EventID: NULL
EventBinaryData: NULL
MaxAvailable: NULL
CurrUsage: NULL
MinUsage: NULL
五、部署配置LogAnalyzer
5.1 安装LogAnalyzer
# wget https://download.adiscon.com/loganalyzer/loganalyzer-4.1.10.tar.gz
# tar xvf loganalyzer-4.1.10.tar.gz
# mkdir /var/www/html/log
# mv loganalyzer-4.1.10/src/* /var/www/html/log
5.2 安装相关服务
# yum -y install httpd php-fpm php-mysqlnd php-gd
# systemctl enable --now httpd php-fpm && systemctl status httpd php-fpm
5.3 测试php
php是使用套接字和httpd通讯的,并非监听在9000端口。
需要监听在端口,修改配置文件/etc/php-fpm.d/www.conf,监听端修改为:listen = 127.0.0.1:9000
# cat > /var/www/html/info.php << EOF
<?php phpinfo() ?>
EOF
# 打开浏览器访问http://10.0.0.38/info.php,没问题继续下一步操作
六、基于 web 页面初始化LogAnalyzer
6.1 打开浏览器
访问http://10.0.0.38/log 实现初始化


6.2 提示缺失配置文件
# touch /var/www/html/log/config.php
# chmod 666 /var/www/html/log/config.php
6.3 重新访问




6.4 测试
[root@reyslog ~]# logger "this is a test log"
[root@reyslog ~]# logger "this is a newtest log

图表展示

通过loganalyzer展示数据库中的日志的更多相关文章
- 通过 loganalyzer 展示数据库中的系统日志
目录 通过 loganalyzer 展示数据库中的日志 环境准备 准备服务器: 日志服务器: 数据库服务器: 测试日志服务器和数据库是否连接: websrv服务器端: 通过 loganalyzer 展 ...
- Linux学习-通过loganalyzer展示MySQL中rsyslog日志
一.实验环境 系统:CentOS7.6 软件包:apache,php,mariadb-server (都是基于光盘yum源) 源码包:loganalyzer-4.1.7.tar.gz (http:// ...
- jsp案例--展示数据库中的数据
一.什么是jsp? JAVA SERVER PAGES java的动态网页,servlet用来获取数据处理业务,擅长处理与java代码有关的内容.jsp展示数据,擅长处理与html有关的内容. 二.如 ...
- SQL Server 2008 R2 清空数据库中ldf日志文件
/************************************************************ * Sql Server 2008 R2 清空数据库中ldf日志文件 * 将 ...
- Python Django CMDB项目实战之-2创建APP、建模(models.py)、数据库同步、高级URL、前端页面展示数据库中数据
基于之前的项目代码来编写 Python Django CMDB项目实战之-1如何开启一个Django-并设置base页index页文章页面 现在我们修改一个文章列表是从数据库中获取数据, 下面我们就需 ...
- 史林枫:sqlserver数据库中数据日志的压缩及sqlserver占用内存管理设置
使用sqlserver和IIS开发.net B/S程序时,数据量逐渐增多,用户也逐渐增多,那么服务器的稳定性就需要维护了.数据库如何占用更小内存,无用的日志如何瞬间清空? 今天在给一个客户维护网站的时 ...
- django开发博客01-页面展示数据库中的数据
1.首先在views.py中引入models.py的 Category这个类 然后在函数中(blog)写执行逻辑 categorys 返回的对象是是一个list"<QuerySet [ ...
- SQL Server清空数据库中ldf日志文件
USE [master] ALTER DATABASE [Whir_InternalSystem] SET RECOVERY SIMPLE WITH NO_WAIT ALTER DATABASE [W ...
- C#-WinForm-ListView-表格式展示数据、如何将数据库中的数据展示到ListView中、如何对选中的项进行修改
在展示数据库中不知道数量的数据时怎么展示最好呢?--表格 ListView - 表格形式展示数据 ListView 常用属性 HeaderStyle - "详细信息"视图中列标头的 ...
随机推荐
- .NetCore下构建自己的文件服务管理(UosoOSS)
Web开发系统文件默认存储在wwwroot目录下面,现在越来越多的系统服务化了,UI也更加多元化,当然文件可以用第三方的文件服务,但是这里准备文件分离出来构建自己的文件服务配合数据库表来实现(Uoso ...
- linux -安装redis ,配置密码,开启远程访问
1.安装 添加epel源yum install epel-release查看yum repolist安装redis命令yum install redis查看Redis安装了哪些文件find / -na ...
- mysql5.7初始化密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement
mysql初始化密码常见报错问题 1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password 2 ...
- Go语言系列之性能调优
在计算机性能调试领域里,profiling 是指对应用程序的画像,画像就是应用程序使用 CPU 和内存的情况. Go语言是一个对性能特别看重的语言,因此语言中自带了 profiling 的库,这篇文章 ...
- 鲜为人知的一些meta标签作用
来自UC Scrat-team http://scrat-team.github.io/ <meta name="viewport" content="width= ...
- iframe页面总是提示需要重新登录怎么办
原文链接:iframe页面二次登录问题 生产问题 问题背景 由于历史原因,公司内部系统有一些页面是基于iframe嵌入的其他系统的页面,之前一直运行正常,最近不知什么原因接连出现访问所有iframe页 ...
- GitHub 公布 2021 Top 10 博文「GitHub 热点速览」
作者:HelloGitHub-小鱼干 2021 年在这周彻底同我们告别了,在本周的「News 快读」模块你可以看到过去一年 GitHub 的热门文章,其中有我们熟悉的可能让很多程序员"失业& ...
- [论文翻译] 分布式训练 Parameter Sharding 之 Google Weight Sharding
[论文翻译] 分布式训练 Parameter sharding 之 Google Weight Sharding 目录 [论文翻译] 分布式训练 Parameter sharding 之 Google ...
- day1 三位数各个位上的数字和
int main(){ int x = 0; scanf("%d", &x); if (x > 999 || x < 0) { printf("输入错 ...
- [µC/GUI 学习]µC/GUI移植
一.什么是µC/GUI µC/GUI为任何需要图形显示器的嵌入式应用提供了一种灵活的图形用户界面(GUI).µC/GUI允许软件工程师在使用了LCD显示器的产品上增加美轮美奂的用户界面,从简单的2D黑 ...