RustFS 安装和维护

本文重在 RustFS 的部署流程,介绍和具体使用方法请到:自建 对象存储 – 构建高效可靠的数据存储系统 – 技焉洲

指标 描述
适用系统 Debian 系发行版,包括 Ubuntu, Armbian,其他发行版稍改命令一般也可
走通流程时间 10 分钟

I might have made some mistakes, please let me know if I’ve gotten anything wrong!


默认的端口为 9000 和 9001,记得开放端口

  • 9000 为 API 端口,用于让程序上传下载,以及充当图床时用的也是它
  • 9001 是 Web 后台 的端口。访问 ip:9001 即可到 Web 管理后台

手动安装 MinIO

文档:RustFS Single Node Single Disk Installation | RustFS Documentation

创建目录和用户

创建数据保存的目录

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

创建 rustfs-user 用户

sudo groupadd -r rustfs-user
sudo useradd -M -r -g rustfs-user rustfs-user
sudo chown rustfs-user:rustfs-user  /data/rustfs0

下载程序文件

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
sudo mv rustfs /usr/local/bin/
rm rustfs-linux-x86_64-musl-latest.zip

试运行一下

sudo -u rustfs-user rustfs /data/rustfs0 --address ":9000" --console-enable --console-address ":9001" --access-key "vfly2" --secret-key "pass_vfly2_word"

配置文件

编辑配置文件。

sudo vim /etc/default/rustfs

注意修改用户名和密码

# 保存数据的目录
RUSTFS_VOLUMES="/data/rustfs0"
# Root 用户的名称
RUSTFS_ACCESS_KEY=vfly2
# Root 用户的密码
RUSTFS_SECRET_KEY=pass_vfly2_word
RUSTFS_ADDRESS=":9000"
RUSTFS_CONSOLE_ENABLE=true
RUST_LOG=error
RUSTFS_OBS_LOG_DIRECTORY="/var/logs/rustfs/"

systemd

sudo vim /usr/lib/systemd/system/rustfs.service
[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=rustfs-user
Group=rustfs-user

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
sudo systemctl daemon-reload

迁移的话,在这里复制目录到 /data/rustfs,再启动就可以了

启动并设置开机自启

sudo systemctl enable --now rustfs.service

方便读者使用

sudo systemctl status rustfs.service
sudo systemctl start rustfs.service
sudo systemctl stop rustfs.service
sudo systemctl disable rustfs.service
journalctl -u rustfs.service --since "5 minutes ago"

反代

下面是对管理后台的反代,对于想作为图床的反代,可以查看 Nginx 反代和重定向的简洁教程 – 技焉洲 里的”HTTP 反代缓存“。


获取证书:使用 acme.sh 申请和自动更新证书的完整指南 – 技焉洲 [[02acme.sh]]

注意修改下面的域名

acme.sh --issue -d rustfs.cufah.cloud --webroot /var/www/html
acme.sh --install-cert -d rustfs.cufah.cloud \
--key-file       /etc/ssl/private/rustfs.cufah.cloud.key \
--fullchain-file /etc/ssl/certs/rustfs.cufah.cloud.cer \
--reloadcmd "systemctl reload nginx"

sudo vim /etc/nginx/sites-available/rustfs
server {
    listen 80;
    server_name rustfs.cufah.cloud;

    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }

    location / {
        return 301 https://$server_name$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name rustfs.cufah.cloud;

    ssl_certificate /etc/ssl/certs/rustfs.cufah.cloud.cer;
    ssl_certificate_key /etc/ssl/private/rustfs.cufah.cloud.key;

    # Allow special characters in headers
    ignore_invalid_headers off;
    # Allow any size file to be uploaded.
    client_max_body_size 1000m;
    # Disable buffering
    proxy_buffering off;
    proxy_request_buffering off;

    location /.well-known/acme-challenge/ {
      root /var/www/html;
    }

    location / {
        proxy_pass http://localhost:9001;

        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;

        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";
    }
}
sudo ln -s /etc/nginx/sites-available/rustfs /etc/nginx/sites-enabled/rustfs

检查配置并重启生效

sudo nginx -t && sudo systemctl reload nginx

更新

关闭,更改二进制文件,重启

备份

只要保存 /data/rustfs 目录就行,所有数据都在里面

迁移

  1. 先把旧机器上的升到最新版,确保两者版本一致
  2. 然后,停止旧机器上的运行
  3. 直接复制数据目录到新机器上,就行了
sudo rsync -avuzP -e "ssh -p 22" -r vfly2@1.2.3.4:/data/rustfs /mnt/

原文链接: https://yanh.tech/2026/05/rustfs-server-installation-and-maintenance/

版权声明:本博客所有文章除特別声明外,均为 AhFei 原创,采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 技焉洲 (yanh.tech)

保持更新 ٩(•̤̀ᵕ•̤́๑)ᵒᵏᵎᵎᵎᵎ 清晰恒益的实用技能,欢迎使用 RSS 订阅,如果能留言互动就更好了。

可在 Telegram 群组 https://t.me/vfly2 交流依文章步骤遇到的问题。

评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇