Phần 2 — SeaweedFS: Object storage gọn nhẹ cho Loki, Mimir, Tempo
Ý kiến
0
Chưa có ý kiến nào. Hãy là người đầu tiên chia sẻ!
Chưa có ý kiến nào. Hãy là người đầu tiên chia sẻ!
Tổng quan series: Grafana LGTM (Loki, Tempo, Mimir) + Alloy collector + SeaweedFS object storage + Pyroscope/Beyla. Kiến trúc, hardware, thứ tự deploy.
Backup checklist, self-monitoring alerts, capacity planning, lỗi kinh điển, security checklist, và khi nào nên scale từ monolithic sang microservice mode.
Hướng dẫn đầy đủ ssh port forwarding (-L local, -R remote, -D SOCKS) và autossh để giữ tunnel luôn sống — bao gồm các tham số quan trọng (ServerAliveInterval, ExitOnForwardFailure, GatewayPorts), biến môi trường autossh, và systemd service. Mọi lệnh đã test trong Docker.
Series Observability với Grafana Stack — 6 phần:
Phần 1 — Tổng quan: Observability với Grafana LGTM, Alloy và SeaweedFS
Phần 2 — SeaweedFS: Object storage gọn nhẹ cho Loki, Mimir, Tempo ← bạn đang đọc
Phần 3 — Grafana Alloy: Collector duy nhất cho metrics, logs, traces
Phần 5 — Grafana, Pyroscope, Beyla: UI, profiling và auto-instrumentation
Phần 6 — Production checklist: Backup, alerting, troubleshooting
Loki, Mimir, Tempo và Pyroscope đều cần một object storage backend. Bạn có 3 lựa chọn phổ biến:
| SeaweedFS | MinIO | Ceph | |
|---|---|---|---|
| S3 API | Có | Có | Có (RGW) |
| Độ phức tạp | Thấp | Thấp | Rất cao |
| RAM/node | ~512MB | ~1–2GB | ~4GB+ |
| Block storage (RBD) | Không | Không | Có |
| POSIX strict | Mount cơ bản | Không | CephFS |
| Phù hợp cho LGTM | Rất tốt | Tốt | Quá nặng |
Trong stack observability, bạn chỉ cần object storage. SeaweedFS là sweet spot: nhẹ như MinIO, scale tốt hơn, và không gánh nổi complexity Ceph.
SeaweedFS gồm 4 thành phần:
┌─────────────┐
│ Master │ ← metadata, volume mapping
└──────┬──────┘
│
┌─────────┴─────────┐
│ │
┌──▼──────┐ ┌────▼─────┐
│ Volume │ │ Volume │ ← chứa data thật
│ Server │ │ Server │
└─────────┘ └──────────┘
│
┌──────▼──────┐
│ Filer │ ← metadata layer (PG/MySQL/etcd)
└──────┬──────┘
│
┌──────▼──────┐
│ S3 Gateway │ ← API S3-compatible
└─────────────┘
Master — quản lý metadata volume mapping, tracking, replication. Không chứa data.
Volume — chứa data thật (file, object, chunk). Scale = thêm volume server.
Filer — metadata layer. Cho phép view filesystem, S3, POSIX mount.
S3 Gateway — expose API tương thích Amazon S3.
Tạo file seaweedfs-compose.yml:
services:
seaweed-master:
image: chrislusf/seaweedfs:3.67
command: master -ip=seaweed-master -ip.bind=0.0.0.0 -mdir=/data
ports: ["9333:9333"]
volumes: [seaweed_master_data:/data]
restart: unless-stopped
seaweed-volume:
image: chrislusf/seaweedfs:3.67
command: volume -ip=seaweed-volume -master=seaweed-master:9333 -dir=/data -max=0
ports: ["8080:8080"]
volumes: [seaweed_volume_data:/data]
depends_on: [seaweed-master]
restart: unless-stopped
seaweed-filer:
image: chrislusf/seaweedfs:3.67
command: filer -master=seaweed-master:9333 -defaultStoreDir=/data
ports: ["8888:8888"]
volumes: [seaweed_filer_data:/data]
depends_on: [seaweed-master, seaweed-volume]
restart: unless-stopped
seaweed-s3:
image: chrislusf/seaweedfs:3.67
command: s3 -filer=seaweed-filer:8888 -ip.bind=0.0.0.0
ports: ["8333:8333"]
depends_on: [seaweed-filer]
restart: unless-stopped
volumes:
seaweed_master_data:
seaweed_volume_data:
seaweed_filer_data:
Chạy:
docker compose -f seaweedfs-compose.yml up -d
Endpoint: http://localhost:8333. Khi chưa bật auth, truyền key gì cũng được:
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws s3 mb s3://loki --endpoint-url http://localhost:8333
echo "hello" > test.txt
AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \
aws s3 cp test.txt s3://loki/ --endpoint-url http://localhost:8333
AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \
aws s3 ls s3://loki --endpoint-url http://localhost:8333
Thấy test.txt là OK.
Tạo trước 4 bucket — Loki, Tempo, Mimir, Pyroscope mỗi service một bucket riêng:
for b in loki tempo mimir-blocks mimir-ruler mimir-alerts pyroscope; do
AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \
aws s3 mb s3://$b --endpoint-url http://localhost:8333
done
Tối thiểu 3 master để tránh single point of failure:
node1 → master + volume
node2 → master + volume
node3 → master + volume
node4 → filer + s3 (×2 cho HA)
Master config:
master \
-ip=node1 \
-peers=node1:9333,node2:9333,node3:9333
Volume config (chỉ tới cluster master):
volume \
-mserver=node1:9333,node2:9333,node3:9333
Replication strategy — flag -replication=001 = giữ 1 copy ở rack khác:
volume \
-dataCenter=DC1 \
-rack=R1 \
-replication=001
Mặc định Filer lưu metadata local — production không bao giờ làm thế. Hãy chuyển sang Postgres / MySQL / etcd. Ví dụ filer.toml:
[postgres]
enabled = true
hostname = "postgres"
port = 5432
username = "seaweedfs"
password = "***"
database = "seaweedfs"
sslmode = "disable"
≥ 3 master cho production. 1 master = SPOF.
Backup metadata Filer (không phải volume). Mất metadata = mất index = mất tất cả.
Disk layout: nhiều disk nhỏ (/data1, /data2...) tốt hơn 1 disk to.
Monitor /metrics — Prometheus scrape Master, Volume, Filer, S3.
Security: bật TLS + IAM, không expose S3 endpoint public.
Disk usage: SeaweedFS không tự clean — phải alert khi đầy.
Chỉ có 1 node → dùng MinIO single hoặc NFS.
Cần block storage (RBD) cho VM/database → Ceph.
Cần POSIX strict (lock, fsync mạnh) → GlusterFS.
← Phần 1: Tổng quan: Observability với Grafana LGTM, Alloy và SeaweedFS
Phần 3: Grafana Alloy: Collector duy nhất cho metrics, logs, traces →