麒麟V10部署 RustFS

温馨提醒

下载安装包

1
2
3
4
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/

创建配置文件

  • 单机单盘模式

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    # 单机单盘模式
    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
  • 单机多盘模式

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    # 单机多盘模式
    sudo tee /etc/default/rustfs <<EOF
    RUSTFS_ACCESS_KEY=rustfsadmin
    RUSTFS_SECRET_KEY=rustfsadmin
    RUSTFS_VOLUMES="/data/rustfs{0...3}"
    RUSTFS_ADDRESS=":9000"
    RUSTFS_CONSOLE_ENABLE=true
    RUST_LOG=error
    RUSTFS_OBS_LOG_DIRECTORY="/var/logs/rustfs/"
    EOF
  • 多机多盘模式

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    # 多机多盘模式
    sudo tee /etc/default/rustfs <<EOF
    RUSTFS_ACCESS_KEY=rustfsadmin
    RUSTFS_SECRET_KEY=rustfsadmin
    RUSTFS_VOLUMES="http://node{1...4}:9000/data/rustfs{0...3}"
    RUSTFS_ADDRESS=":9000"
    RUSTFS_CONSOLE_ENABLE=true
    RUST_LOG=error
    RUSTFS_OBS_LOG_DIRECTORY="/var/logs/rustfs/"
    EOF

创建存储目录并授权

  • 单机单盘模式

    1
    2
    
    mkdir -p /data/rustfs0 /var/logs/rustfs /opt/tls
    chmod -R 750 /data/rustfs* /var/logs/rustfs
  • 单机多盘模式

    1
    2
    
    sudo mkdir -p /data/rustfs{0..3} /var/logs/rustfs /opt/tls
    sudo chmod -R 750 /data/rustfs* /var/logs/rustfs
  • 多机多盘模式

    1
    2
    
    sudo mkdir -p /data/rustfs{0..3} /var/logs/rustfs /opt/tls
    sudo chmod -R 750 /data/rustfs* /var/logs/rustfs

    /data/rustfs0:核心数据存储目录,存放所有对象文件

    /var/logs/rustfs:日志存储目录,包含运行日志和错误日志

    /opt/tls:证书目录,用于后续配置 https 访问

配置系统服务

  • 创建 systemd 服务文件

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    
    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
  • 重新加载服务配置

    1
    
    systemctl daemon-reload

启动服务与验证

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

    1
    
    systemctl enable --now rustfs
  • 验证服务状态 检查服务端口

    1
    2
    3
    
    systemctl status rustfs
    
    netstat -ntlp

访问控制台

浏览器访问 http://IP:9001

用户名:rustfsadmin

密码:rustfsadmin