---
title: "Trên AlmaLinux 9: Hướng dẫn cài đặt Node Exporter và Promtail đẩy metric về Grafana"
description: "Hướng dẫn cài đặt Node Exporter và Promtail trên AlmaLinux 9 để thu thập chỉ số CPU, RAM, Disk IOPS và log hệ thống đẩy về Prometheus/Grafana Loki."
canonical: "https://thuecloud.vn/tren-almalinux-9-huong-dan-cai-dat-node-exporter-va-promtail-day-metric-ve-grafana"
markdown_url: "https://thuecloud.vn/tren-almalinux-9-huong-dan-cai-dat-node-exporter-va-promtail-day-metric-ve-grafana.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:28.945Z"
updated_at: "2026-11-22T16:18:25.613Z"
site: "ThueCloud.Vn"
estimated_tokens: 1758
---
# Trên AlmaLinux 9: Hướng dẫn cài đặt Node Exporter và Promtail đẩy metric về Grafana

> Hướng dẫn cài đặt Node Exporter và Promtail trên AlmaLinux 9 để thu thập chỉ số CPU, RAM, Disk IOPS và log hệ thống đẩy về Prometheus/Grafana Loki.

- Canonical HTML: https://thuecloud.vn/tren-almalinux-9-huong-dan-cai-dat-node-exporter-va-promtail-day-metric-ve-grafana
- Markdown URL: https://thuecloud.vn/tren-almalinux-9-huong-dan-cai-dat-node-exporter-va-promtail-day-metric-ve-grafana.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 Node Exporter trên AlmaLinux 9
- Cấu hình Promtail đẩy Log về Grafana Loki
- Bảng đối chiếu vai trò Node Exporter và Promtail
- Câu hỏi thường gặp (FAQ)
  - Có nên mở cổng 9100 của Node Exporter ra toàn Internet không?
  - Promtail không đọc được /var/log/messages trên AlmaLinux 9 là do đâu?
  - Node Exporter + Promtail tốn bao nhiêu tài nguyên trên mỗi VPS?

Khi vận hành nhiều máy chủ [VPS Việt Nam](https://thuecloud.vn/vps-viet-nam) cho hệ thống microservices hoặc web traffic cao, việc chỉ SSH vào gõ `htop` là không đủ để bắt được các điểm nghẽn xảy ra lúc nửa đêm. Trên **AlmaLinux 9**, bộ đôi **Node Exporter** (thu thập metric phần cứng) và **Promtail** (thu thập log đẩy về Grafana Loki) là giải pháp giám sát chuẩn mực, tiêu tốn cực ít tài nguyên.

> **Tóm tắt nhanh (TL;DR):**
> - Cài đặt `node_exporter` chạy dưới user hệ thống không quyền login, lắng nghe trên cổng `9100` (chỉ mở qua IP VPN nội bộ).
> - Cài đặt `promtail` đọc `/var/log/messages` hoặc `systemd-journal` đẩy thẳng về Grafana Loki trung tâm.
> - Chú ý cấu hình SELinux trên AlmaLinux 9 để Promtail đọc được log hệ thống mà không cần tắt SELinux.
> - *Cập nhật: 11/2026*

## Cài đặt Node Exporter trên AlmaLinux 9

Tạo user `node_exporter`, tải bản phát hành chính thức và chạy bằng `systemd` (xem thêm các [giải pháp giám sát](https://thuecloud.vn/giai-phap)):

```bash
sudo useradd --no-create-home --shell /sbin/nologin node_exporter
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
tar xvf node_exporter-1.8.2.linux-amd64.tar.gz
sudo cp node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
```

Tạo file `/etc/systemd/system/node_exporter.service` và mở cổng `9100` chỉ cho IP máy chủ Prometheus (ví dụ qua WireGuard `10.10.0.0/24`):

```bash
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.10.0.0/24" port protocol="tcp" port="9100" accept'
sudo firewall-cmd --reload
sudo systemctl enable --now node_exporter
```

## Cấu hình Promtail đẩy Log về Grafana Loki

Cấu hình `/etc/promtail/config.yml` để đẩy log dịch vụ Nginx và SSH về Loki server:

```yaml
server:
  http_listen_port: 9080
positions:
  filename: /tmp/positions.yaml
clients:
  - url: http://10.10.0.10:3100/loki/api/v1/push
scrape_configs:
  - job_name: system
    static_configs:
      - targets: [localhost]
        labels:
          job: varlogs
          host: almalinux-node-01
          __path__: /var/log/nginx/*.log
```

## Bảng đối chiếu vai trò Node Exporter và Promtail

| Công cụ | Loại dữ liệu thu thập | Giao thức / Cổng | Đích lưu trữ |
| :--- | :--- | :--- | :--- |
| **Node Exporter** | CPU, RAM, Disk IOPS, Network | HTTP Pull (`:9100/metrics`) | Prometheus / VictoriaMetrics |
| **Promtail** | System log, Nginx log, Journald | HTTP Push (`:3100/loki/api/v1/push`) | Grafana Loki |

Kết hợp dữ liệu từ Node Exporter sẽ giúp bạn tinh chỉnh chính xác hơn khi áp dụng [TCP BBRv3 Production](https://thuecloud.vn/tcp-bbrv3-congestion-control-tinh-chinh-tham-so-hieu-nang-va-gioi-han-tai-nguyen-production), [tối ưu Falco Kubernetes](https://thuecloud.vn/falco-kubernetes-runtime-tinh-chinh-tham-so-hieu-nang-va-gioi-han-tai-nguyen-production) hoặc [cài đặt MPTCP](https://thuecloud.vn/mptcp-multipath-tcp-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te). Tham khảo thêm [bảng giá VPS](https://thuecloud.vn/pricing) để chọn node lưu trữ Grafana/Prometheus riêng.

> **Dựng hệ thống Observability mượt mà tại ThueCloud.Vn:**
> Hạ tầng KVM Enterprise NVMe tại `vn-hn`, VAT `0%`, SLA `99,9%`, hoàn tiền `07 ngày`. Gói **VPS VN 1** (`45.000đ`–`60.000đ`/tháng) chạy nhẹ nhàng cho từng node con, còn **VPS VN 3** (`139.000đ`–`170.000đ`/tháng) lý tưởng làm máy chủ trung tâm Prometheus + Grafana Loki.

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

### Có nên mở cổng 9100 của Node Exporter ra toàn Internet không?
Không. Dù Node Exporter chỉ xuất metric phần cứng, việc mở công khai dễ lộ thông tin cấu hình và có thể bị quét. Hãy chỉ mở cổng `9100` trên dải IP mạng nội bộ hoặc WireGuard VPN.

### Promtail không đọc được `/var/log/messages` trên AlmaLinux 9 là do đâu?
Thường do user chạy Promtail không thuộc nhóm `adm` hoặc `systemd-journal`. Hãy thêm user `promtail` vào các nhóm này (`usermod -aG adm,systemd-journal promtail`) và kiểm tra quyền SELinux.

### Node Exporter + Promtail tốn bao nhiêu tài nguyên trên mỗi VPS?
Cả hai tiến trình chỉ tiêu thụ tổng cộng khoảng 40–70 MB RAM và dưới 1% CPU trên một VPS có tải thông thường.

## References / Sources

- https://prometheus.io/docs/guides/node-exporter/
- https://grafana.com/docs/loki/latest/send-data/promtail/

---

## 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)
