跳到内容

可用性和可伸缩性说明

注意:本文档基于最新的 RustFS 版本。在执行扩容操作前,请务必进行全量数据备份。对于生产环境,建议联系 RustFS 技术支持工程师进行方案评审。

扩容方案概述

RustFS 通过添加新的存储池(Server Pool)支持横向扩容。每个新的存储池必须满足

  1. 存储池内的节点必须使用连续的主机名(例如:node5-node8)
  2. 单个存储池必须使用相同规格的磁盘(类型/容量/数量)
  3. 新的存储池必须与现有集群保持时间同步网络连通性

RustFS Architecture Diagram


1. 扩容前准备

1.1 硬件规划要求

项目最低要求推荐生产配置
节点数量4 节点/存储池4 - 8 节点/存储池
单节点内存128 GB128 GB
磁盘类型SSDNVMe SSD
单盘容量≥1 TB≥4 TB
网络带宽10 Gbps25 Gbps

1.2 系统环境检查

bash
# Check hostname continuity (new node example)
cat /etc/hosts
192.168.10.5 node5
192.168.10.6 node6
192.168.10.7 node7
192.168.10.8 node8

# Verify time synchronization status
timedatectl status | grep synchronized

# Check firewall rules (all nodes need to open ports 9000/9001)
firewall-cmd --list-ports | grep 9000
firewall-cmd --list-ports | grep 9001

2. 扩容实施步骤

2.1 新节点基础配置

bash
# Create dedicated user (execute on all new nodes)
groupadd rustfs-user
useradd -M -r -g rustfs-user rustfs-user

# Create storage directories (example with 8 disks)
mkdir -p /data/rustfs{0..7}
chown -R rustfs-user:rustfs-user /data/rustfs*

2.2 在所有新节点上安装 RustFS 二进制文件

bash
# Check rustfs version on existing node
/usr/local/bin/rustfs --version

# Download and install binary package (version must match existing cluster), e.g. for version 1.0.0-alpha.67:
wget https://github.com/rustfs/rustfs/releases/download/1.0.0-alpha.67/rustfs-linux-x86_64-musl-latest.zip
unzip rustfs-linux-x86_64-musl-latest.zip
chmod +x rustfs
mv rustfs /usr/local/bin/

2.3 在所有新节点上创建 RustFS 配置文件 (/etc/default/rustfs)

bash
# Create configuration file (/etc/default/rustfs)
# Please replace <Your RustFS admin username> and <Secure password of your RustFS admin> with yours values!
cat <<EOF > /etc/default/rustfs
RUSTFS_ACCESS_KEY=<Your RustFS admin username> # e.g. rustfsadmin
RUSTFS_SECRET_KEY=<Secure password of your RustFS admin> # e.g. rustfsadmin  
RUSTFS_VOLUMES="http://node-{1...4}:9000/data/rustfs{0...3} http://node-{5...8}:9000/data/rustfs{0...7}" # add new storage pool to the existing
RUSTFS_ADDRESS=":9000"
RUSTFS_CONSOLE_ADDRESS=":9001"
EOF

2.4 在所有新节点上配置系统服务

bash
# Create systemd service file

sudo tee /etc/systemd/system/rustfs.service <<EOF
[Unit]
Description=RustFS Object Storage Server
Documentation=https://rustfs.cn/docs/
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
NotifyAccess=main
User=root
Group=root

WorkingDirectory=/usr/local
EnvironmentFile=-/etc/default/rustfs
ExecStart=/usr/local/bin/rustfs \$RUSTFS_VOLUMES

LimitNOFILE=1048576
LimitNPROC=32768
TasksMax=infinity

Restart=always
RestartSec=10s

OOMScoreAdjust=-1000
SendSIGKILL=no

TimeoutStartSec=30s
TimeoutStopSec=30s

NoNewPrivileges=true
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictRealtime=true

# service log configuration
StandardOutput=append:/var/logs/rustfs/rustfs.log
StandardError=append:/var/logs/rustfs/rustfs-err.log

[Install]
WantedBy=multi-user.target
EOF

2.5 在所有新节点上重新加载服务配置

bash
#Reload service configuration
sudo systemctl daemon-reload

#Start service and set auto-start
sudo systemctl enable --now rustfs

2.6 在所有现有节点上执行集群扩容操作

bash
# Update configuration on all existing nodes (following command will add new storage pool to the existing $RUSTFS_VOLUMES list)
sed -i '/RUSTFS_VOLUMES/s|"$| http://node{5...8}:9000/data/rustfs{0...7}"|' /etc/default/rustfs

2.7 在所有节点(现有和新增)上执行集群扩容操作

bash
# Global service restart (execute simultaneously on all nodes)
systemctl restart rustfs.service

3. 扩容后验证

3.1 检查 RustFS Console 中的服务器列表

在 RustFS Console 性能菜单中打开,例如 http://node1:9001/rustfs/console/performance 并检查服务器列表中的节点加入状态

3.2 数据均衡验证

bash
# View data distribution ratio (should be close to each storage pool capacity ratio)
watch -n 5 "rustfs-admin metrics | grep 'PoolUsagePercent'"

4. 重要注意事项

  1. 禁止滚动重启:必须同时重启所有节点以避免数据不一致
  2. 容量规划建议:当存储使用率达到 70% 时,应规划下一次扩容
  3. 性能调优建议:
bash
# Adjust kernel parameters (all nodes)
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo "net.core.somaxconn=32768" >> /etc/sysctl.conf
sysctl -p

5. 故障排除指南

症状检查点修复命令
新节点无法加入集群检查端口 9000 连通性telnet node5 9000
数据分布不均检查存储池容量配置rustfs-admin rebalance start
Console 显示节点状态异常验证时间同步状态chronyc sources

根据 Apache 许可证 2.0 发布。