演示地址:https://play.rustfs.com/browser
访问账号(默认 rustfsadmin)。
访问密钥(默认 rustfsadmin)。
下载mc
https://dl.min.io/client/mc/release
可以直接在 Linux 系统上安装 mc(,然后访问 Docker 容器内的 RustFS 服务。
下载并安装:
wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc
chmod +x /usr/local/bin/mc
- obs.toml 配置文件(对象存储配置)
通常用于配置 RustFS 的存储后端(如对接 S3、OSS 等)。示例内容
# /etc/default/obs.toml
[storage]
type = "s3" # 存储类型:s3/minio/oss
endpoint = "https://play.min.io" # 对象存储地址
access_key = "rustfsadmin" # 访问密钥(MinIO 默认账号)
secret_key = "rustfsadmin" # 私有密钥(MinIO 默认密码)
bucket = "rustfs-bucket" # 默认存储桶名称
region = "us-east-1" # 区域(AWS S3 必须指定)
[encryption]
enable = false # 是否启用服务端加密
key = "" # 加密密钥(可选)
- /opt/tls TLS 证书目录
作用:为 RustFS 启用 HTTPS 加密通信(如需暴露公网访问必选)。
文件结构:
/opt/tls/
├── cert.pem # 公钥证书(PEM 格式)
├── key.pem # 私钥文件(PEM 格式)
└── ca.pem # CA 根证书(可选,用于双向认证)
生成自签名证书示例:
mkdir -p /opt/tls
openssl req -x509 -newkey rsa:4096 -nodes \
-keyout /opt/tls/key.pem \
-out /opt/tls/cert.pem \
-days 365 \
-subj "/CN=rustfs.example.com" # 替换为你的域名或 IP
证书权限设置:
```bash
chmod 644 /opt/tls/*.pem # 确保容器可读取
x86镜像
docker pull registry.cn-hangzhou.aliyuncs.com/qiluo-images/rustfs:latest
arm架构镜像
docker pull registry.cn-hangzhou.aliyuncs.com/qiluo-images/linux_arm64_rustfs:latest
运行程序
docker run -d \
--name rustfs \
-p 7000:7000 -p 7001:7001 \
-v /data/rustfs/data:/data \
-v /etc/default/obs.toml:/etc/default/obs.toml:ro \
-v /opt/tls:/opt/tls:ro \
-e RUSTFS_OBS_CONFIG="/etc/default/obs.toml" \
-e RUSTFS_TLS_PATH="/opt/tls" \
-e RUSTFS_ROOT_USER="rustfsadmin" \
-e RUSTFS_ROOT_PASSWORD="rustfsadmin" \
registry.cn-hangzhou.aliyuncs.com/qiluo-images/rustfs:latest \
server /data \
--console-address ":7001" \
--address ":7000"
桶名public-example-dynamic
mc alias set rustfs http://localhost:7000 rustfsadmin rustfsadmin
mc mb rustfs/public-example-dynamic
mc ls rustfs
RustFS 凭借高性能、S3 兼容性和开源特性,成为云原生存储领域的优雅选择。通过简单的安装和灵活的配置方式,小白用户也能快速搭建分布式对象存储系统。无论是 AI 工作负载、大数据分析,还是边缘计算,RustFS 都能提供可靠支持。借助丰富的社区资源和文档,你可以进一步挖掘 RustFS 的潜力,打造高效、安全的现代化存储解决方案。
- 环境准备
确保你的系统满足以下要求:
操作系统:Linux、macOS 或 Windows(推荐 Linux 以获得最佳性能)。
硬件:至少 4GB 内存,建议 8GB 或更高;支持 ARM 或 x86_64 架构。
依赖工具:
Rust 编译器(建议最新稳定版本,安装参考 Rust 官网)。
Docker(可选,用于容器化部署)。
Git(用于克隆 RustFS 仓库)。
AWS CLI(可选,用于 S3 兼容性测试)。
此时此刻你的一款专属的RustFS 文件存储系统就完成啦。
Kubernetes 部署的 YAML 配置:
- 创建 PersistentVolume (PV)
定义存储卷,可以是 NFS、云存储(如 AWS EBS、Azure Disk、GCP PD)或本地存储(Local PV)。
这里以 本地存储(Local PV) 为例(适用于单节点测试,生产环境建议用网络存储):
apiVersion: v1
kind: PersistentVolume
metadata:
name: rustfs-data-pv
spec:
capacity:
storage: 10Gi # 根据需求调整大小
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain # 删除 Pod 时保留数据
storageClassName: local-storage
local:
path: /data/rustfs/data # 节点上的存储路径
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- your-node-name # 替换为你的节点名称
# - node1 # 替换为你的实际节点名称(节点名字)
- 创建 PersistentVolumeClaim (PVC)
Pod 通过 PVC 申请存储资源:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rustfs-data-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 5Gi # 申请 5GB 存储
- Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: rustfs-deployment
labels:
app: rustfs
spec:
replicas: 1
selector:
matchLabels:
app: rustfs
template:
metadata:
labels:
app: rustfs
spec:
nodeSelector:
kubernetes.io/hostname: k8s-normal-master
containers:
- name: rustfs
image: registry.cn-hangzhou.aliyuncs.com/qiluo-images/rustfs:latest
command: ["server", "/data"]
args: ["--console-address", ":7001", "--address", ":7000"]
ports:
- containerPort: 7000
name: main-port
- containerPort: 7001
name: console-port
volumeMounts:
- name: data-volume
mountPath: /data
- name: config-volume
mountPath: /etc/default/obs.toml
readOnly: true
- name: tls-volume
mountPath: /opt/tls
readOnly: true
env:
- name: RUSTFS_OBS_CONFIG
value: "/etc/default/obs.toml"
- name: RUSTFS_TLS_PATH
value: "/opt/tls"
- name: RUSTFS_ROOT_USER
value: "rustfsadmin"
- name: RUSTFS_ROOT_PASSWORD
value: "rustfsadmin"
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: rustfs-data-pvc
- name: config-volume
hostPath:
path: /etc/default/obs.toml
type: FileOrCreate
- name: tls-volume
hostPath:
path: /opt/tls
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
name: rustfs-service
spec:
selector:
app: rustfs
ports:
- name: main
protocol: TCP
port: 7000
targetPort: 7000
nodePort: 30090
- name: console
protocol: TCP
port: 7001
targetPort: 7001
nodePort: 30091
type: NodePort
访问方式:http://<任意节点IP>:30090
控制台(7001 端口):http://<任意节点IP>:30091
通过 ClusterIP 内部访问
即使 Service 是 NodePort 类型,Kubernetes 仍然会分配一个 ClusterIP,供集群内其他 Pod 访问:
主服务:http://rustfs-service:7000
控制台:http://rustfs-service:7001
- 通过 Ingress 访问(如果有 Ingress 控制器)
如果你配置了 Ingress,可以通过域名访问,例如:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rustfs-ingress
spec:
rules:
- host: rustfs.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: rustfs-service
port:
number: 7000
- host: rustfs-console.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: rustfs-service
port:
number: 7001
访问方式:
主服务:http://rustfs.example.com
控制台:http://rustfs-console.example.com
kubectl port-forward(调试用):
如果你想临时测试服务,可以用 kubectl port-forward:
kubectl port-forward svc/rustfs-service 7000:7000 7001:7001
然后访问:
主服务:http://localhost:7000
控制台:http://localhost:7001