简介

Frostmourne(霜之哀伤) 是汽车之家经销商技术部监控系统的开源版本,用于帮助监控几乎所有数据库数据 (包括 Elasticsearch, Prometheus, SkyWalking, MySql 等等)。如果你已经建立起了日志系统, 指标体系,却苦恼于没有一个配套监控系统,也许它能帮到你。

支持数据源:Elasticsearch, HTTP, SkyWalking, Prometheus, InfluxDB, MySQL/TiDb, ClickHouse, SqlServer, PING, IotDB, Telnet

支持告警发送方式:钉钉 (机器人)、企业微信 (机器人)、飞书机器人、OneMessage 机器人、Email、短信、HTTP。(text, markdown)

支持 LDAP 认证和自动创建用户。

Elasticsearch 数据查询、分享和下载

报警消息抑制功能,防止消息轰炸;也有报警升级功能,避免故障相关方长时间得不到通知。

Github 地址:https://github.com/AutohomeCorp/frostmourne

环境要求:JAVA8-14、Mysql 8 数据库。

教程使用 Linux 版本:Rocky Linux 8 (关闭 SELinux)

版本:部署 1.0 版本

注意:目前不支持 ES8 的加密认证,需要等后期支持 JAVA 17

使用 ZIP 包部署(使用 Linux 环境)

下载 JDK(推荐使用 JDK8)

dnf install wget tree
## 安装 wget tree

cd /opt
mkdir java1.8
cd /opt/java1.8
wget --execute robots=off -nc -nd -r -l1 -A '*.gz' https://mirrors.tuna.tsinghua.edu.cn/Adoptium/8/jdk/x64/linux/
## 下载 OpenJDK8 二进制包,源为清华大学源,会自动下载最新版。

tar -zxvf OpenJDK8U-jdk_*.tar.gz 
## 解压

tree -L 2 /opt/java1.8/
/opt/java1.8/
├── jdk8u362-b09
│   ├── ASSEMBLY_EXCEPTION
│   ├── bin
│   ├── include
│   ├── jre
│   ├── lib
│   ├── LICENSE
│   ├── man
│   ├── NOTICE
│   ├── release
│   ├── sample
│   ├── src.zip
│   └── THIRD_PARTY_README
└── OpenJDK8U-jdk_x64_linux_hotspot_8u362b09.tar.gz

7 directories, 7 files


## 查看当前文件树
Plain text

PS:JDK 也可以手动去 https://mirrors.tuna.tsinghua.edu.cn/Adoptium/8/jdk/x64/linux/ 目录下进行下载最新版。

部署 Mysql(建议为 8 版本)

dnf install mysql-server

##Rocky 8 源默认安装 mysql8

systemctl enable --now mysqld

systemctl status mysqld.service 

## 设置开机并启动,查看启动状态
Plain text
mysql_secure_installation 

## 初始化 Mysql


## 如下,都选择 Y 即可,密码等级选择 0,然后配置 root 密码。


Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
Plain text

创建数据库导入 SQL 文件

wget https://github.com/AutohomeCorp/frostmourne/blob/master/doc/mysql-schema/frostmourne.sql

## 可能需要挂国际代理,或浏览器下载,使用 SCP 上传即可.

mysql -uroot -p < frostmourne.sql

#输入密码即可导入创建数据库。

mysql -uroot -p
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| frostmourne        |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)


#查看数据库是否正常创建, quit 命令退出。
Plain text

下载 frostmourne

cd /opt
mkdir frostmourne
cd frostmourne

wget https://github.com/AutohomeCorp/frostmourne/releases/download/1.0-RELEASE/frostmourne-monitor-1.0-RELEASE.zip

## 可能需要挂国际代理,或浏览器下载,使用 SCP 上传到 opt 目录即可.
## Github 下载地址 https://github.com/AutohomeCorp/frostmourne/releases

dnf install unzip 

unzip frostmourne-monitor*.zip 

tree 
.
├── application.properties
├── env
├── frostmourne-monitor-1.0-RELEASE.jar
├── frostmourne-monitor-1.0-RELEASE.zip
└── scripts
    ├── shutdown.sh
    └── startup.sh

1 directory, 6 files
## 文件树如上。
Plain text

修改 ENV 环境文件,配置 java 路径

vim /opt/frostmourne/env 


JAVA_HOME=/opt/java1.8/jdk8u362-b09
## 配置文件上面操作解压的 JDK 路径即可

JAVA_OPTS="-Xms1200m -Xmx2000m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m -Dfile.encoding=utf-8"
##JAVA 参数,可适当改大内存等参数。
Plain text

修改启动 app 配置 (也可以配置邮件发送服务器和 LDAP)

vim /opt/frostmourne/application.properties 

alarmlog_reserve_days=30
#配置监控日志保留天数

datasource_frostmourne_url=jdbc:mysql://127.0.0.1:3306/frostmourne?characterEncoding=utf8
#配置 mysql 数据库 IP 地址、数据库名字、编码。

datasource_frostmourne_username=root
datasource_frostmourne_password=Wow@123
#配置 mysql 数据库账号密码


frostmourne_monitor_address=192.168.124.100

#配置为本机 IP 地址即可

frostmourne_message_title=Wow
#配置实例名字
Plain text

启动测试

/opt/frostmourne/scripts/startup.sh 

./startup.sh: line 7: dos2unix: command not found
LOG_DIR: /opt/frostmourne/scripts/../logs
PID_FOLDER: /opt/frostmourne/scripts/../pid
Sun Mar 26 16:42:27 CST 2023 ==== Starting ==== 
Application is running as root (UID 0). This is considered insecure.
Started [5477]
Waiting for server startup..
Sun Mar 26 16:42:37 CST 2023 Server started in 10 seconds

ss -an | grep 10054
tcp   LISTEN 0      100                    *:10054           *:*                  

## 查看 10054 端口监听即可判断已正常启动。

/opt/frostmourne/scripts/shutdown.sh 

## 停止服务
Plain text

Web 访问: http://192.168.124.100:10054 即可测试,注意替换 IP

admin 管理账号默认的账号密码是 123456

注意:开启了 LDAP 认证,admin 账号仍然可以用初始密码登录。

配置为 Systemd 自定义服务并设置开机启动

vim /usr/lib/systemd/system/frostmourne.service 


[Unit]
Description=frost
After=network.target mysqld.service

[Service]
User=root
Type=forking
ExecStart=/opt/frostmourne/scripts/startup.sh
ExecStop=/opt/frostmourne/scripts/shutdown.sh
RemainAfterExit=yes



[Install]
WantedBy=multi-user.target

## 写入到文件保存。

systemctl daemon-reload
## 加载自定义服务
systemctl start frostmourne.service 
systemctl status frostmourne.service 

## 尝试启动,并查看状态。
systemctl enable frostmourne.service 

## 设置开启及并启动
Plain text

注意:需要等待网络服务和 mysql 启动之后,才会启动。

技术架构

frostmourne-vue:前端项目,使用 vue-element-template 实现,打包时会把生成的资源文件构建到 frostmourne-monitor

  • frostmourne-monitor:监控运行主体服务
    Frostmourne (霜之哀伤)日志监控系统部署安装
    Frostmourne (霜之哀伤) 日志监控系统部署安装

主要技术栈

  • springboot 2.x
  • element ui
  • vue-admin-template
  • xxl-job
  • mybatis
  • freemarker
  • elasticsearch
  • InfluxDB
  • jjwt
  • nashorn

    参考

官方文档:https://github.com/AutohomeCorp/frostmourne

注意:推荐配合 https://songxwn.com/elk/ ES 部署使用。