RustFS – 基于 Rust 构建的高性能分布式存储系统

1.背景

随着2025年底MinIO的闭源,众多基于此的业务系统一时间无法使用,众多企业与开发者不得不选型新型的软件产品。

在众多的产品中,找到一款MinIO的替代方案:RustFS

RustFS是使用目前全球最流行的、内存安全的Rust语言开发的 高性能 , 分布式对象存储软件。RustFS 同时具备简单、高效的特点,也是一种高效、开源、自由、可以进行本地私有云部署的对象存储解决方案。RustFS 100% 兼容 S3 协议,使用 Apache2 许可证发行的开源软件。RustFS 使用目前全世界最受欢迎的、内存安全的语言 Rust 语言编写。 它是由全世界优秀的工程师参与并贡献的一款对于商用友好的分布式对象存储产品,RustFS 可以平替非常多非友好开源协议的对象存储产品。

RustFS 即将从商业应用正式向开源,向全球进行发布,帮助全世界降低存储成本、提升数据安全。

RustFS 与 MinIO 都是S3 兼容的分布式对象存储,但在技术栈、架构、性能、许可、生态与适用场景上有本质区别。简单说:MinIO 成熟、生态强、通用;RustFS 更轻、更快、内存更省、许可更友好,适合性能与合规敏感场景

2.安装部署

2.1 二进制部署

RustFS官方提供了支持 Windows、Linux、macOS 和 Docker 部署方式

下载地址如下:

https://rustfs.com.cn/download/?platform=docker

详细的安装文档参考地址:

https://docs.rustfs.com.cn/installation/	

根据官方文档,需要依次检查如下要素,并按要求配置。

  1. 操作系统版本;
  2. 防火墙;
  3. 内存条件;
  4. 时间同步;
  5. 容量规划;
  6. 磁盘规划;
  7. 文件系统选择;

我这里采用单机版本,首先采用二进制部署:

以下示例是修改创建用户、组并设置权限以访问 RustFS 指定的数据目录(可选):

groupadd -r rustfs-user
useradd -M -r -g rustfs-user rustfs-user
chown rustfs-user:rustfs-user  /data/rustfs*
  • 如果创建了rustfs-user用户和组需要将 /etc/systemd/system/rustfs.service 中的User 和Group改为 rustfs-user ;
  • 将 /data/rustfs* 调整为指定的挂载目录。

下载软件包:

# 下载地址
wget https://dl.rustfs.com/artifacts/rustfs/release/rustfs-linux-x86_64-musl-latest.zip
unzip rustfs-linux-x86_64-musl-latest.zip
chmod +x rustfs
mv rustfs /usr/local/bin/

创建配置文件:

# 单机单盘模式
sudo tee /etc/default/rustfs <<EOF
RUSTFS_ACCESS_KEY=rustfsadmin
RUSTFS_SECRET_KEY=rustfsadmin
RUSTFS_VOLUMES="/data/rustfs0"
RUSTFS_ADDRESS=":9000"
RUSTFS_CONSOLE_ENABLE=true
RUST_LOG=error
RUSTFS_OBS_LOG_DIRECTORY="/var/logs/rustfs/"
EOF

创建配置目录:

sudo mkdir -p /data/rustfs0 /var/logs/rustfs /opt/tls
sudo chmod -R 750 /data/rustfs* /var/logs/rustfs

创建系统服务:

sudo tee /etc/systemd/system/rustfs.service <<EOF
[Unit]
Description=RustFS Object Storage Server
Documentation=https://rustfs.com/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

重载服务配置:

sudo systemctl daemon-reload

启动服务并设置开机自启:

sudo systemctl enable --now rustfs
systemctl status rustfs

查看日志:

tail -f /var/logs/rustfs/rustfs*.log

放行端口:

firewall-cmd --add-port=9000/tcp --permanent
firewall-cmd --add-port=9001/tcp --permanent
firewall-cmd --reload

使用9001端口进行web访问。

使用Nginx反向代理:

upstream rustfs {
   least_conn;
   server 127.0.0.1:9000;
}

upstream rustfs-console {
   least_conn;
   server 127.0.0.1:9001;
}


server {
   listen       80;
   listen  [::]:80;
   server_name  YOUR_DOMAIN;

   # Allow special characters in headers
   ignore_invalid_headers off;
   # Allow any size file to be uploaded.
   # Set to a value such as 1000m; to restrict file size to a specific value
   client_max_body_size 0;
   # Disable buffering
   proxy_buffering off;
   proxy_request_buffering off;

   location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      # Disable Nginx from converting HEAD to GET
      # proxy_cache_convert_head off;

      proxy_connect_timeout 300;
      # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      chunked_transfer_encoding off;

      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";




      proxy_pass http://rustfs; # This uses the upstream directive definition to load balance
   }
}


server {
   listen       8080;
   listen  [::]:8080;
   server_name  YOUR_DOMAIN;

   # Allow special characters in headers
   ignore_invalid_headers off;
   # Allow any size file to be uploaded.
   # Set to a value such as 1000m; to restrict file size to a specific value
   client_max_body_size 0;
   # Disable buffering
   proxy_buffering off;
   proxy_request_buffering off;

   location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;

      # Disable Nginx from converting HEAD to GET
      # proxy_cache_convert_head off;

      proxy_connect_timeout 300;
      # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      chunked_transfer_encoding off;

      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";




      proxy_pass http://rustfs-console; # This uses the upstream directive definition to load balance
   }
}

2.2 Docker 部署

version: "3.8"

services:
  rustfs:
    image: rustfs/rustfs:latest
    container_name: rustfs-server
    security_opt:
      - "no-new-privileges:true"
    ports:
      - "9000:9000"   # S3 API 对外端口
      - "9001:9001"   # 控制台对外端口
    environment:
      # 数据卷(多个路径用逗号分隔)
      - RUSTFS_VOLUMES=/data/rustfs0
      # API 和控制台监听地址
      - RUSTFS_ADDRESS=0.0.0.0:9000
      - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9001
      - RUSTFS_CONSOLE_ENABLE=true
      # CORS 设置,控制台与 S3 API 都放开来源
      - RUSTFS_CORS_ALLOWED_ORIGINS=*
      - RUSTFS_CONSOLE_CORS_ALLOWED_ORIGINS=*
      # 访问密钥(生产环境请修改为强密码)
      - RUSTFS_ACCESS_KEY=rustfsadmin
      - RUSTFS_SECRET_KEY=rustfsadmin
      # 日志级别
      - RUSTFS_OBS_LOGGER_LEVEL=info

    volumes:
      # 存储数据卷(请根据实际情况修改路径)
      - ./deploy/data/pro:/data
      # 日志目录
      - ./deploy/logs:/app/logs

    networks:
      - rustfs-network
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "sh", "-c", "curl -f http://localhost:9000/health && curl -f http://localhost:9001/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

networks:
  rustfs-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16

3.访问

使用http://ip:9001访问Rustfs,默认账号密码是rustfsadmin/rustfsadmin

声明:来自运维贼船,仅代表创作者观点。链接:https://eyangzhen.com/7634.html

运维贼船的头像运维贼船

相关推荐

添加微信
添加微信
Ai学习群
返回顶部