---
title: "VictoriaMetrics TimeSeries: Cài đặt chi tiết từ đầu và kiểm tra hoạt động thực tế"
description: "Hướng dẫn cài đặt VictoriaMetrics Single-node từ đầu trên Linux VPS, cấu hình scrape Prometheus target bằng vmagent và kiểm tra truy vấn MetricsQL thực tế."
canonical: "https://thuecloud.vn/victoriametrics-timeseries-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te"
markdown_url: "https://thuecloud.vn/victoriametrics-timeseries-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:37.900Z"
updated_at: "2026-11-22T16:18:36.558Z"
site: "ThueCloud.Vn"
estimated_tokens: 2079
---
# VictoriaMetrics TimeSeries: Cài đặt chi tiết từ đầu và kiểm tra hoạt động thực tế

> Hướng dẫn cài đặt VictoriaMetrics Single-node từ đầu trên Linux VPS, cấu hình scrape Prometheus target bằng vmagent và kiểm tra truy vấn MetricsQL thực tế.

- Canonical HTML: https://thuecloud.vn/victoriametrics-timeseries-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te
- Markdown URL: https://thuecloud.vn/victoriametrics-timeseries-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te.md
- Organization: ThueCloud.Vn
- Support Email: support@thuecloud.vn
- Hotline: 03333 499 48
- Published: 2026-11-22
- Updated: 2026-11-22

## Mục lục

- Cài đặt VictoriaMetrics Single-node bằng Systemd
- Cấu hình vmagent thu thập Metrics và kiểm tra thực tế
- Kiểm tra hoạt động thực tế qua API và VMUI
- Câu hỏi thường gặp (FAQ)
  - VictoriaMetrics Single-node có chịu được tải bao nhiêu active series trên VPS 4GB RAM?
  - Có cần cài đặt thêm vmalert riêng nếu muốn gửi cảnh báo Telegram/Slack không?
  - Làm sao sao lưu dữ liệu VictoriaMetrics mà không cần dừng dịch vụ?

Khi hệ thống giám sát Prometheus bắt đầu ngốn hàng chục GB RAM và phình to dung lượng ổ đĩa, chuyển sang VictoriaMetrics là giải pháp tối ưu hàng đầu trên [VPS Việt Nam](https://thuecloud.vn/vps-viet-nam). Với kiến trúc viết bằng Go và nén dữ liệu chuỗi thời gian vượt trội, bản Single-node của VictoriaMetrics có thể thay thế hoàn toàn Prometheus trên một VPS cấu hình khiêm tốn mà vẫn hỗ trợ 100% PromQL và Grafana.

> **Tóm tắt nhanh (TL;DR):**
> - Tải binary `victoria-metrics-prod` (hoặc chạy Docker) với dung lượng RAM chỉ từ 512MB-2GB cho hàng triệu active series.
> - Cấu hình `-retentionPeriod` và `-storageDataPath` để kiểm soát thời gian lưu trữ dữ liệu dài hạn.
> - Dùng `vmagent` (hoặc Prometheus `remote_write`) để thu thập metrics từ `node_exporter` và kiểm chứng qua `vmui`.
> *Cập nhật: 11/2026*

## 1. Cài đặt VictoriaMetrics Single-node bằng Systemd

Tạo user hệ thống riêng và tải bản phát hành ổn định mới nhất của VictoriaMetrics:

```bash
useradd --no-create-home --shell /bin/false victoriametrics
mkdir -p /var/lib/victoriametrics
chown -R victoriametrics:victoriametrics /var/lib/victoriametrics

wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.106.0/victoria-metrics-linux-amd64-v1.106.0.tar.gz
tar xzf victoria-metrics-linux-amd64-v1.106.0.tar.gz -C /usr/local/bin/
```

Tạo file dịch vụ `/etc/systemd/system/victoriametrics.service` với thời gian lưu trữ 90 ngày (`3` tháng):

```ini
[Unit]
Description=VictoriaMetrics Time Series Database
After=network.target

[Service]
Type=simple
User=victoriametrics
ExecStart=/usr/local/bin/victoria-metrics-prod \
  -storageDataPath=/var/lib/victoriametrics \
  -retentionPeriod=3 \
  -httpListenAddr=127.0.0.1:8428
Restart=on-failure
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target
```

Khởi chạy dịch vụ:
```bash
systemctl daemon-reload
systemctl enable --now victoriametrics
```

## 2. Cấu hình `vmagent` thu thập Metrics và kiểm tra thực tế

`vmagent` là trình thu thập nhẹ tương thích file cấu hình `prometheus.yml`. Tạo `/etc/vmagent/scrape.yml`:

```yaml
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['127.0.0.1:9100']
  - job_name: 'victoriametrics'
    static_configs:
      - targets: ['127.0.0.1:8428']
```

Chạy `vmagent` đẩy dữ liệu về VictoriaMetrics qua `remoteWrite`:

```bash
/usr/local/bin/vmagent-prod \
  -promscrape.config=/etc/vmagent/scrape.yml \
  -remoteWrite.url=http://127.0.0.1:8428/api/v1/write
```

## 3. Kiểm tra hoạt động thực tế qua API và VMUI

Sau khi chạy khoảng 1 phút, bạn có thể kiểm tra ngay dữ liệu đã vào database chưa bằng `curl` hoặc giao diện web tích hợp sẵn tại `http://127.0.0.1:8428/vmui`:

| Bước kiểm tra | Lệnh / Endpoint | Kết quả kỳ vọng | Ghi chú |
| --- | --- | --- | --- |
| Sức khỏe dịch vụ | `curl -s http://127.0.0.1:8428/health` | Trả về `OK` (HTTP 200) | Xác nhận tiến trình lắng nghe cổng 8428 |
| Truy vấn MetricsQL | `curl -s 'http://127.0.0.1:8428/api/v1/query?query=up'` | JSON `"status":"success"` với `value: "1"` | Chứng minh `vmagent` đã ghi dữ liệu |
| Tỷ lệ nén đĩa | `du -sh /var/lib/victoriametrics` | Chiếm dung lượng cực nhỏ (~0.4-0.8 byte/sample) | Nhỏ hơn Prometheus TSDB từ 3-7 lần |
| Kết nối Grafana | Thêm Data Source kiểu `Prometheus` | URL `http://127.0.0.1:8428` -> Save & Test OK | Tương thích hoàn toàn dashboard có sẵn |

Khi mở rộng hệ thống giám sát, bạn có thể kết hợp đọc thêm bài [SvelteKit Node Adapter phân tích lỗi](https://thuecloud.vn/sveltekit-node-adapter-phan-tich-loi-thuong-gap-va-quy-trinh-xu-ly-su-co-nhanh), hoặc tham khảo cách triển khai cụm AI tại [TensorRT-LLM Quantization cài đặt chi tiết](https://thuecloud.vn/tensorrt-llm-quantization-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te) và [TensorRT-LLM bảo mật và giám sát](https://thuecloud.vn/tensorrt-llm-quantization-tang-cuong-bao-mat-phan-quyen-va-thiet-lap-giam-sat-canh-bao). Xem thêm các mô hình kiến trúc tại [giải pháp ThueCloud](https://thuecloud.vn/giai-phap).

---
**Dựng hệ thống Monitoring tiết kiệm RAM trên VPS ThueCloud.Vn:**
Chỉ cần gói **VPS VN 1** (`45.000đ` - `60.000đ/tháng`) hoặc **VPS VN 2** (`78.000đ` - `90.000đ/tháng`) sử dụng KVM Enterprise NVMe tại `vn-hn`, bạn đã có thể vận hành trọn bộ VictoriaMetrics + vmagent + Grafana mượt mà. Cam kết SLA `99,9%`, VAT `0%`, hoàn tiền `07 ngày`. Xem chi tiết tại [bảng giá VPS](https://thuecloud.vn/pricing).

---

## Câu hỏi thường gặp (FAQ)

### VictoriaMetrics Single-node có chịu được tải bao nhiêu active series trên VPS 4GB RAM?
Với 4GB RAM và ổ cứng NVMe, VictoriaMetrics Single-node có thể xử lý mượt mà từ 500.000 đến hơn 1.000.000 active time series với tốc độ ghi hàng trăm nghìn mẫu mỗi giây.

### Có cần cài đặt thêm vmalert riêng nếu muốn gửi cảnh báo Telegram/Slack không?
Có. VictoriaMetrics Single-node tập trung vào lưu trữ và truy vấn; để đánh giá rule cảnh báo (`alerts.yml`) và đẩy sang Alertmanager, bạn chạy kèm binary `vmalert-prod` rất nhẹ.

### Làm sao sao lưu dữ liệu VictoriaMetrics mà không cần dừng dịch vụ?
Bạn sử dụng công cụ `vmbackup-prod` kết hợp endpoint `/snapshot/create` có sẵn của VictoriaMetrics để tạo ảnh chụp tức thời (zero-downtime snapshot) và đẩy thẳng lên S3/MinIO.

## References / Sources

- https://docs.victoriametrics.com/single-server-victoriametrics/
- https://docs.victoriametrics.com/vmagent/

---

## Navigation & Machine-Readable Endpoints

- [Site Summary (llms.txt)](https://thuecloud.vn/llms.txt)
- [Full Technical Reference (llms-full.txt)](https://thuecloud.vn/llms-full.txt)
- [Pricing Catalog (Markdown)](https://thuecloud.vn/pricing.md)
- [Blog & Technical Guides (Markdown)](https://thuecloud.vn/blog.md)
- [XML Sitemap](https://thuecloud.vn/sitemap.xml)
