SeaweedFS – Object Storage
Ý 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ẻ!
1. SeaweedFS là gì — khi nào nên dùng
2. Kiến trúc và cách hoạt động
3. Khi nào nên chọn SeaweedFS thay vì MinIO / Ceph
4. Thiết kế production chuẩn
5. Hướng dẫn cài đặt production bằng Docker
6. Best practices thực tế
7. Những lỗi hay gặp khi triển khai thật
Nếu bạn đang xây dựng hệ thống cần shared storage, S3-compatible, hoặc distributed file storage, nhưng không muốn gánh complexity của Ceph, thì SeaweedFS là một lựa chọn cực kỳ đáng cân nhắc.
SeaweedFS là một distributed file system mã nguồn mở, hỗ trợ:
Object storage (S3 compatible)
Distributed filesystem
POSIX filesystem
Volume storage
Multi-datacenter replication
Nó được thiết kế với mục tiêu:
High performance + Simple architecture + Low operational cost
Khác với Ceph, SeaweedFS không cần cluster phức tạp để chạy hiệu quả.
SeaweedFS gồm 3 thành phần chính:
+-------------+
| Master |
+-------------+
|
-----------------------------
| |
+-----------+ +-----------+
| Volume | | Volume |
| Server | | Server |
+-----------+ +-----------+
|
+-----------+
| Filer |
+-----------+
|
+-----------+
| S3 API |
+-----------+
Quản lý metadata:
Volume mapping
Location tracking
Replication
Không chứa dữ liệu.
Chứa dữ liệu thật:
File
Object
Chunk
Scale bằng cách:
add more volume servers
Metadata layer.
Cho phép:
Filesystem view
S3 view
POSIX mount
Expose API:
Amazon S3 compatible
Có thể dùng với:
Loki
Prometheus
MinIO replacement
Backup tools
SeaweedFS rất hợp khi bạn:
Có nhiều node cần shared storage
Ví dụ:
Docker Swarm
Kubernetes
MicroServices cluster
Cần S3 nhưng không muốn MinIO cluster nặng
SeaweedFS:
nhẹ hơn
scale tốt
ít RAM hơn
Không muốn complexity của Ceph
Ceph:
Rất mạnh
Nhưng cực kỳ phức tạp
SeaweedFS:
Đủ mạnh
Dễ vận hành
img…
Một setup tối thiểu production-grade:
3 x Master
3 x Volume
2 x Filer
2 x S3 Gateway
Nếu nhỏ hơn:
1 x Master
2 x Volume
1 x Filer
1 x S3 Gateway
Vẫn chạy tốt.
Đây là cách được recommend. Không nên build từ source cho production trừ khi cần patch:
wget https://raw.githubusercontent.com/chrislusf/seaweedfs/master/docker/seaweedfs-compose.yml
docker-compose -f seaweedfs-compose.yml -p seaweedfs up
Hoặc bạn có thể sử dụng docker-compose.yml sau:
services:
seaweed-master:
image: chrislusf/seaweedfs:3.67
container_name: seaweed-master
command: >
master
-ip=seaweed-master
-ip.bind=0.0.0.0
-mdir=/data
-metricsPort=9324
ports:
- "9333:9333"
- "9324:9324"
volumes:
- seaweed_master_data:/data
restart: unless-stopped
seaweed-volume:
image: chrislusf/seaweedfs:3.67
container_name: seaweed-volume
command: >
volume
-ip=seaweed-volume
-master=seaweed-master:9333
-dir=/data
-max=0
-metricsPort=9325
ports:
- "8080:8080"
- "9325:9325"
volumes:
- seaweed_volume_data:/data
depends_on:
- seaweed-master
restart: unless-stopped
seaweed-filer:
image: chrislusf/seaweedfs:3.67
container_name: seaweed-filer
command: >
filer
-master=seaweed-master:9333
-defaultStoreDir=/data
-metricsPort=9326
ports:
- "8888:8888"
- "9326:9326"
volumes:
- seaweed_filer_data:/data
depends_on:
- seaweed-master
- seaweed-volume
restart: unless-stopped
seaweed-s3:
image: chrislusf/seaweedfs:3.67
container_name: seaweed-s3
command: >
s3
-filer=seaweed-filer:8888
-ip.bind=0.0.0.0
-metricsPort=9327
ports:
- "8333:8333"
- "9327:9327"
depends_on:
- seaweed-filer
restart: unless-stopped
volumes:
seaweed_master_data:
seaweed_volume_data:
seaweed_filer_data:
Test bằng awscli:
sudo snap install awscli
Create config:
aws configure
Nhập đại (dummy credential - nhập gì cũng được):
Access Key ID: test
Secret Access Key: test
Default region name: us-east-1
Default output format: json
Endpoint:
http://localhost:8333
Test:
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws s3 mb s3://loki \
--endpoint-url http://localhost:8333
Nếu thấy:
(empty)
→ OK.
Tạo bucket
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws s3 mb s3://loki \
--endpoint-url http://localhost:8333
Kết quả mong đợi:
make_bucket: loki
Upload file test
echo "hello seaweedfs" > test.txt
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws s3 cp test.txt s3://loki/ \
--endpoint-url http://localhost:8333
List lại
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws s3 ls s3://loki \
--endpoint-url http://localhost:8333
Nếu thấy:
test.txt
→ hệ thống OK.
Ví dụ:
node1 → master + volume
node2 → master + volume
node3 → master + volume
Master config:
master \
-ip=node1 \
-peers=node1:9333,node2:9333,node3:9333
Volume config:
volume \
-mserver=node1:9333,node2:9333,node3:9333
Ví dụ:
-rack=R1
-dataCenter=DC1
Replication:
- replication=001
Meaning:
1 copy in another rack
Đây là phần quan trọng nhất.
10.1 Không dùng local metadata
Filer nên dùng:
MySQL
PostgreSQL
etcd
Ví dụ:
- filer.store=postgres
10.2 Volume disk layout
Không nên:
1 disk rất lớn
Nên:
nhiều disk nhỏ
Ví dụ:
/data1
/data2
/data3
10.3 Backup metadata
Quan trọng:
Backup filer metadata
Không phải volume.
10.4 Monitoring
Phải có:
Prometheus
Grafana
SeaweedFS expose metrics:
/metrics
10.5 Security
Enable:
TLS
IAM
Không nên expose S3 public.
Một số flag quan trọng:
-volume.fileSizeLimitMB=30000
-volume.index=leveldb
Nếu file nhỏ:
-volume.smallFileLimitMB=1
Ví dụ:
Loki → object storage
Tempo → trace storage
Mimir → metrics storage
SeaweedFS thay:
MinIO
S3
Hoạt động rất ổn.
Đây là kinh nghiệm thực tế.
Chạy chỉ 1 master
→ Single point of failure.
Luôn:
>= 3 master
Không backup metadata
→ mất toàn bộ index (rất nguy hiểm).
Disk đầy
SeaweedFS không auto clean.
Phải:
monitor disk usage
Không cấu hình replication
→ mất dữ liệu khi node chết.
Không phải lúc nào cũng phù hợp.
Chỉ có 1 node
→ dùng:
local disk
NFS
MinIO single node
Cần block storage (RBD)
→ dùng: Ceph
Cần filesystem POSIX strict
→ dùng: GlusterFS
Rất phổ biến:
Swarm cluster
node1:
seaweed master
seaweed volume
node2:
seaweed master
seaweed volume
node3:
seaweed master
seaweed volume
node4:
filer + s3
Các service khác:
Loki
Tempo
Mimir
Alloy
Sử dụng:
S3 endpoint