搭建一套企业级日志监控系统
概述
背景
公司原先基于MySQL的MSP监控项目已经无法满足集团对系统关键页面、关键业务和接口实现有效监控的要求,故更换新架构MSP-2:Kafka数据采集+ClickHouse数据库+Flink数据计算+Grafana看板
术语
- MSP-2:监控分析平台的简称
- Kafka:是由Apache软件基金会开发的一个开源流处理平台
- ClickHouse:是一个用于联机分析处理(OLAP)的开源列式数据库
- Zookeeper:是一个分布式的。开源的分布式应用程序协调服务
目标
MSP-2主要实现如下功能:
- 数据的采集
- 数据的分析计算
部署
话不多说,清楚了MSP-2系统是干什么的之后就开始干活吧。
部署架构图
注
- 新部署集群:ZK、Kafka、ClickHouse
- 现有服务改造:Flume,Grafana
- 现有功能无需改造:xxx系统、业务日志文件
部署实施方案
资源分配
仅供参考,每个公司可分配的资源不一样
集群高可用
数据存储方案
- Zookeeper数据存储
- Kafka数据存储
略
- ClickHouse数据存储
数据存储层次划分:
- ods:原始数据层
- dim:公共维度汇总层
- dwd:明细数据层
- dwm:数据中间层
- dws:数据服务层
- dwt:主题数据层
- ads:数据应用层
各层存放的数据维度不一样
权限分配方案
略
系统安装及配置
安装包准备
Zookeeper安装包准备
- cd /home/dev
- 安装包下载:wget http://archive.apache.org/dist/zookeeper/zookeeper-3.6.4/apache-zookeeper-3.6.4-bin.tar.gz
- 解压:tar -zxf apache-zookeeper-3.6.4-bin.tar.gz
- 重新打包Zookeeper安装包:
- mv ./apache-zookeeper-3.6.4-bin ./zookeeper
- zip -ry zookeeper.zip zookeeper
Kafka安装包准备
- 安装包下载:wget https://archive.apache.org/dist/kafka/3.5.0/kafka_2.12-3.5.0.tgz
- 下载的安装包解压缩:tar -zxf kafka_2.12-3.5.0.tgz
- 重新打包Kafka安装包:
- mv ./kafka_2.12-3.5.0 ./kafka
- zip -ry kafka.zip kafka
ClickHouse安装包准备
- cd /home/dev
- 安装包下载:
- wget https://packages.clickhouse.com/tgz/lts/clickhouse-client-22.3.10.22-amd64.tgz
- wget https://packages.clickhouse.com/tgz/lts/clickhouse-common-static-22.3.10.22-amd64.tgz
- wget https://packages.clickhouse.com/tgz/lts/clickhouse-server-22.3.10.22-amd64.tgz
- 解压缩:
- tar -xzvf clickhouse-common-static-22.3.10.22-amd64.tgz
- tar -xzvf clickhouse-client-22.3.10.22-amd64.tgz
- tar -xzvf clickhouse-server-22.3.10.22-amd64.tgz
- ClickHouse-Server安装包分发:
- mkdir ./clickhouse-server
- mkdir ./clickhouse-server/bin
- mkdir ./clickhouse-server/etc
- mkdir ./clickhouse-server/run
- cp -rf ./clickhouse-common-static-22.3.10.22/usr/bin/* ./clickhouse-server/bin
- cp -rf ./clickhouse-server-22.3.10.22/usr/bin/* ./-clickhouse-server/bin
- cp -rf ./clickhouse-server-22.3.10.22/etc/clickhouse-server/* ./clickhouse-server/etc
- sed -i “s#/var/log/#/data/log/#g” ./clickhouse-server/etc/config.xml
- sed -i “s#/var/lib/#/data/data/#g” ./clickhouse-server/etc/config.xml
- ClickHouse-Client安装包分发:
- mkdir ./clickhouse-client
- mkdir ./clickhouse-client/bin
- mkdir ./clickhouse-client/etc
- cp -rf ./clickhouse-common-static-22.3.10.22/usr/bin/* ./clickhouse-client/bin
- cp -rf ./clickhouse-client-22.3.10.22/usr/bin/* ./clickhouse-client/bin
- cp -rf ./clickhouse-client-22.3.10.22/etc/clickhouse-client/* ./clickhouse-client/etc
- zip -ry clickhouse-server.zip clickhouse-server
- zip -ry clickhouse-client.zip clickhouse-client
Flume安装包准备
- cd /home/dev
- 安装包下载:wget https://dlcdn.apache.org/flume/1.11.0/apache-flume-1.11.0-bin.tar.gz
- 解压缩:tar -zxf apache-flume-1.11.0-bin.tar.gz
- 重新打包:
- mv ./apache-flume-1.11.0-bin ./flume
- zip -ry flume.zip flume
操作系统配置
- 创建存储目录:
- su dev
- mkdir /work/app
- mkdir /data/data
- mkdir /data/log
Java安装
- sudo yum -y install java-1.8.0-openjdk-devel
- java -version
Zookeeper集群
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 启航苑&博客!