VictoriaMetrics 集群部署

蒙墨竹
2023-12-01

官网

## 官网
https://github.com/VictoriaMetrics/VictoriaMetrics

集群角色详解

VictoriaMetrics 集群模式。主要由 vmstorage ,vminsert,vmselect 三部分组成,这三个组件每个组件都可以单独进行扩展。其中:

  • vmstorage 负责提供数据存储服务
  • vminsert 是数据存储 vmstorage 的代理,使用一致性 hash 算法进行写入分片
  • vmselect 负责数据查询,根据输入的查询条件从 vmstorage 中查询数据

集群部署(K8S版)

集群部署可以选择部署在K8S里,比如通过helm形式,也可以通过二进制方式部署。安装K8S的方式参考如下:

##
https://docs.victoriametrics.com/guides/k8s-monitoring-via-vm-cluster.html

集群部署(二进制版)

## 二进制包下载地址
https://github.com/VictoriaMetrics/VictoriaMetrics/releases


下载cluster的所有包

## 
wget  https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.84.0/victoria-metrics-linux-amd64-v1.84.0-cluster.tar.gz


## 创建数据目录
mkdir  -p /data/vmstorage-data

## 创建临时缓存目录
mkdir -p /data/vm-tmp

部署vmstorage-prod 组件服务

vim /etc/systemd/system/vmstorage.service

[Unit]
Description=Vmstorage Server
After=network.target

[Service]
Restart=on-failure
WorkingDirectory=/data/vm-tmp
ExecStart=/opt/victoria-metrics-cluster/bin/vmstorage-prod -loggerTimezone Asia/Shanghai -storageDataPath /data/vmstorage-data -httpListenAddr :8482 -vminsertAddr :8400 -vmselectAddr :8401

[Install]
WantedBy=multi-user.target

部署 vminsert-prod 组件

vim /etc/systemd/system/vminsert.service

[Unit]
Description=Vminsert Server
After=network.target

[Service]
Restart=on-failure
WorkingDirectory=/data/vm-tmp
ExecStart=/opt/victoria-metrics-cluster/bin/vminsert-prod -httpListenAddr :8480 -storageNode=10.10.10.120:8400

[Install]
WantedBy=multi-user.target

部署 vmselect-prod 组件

vim /etc/systemd/system/vmselect.service

[Unit]
Description=Vmselect Server
After=network.target

[Service]
Restart=on-failure
WorkingDirectory=/data/vm-tmp
ExecStart=/opt/victoria-metrics-cluster/bin/vmselect-prod -httpListenAddr :8481 -storageNode=10.10.10.120:8401

[Install]
WantedBy=multi-user.target

启动

###
systemctl daemon-reload

##
systemctl list-unit-files|grep vm

## 启动 vmstorage
systemctl start vmstorage.service

## 
netstat -ntlp|grep vmstorage

##  启动 vminsert
systemctl start vminsert
netstat -ntlp|grep vmin

## 启动vmselect
systemctl enable vmselect && systemctl start vmselect

验证

## 查看vmstorage 的三个端口
curl http://127.0.0.1:8480/metrics
curl http://127.0.0.1:8481/metrics
curl http://127.0.0.1:8482/metrics

## 

proms集群写入

## 写入其他时序数据库
remote_write:
  - url: http://10.10.10.120:8480/insert/0/prometheus

查看图形化界面

## vmui
http://10.10.10.120:8481/select/0/vmui/


###
http://10.10.10.120:8481/select/0/

参考文章

##
https://www.cnblogs.com/cyh00001/p/16742399.html

 类似资料: