惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
Security @ Cisco Blogs
S
Secure Thoughts
Attack and Defense Labs
Attack and Defense Labs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hacker News: Front Page
博客园 - 叶小钗
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
Forbes - Security
Forbes - Security
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
爱范儿
爱范儿
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
TaoSecurity Blog
TaoSecurity Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Schneier on Security
Schneier on Security
C
Cisco Blogs
美团技术团队
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
月光博客
月光博客
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
Arctic Wolf
B
Blog RSS Feed
Cisco Talos Blog
Cisco Talos Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
V2EX - 技术
V2EX - 技术
Y
Y Combinator Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
G
GRAHAM CLULEY
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The Hacker News
The Hacker News

博客园 - 尹正杰

k8s集群为每个节点分配不通的ippool实战 ansible剧本实现一键升级K8S集群的NVIDIA GPU驱动 vmagent采集etcd数据并写入victoriametrics集群 Squid正向代理实战 kubespray生产故障案例之kubelet启动参数案例 filebeat指定名称空间采集pod数据 Calico自定义Ipool实战 ansible剧本实现kibana的部署和卸载 ansible剧本应用案例集合2 ansible剧本实现磁盘格式化 Ansible急速入门实战篇 ansible快速入门篇 k8s集群管理 kubesray实战 kubespray实战案例 kubespray管理k8s的worker集群扩缩容 kubespray快速部署k8s集群实战 Kubeasz使用吐槽博客专题 Kubeasz基于ezctl实现etcd集群的管理实战 Kubeasz基于ezctl实现k8s集群一键升级 Calico启用纯BGP模式+RR实战案例 Calico 底层原理及IPIP(依赖BGP协议))和vxlan(不依赖BGP)工作模式切换 kubeasz基于ezctl实现k8s集群的扩容和缩容 kubeasz快速部署K8S集群实战 Ubuntu 24.04.04 LTS版本系统优化 Ubuntu Server 24.04.04 LTS部署指南 windows极速部署Openclaw实战篇 K8S的StatefulSet控制器应用案例之MySQL主从同步实战 k8s底层基于不同运行时集成harbor企业级私有仓库实战 二进制K8S集群附加组件部署及CNI网络插件切换实战 二进制部署K8S 1.35.0+最新版实战案例 etcd高可用集群部署及K8S周期性备份数据实战 基于Docker实现《若依》服务业务容器化实战篇 k8s集群基于Flannel网络插件部署凡人修仙传 k8s集群基于Calico网络插件部署凡人修仙传 ElasticSEearch 9.X环境部署 K8S Vertical Pod Autoscaler(VPA)实战案例 Prometheus监控自定义程序指标
VictoriaMetrics集群部署实战
尹正杰 · 2026-06-30 · via 博客园 - 尹正杰

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.VictoriaMetrics概述

1.VictoriaMetrics概述

VictoriaMetrics是一款快速、经济高效且可扩展的监控与管理时序数据的解决方案。它提供高性能与高可靠性,是各类规模企业的理想选择。


我们在生产环境中已经直接用VictoriaMetrics取代了Prometheus的地位,直接是去Prometheus化,直接使用高性能的VictoriaMetrics集群。

GitHub地址:
  https://github.com/VictoriaMetrics/VictoriaMetrics

2.软件包选择

image

文件名后缀 包类型 适用场景 内部二进制
-cluster.tar.gz 开源集群版 你要部署的 VM 集群(vmstorage-prod/vminsert-prod/vmselect-prod) 集群三组件,免费开源无功能限制
-enterprise-cluster.tar.gz 企业集群版 付费商业版,支持集群 + 企业特性(告警分组、权限、审计等) 集群三组件 + 企业增强模块,需授权
.tar.gz(无 cluster) 单机版 单节点 VM,仅victoria-metrics-prod,不支持分布式集群 仅单机存储查询一体程序,不能搭集群
_checksums.txt 校验文件 sha256 校验,下载后核对完整性,防止文件损坏 / 篡改 无二进制,仅校验值
如上图所示,如果要部署集群版本的话,建议选择"victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz"(27.4MB 开源免费集群包)

不要用单机版v1.146.0.tar.gz,该包无法分布式分片存储。

二.VictoriaMetrics环境部署

1.下载二进制的软件包

  1.下载软件包
[root@master231 ~]# wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.146.0/victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz


  2.下载校验文件
[root@master231 ~]# wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.146.0/victoria-metrics-linux-amd64-v1.146.0-cluster_checksums.txt


  3.创建工作目录
[root@master231 ~]# mkdir -pv /yinzhengjie/softwares/victoria-metrics

  4.解压软件包
[root@master231 ~]# tar xf victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz -C /yinzhengjie/softwares/victoria-metrics
[root@master231 ~]# 


  5.校验文件是否完整
[root@master231 ~]# cd /yinzhengjie/softwares/victoria-metrics/
[root@master231 victoria-metrics]# 
[root@master231 victoria-metrics]# ll
total 83352
drwxr-xr-x 2 root        root            4096 Jun 30 02:20 ./
drwxr-xr-x 4 root        root            4096 Jun 30 02:18 ../
-rw-r--r-- 1 root        root             360 Jun 30 02:16 victoria-metrics-linux-amd64-v1.146.0-cluster_checksums.txt
-rw-r--r-- 1 root        root        28727105 Jun 30 02:16 victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17738024 Jun 19 20:42 vminsert-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 21165432 Jun 19 20:42 vmselect-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17701240 Jun 19 20:42 vmstorage-prod*
[root@master231 victoria-metrics]# 
[root@master231 victoria-metrics]# sha256sum -c victoria-metrics-linux-amd64-v1.146.0-cluster_checksums.txt victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz
victoria-metrics-linux-amd64-v1.146.0-cluster.tar.gz: OK
vminsert-prod: OK
vmselect-prod: OK
vmstorage-prod: OK
[root@master231 victoria-metrics]# 


2.将vm程序添加到系统path环境变量

  1.将软件包移动到Path变量
[root@master231 victoria-metrics]# ll vm*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17738024 Jun 19 20:42 vminsert-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 21165432 Jun 19 20:42 vmselect-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17701240 Jun 19 20:42 vmstorage-prod*
[root@master231 victoria-metrics]# 
[root@master231 victoria-metrics]# 
[root@master231 victoria-metrics]# mv vm* /usr/local/bin/
[root@master231 victoria-metrics]# 
[root@master231 victoria-metrics]# ll /usr/local/bin/vm*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17738024 Jun 19 20:42 /usr/local/bin/vminsert-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 21165432 Jun 19 20:42 /usr/local/bin/vmselect-prod*
-rwxr-xr-x 1 yinzhengjie yinzhengjie 17701240 Jun 19 20:42 /usr/local/bin/vmstorage-prod*
[root@master231 victoria-metrics]# 


  2.将程序同步到其他2个节点
[root@master231 ~]# scp -p /usr/local/bin/vm* 10.0.0.232:/usr/local/bin/
[root@master231 ~]# scp -p /usr/local/bin/vm* 10.0.0.233:/usr/local/bin/

3.创建专用运行用户并配置授权目录

  1.创建专用运行用户
[root@master231 ~]# useradd -m -s /sbin/nologin victoriametrics
[root@master231 ~]# 


  2.数据目录(vmstorage专用,SSD磁盘)
[root@master231 ~]# mkdir -p /yinzhengjie/data/vmstorage
[root@master231 ~]# 
[root@master231 ~]# chown -R victoriametrics:victoriametrics /yinzhengjie/data/vmstorage
[root@master231 ~]# 
[root@master231 ~]# ll /yinzhengjie/data/vmstorage -d
drwxr-xr-x 2 victoriametrics victoriametrics 4096 Jun 30 02:30 /yinzhengjie/data/vmstorage/
[root@master231 ~]# 
 
温馨提示:
  其他两个节点都需要做此操作。

4.部署 vmstorage

  1. 创建 systemd 服务文件 /etc/systemd/system/vmstorage.service
cat > /etc/systemd/system/vmstorage.service<<'EOF'
[Unit]
Description=Jason Yin's VictoriaMetrics Storage Cluster
After=network.target

[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
Restart=always
RestartSec=5
# 时区、数据路径、保留周期90天、全端口绑定
ExecStart=/usr/local/bin/vmstorage-prod \
  -loggerTimezone=Asia/Shanghai \
  -storageDataPath=/yinzhengjie/data/vmstorage \
  -retentionPeriod=90d \
  -httpListenAddr=0.0.0.0:8482 \
  -vminsertAddr=0.0.0.0:8400 \
  -vmselectAddr=0.0.0.0:8401 \
  -memory.allowedPercent=60
  
[Install]
WantedBy=multi-user.target
EOF

 
  2.启动服务
systemctl daemon-reload
systemctl enable --now vmstorage
systemctl status vmstorage


  3.测试校验
[root@master231 ~]# curl http://127.0.0.1:8482/-/healthy
VictoriaMetrics is Healthy.
[root@master231 ~]# 
 
[root@master232 ~]# curl http://127.0.0.1:8482/-/healthy
VictoriaMetrics is Healthy.
[root@master232 ~]# 
 
[root@master233 ~]# curl http://127.0.0.1:8482/-/healthy
VictoriaMetrics is Healthy.
[root@master233 ~]# 
 

5.部署 vminsert

  1.准备启动脚本
cat > /etc/systemd/system/vminsert.service <<'EOF'
[Unit]
Description=Jason Yin's VictoriaMetrics Insert Cluster
After=network.target vmstorage.service

[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/vminsert-prod \
  -loggerTimezone=Asia/Shanghai \
  -httpListenAddr=0.0.0.0:8480 \
  # 所有vmstorage节点写入端口列表
  -storageNode=10.0.0.231:8400,10.0.0.232:8400,10.0.0.233:8400 \
  # 副本因子2:每条数据存2个storage,单节点故障不丢数据
  -replicationFactor=2 \
  # 并发写入调优
  -maxConcurrentInserts=20000

[Install]
WantedBy=multi-user.target
EOF


  2.配置开机自启动
systemctl daemon-reload 
systemctl enable --now vminsert
systemctl status vminsert


  3.测试验证
[root@master231 ~]# curl http://127.0.0.1:8480/-/healthy
VictoriaMetrics is Healthy.
[root@master231 ~]# 

[root@master232 ~]# curl http://127.0.0.1:8480/-/healthy
VictoriaMetrics is Healthy.
[root@master232 ~]# 

[root@master233 ~]# curl http://127.0.0.1:8480/-/healthy
VictoriaMetrics is Healthy.
[root@master233 ~]# 

6.部署 vmselect

  1.编写启动脚本
cat > /etc/systemd/system/vmselect.service <<'EOF'
[Unit]
Description=Jason Yin's VictoriaMetrics Select Cluster
After=network.target vmstorage.service

[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/vmselect-prod \
  -loggerTimezone=Asia/Shanghai \
  -httpListenAddr=0.0.0.0:8481 \
  # 所有storage查询端口
  -storageNode=10.0.0.231:8401,10.0.0.232:8401,10.0.0.233:8401 \
  # 和vminsert统一,自动合并副本重复数据
  -dedup.minScrapeInterval=15s \
  # 查询并发限制
  -search.maxConcurrentRequests=1000 \
  -search.maxQueryDuration=30s
  
[Install]
WantedBy=multi-user.target
EOF


  2.配置开机自启动
systemctl daemon-reload 
systemctl enable --now vmselect
systemctl status vmselect


  3.测试验证
[root@master231 ~]# curl http://127.0.0.1:8481/-/healthy
VictoriaMetrics is Healthy.
[root@master231 ~]# 


[root@master232 ~]# curl http://127.0.0.1:8481/-/healthy
VictoriaMetrics is Healthy.
[root@master232 ~]# 

[root@master233 ~]# curl http://127.0.0.1:8481/-/healthy
VictoriaMetrics is Healthy.
[root@master233 ~]# 


三.前端负载均衡配置VictoriaMetrics读写分离

1.nginx配置

  1.安装nginx程序
[root@ansible99 ~]# apt -y install nginx


  2.修改配置文件
[root@ansible99 ~]# cat  /etc/nginx/conf.d/vm-cluster.conf
# 写入入口:vminsert 8480
upstream vm_insert {
    server 10.0.0.231:8480;
    server 10.0.0.232:8480;
    server 10.0.0.233:8480;
}

# 查询入口:vmselect 8481
upstream vm_select {
    server 10.0.0.231:8481;
    server 10.0.0.232:8481;
    server 10.0.0.233:8481;
}

server {
    listen 8480;
    location / {
        proxy_pass http://vm_insert;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
server {
    listen 8481;
    location / {
        proxy_pass http://vm_select;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
[root@ansible99 ~]# 

  3.检查nginx的配置文件
[root@ansible99 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@ansible99 ~]# 


  4.热加载配置
[root@ansible99 ~]# nginx -s reload
2026/06/30 03:40:27 [notice] 8338#8338: signal process started
[root@ansible99 ~]# 
[root@ansible99 ~]# 


  5.检查端口是否监听
[root@ansible99 ~]# ss -ntl | egrep "8480|8481"
LISTEN 0      511          0.0.0.0:8481      0.0.0.0:*          
LISTEN 0      511          0.0.0.0:8480      0.0.0.0:*          
[root@ansible99 ~]# 

2.数据写入 & 查询测试

  1.向负载均衡写入接口推送指标
[root@ansible99 ~]# curl -X POST http://10.0.0.99:8480/insert/0/prometheus/api/v1/import/prometheus \
-H "Content-Type: text/plain" \
-d 'test_metric{node="vm-cluster"} 1668888888 123.45'



  2.