使用Linux操作系统安装RustFS的快速指导
本页面包含了RustFS的三种安装模式的全部文档和说明。其中,多机多盘的模式包含了企业级可用的性能、安全性和扩展性。并且,提供了生产工作负载需要的架构图。 请装前请阅读,我们的启动模式与检查清单,如下:
启动模式, 前明确您的Linux启动模式;
检查清单, 检查各项指标是否符合生产指导特征,若不需要生产标准可不阅读此指导;
操作系统版本;
防火墙;
主机名;
内存条件;
时间同步;
容量规划;
磁盘规划;
容量规划;
数据分层规划。
我们推荐Linux内核为4.x 及以上的版本,但是5.x 及以上的版本可以获得更好的IO吞吐和网络性能。
您可以使用Ubuntu 20.04 和RHEL88.x 来安装RustFS。
Linux系统默认开启防火墙,您可以使用以下命令查看防火墙状态:
systemctl status firewalld
如果您的防火墙状态为“active”,您可以使用以下命令禁用防火墙:
systemctl stop firewalld
systemctl disable firewalld
或者放行RustFS的9000端口:
firewall-cmd --zone=public --add-port=9000/tcp --permanent
firewall-cmd --reload
部署中的所有RustFS服务器 必须 使用相同的监听端口。如果您使用的是9000端口,其他服务器的所有端口均需要为9000端口。
创建RustFS集群必须要使用 相同的、具备连续性 的主机名。有两种方式实现连续性的主机名:
DNS配置;
HOSTS配置。
vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.1 node1
192.168.1.2 node2
192.168.1.3 node3
192.168.1.4 node4
RustFS需要至少2GB的内存来运行测试环境,生产的环境最低需要64GB的内存。
多节点的一致性必须要使用时间服务器维护时间的一致性,不然可能会出现无法启动服务的情况。相关时间服务器例如使用 ntp
, timedatectl
, 或者 timesyncd
。
RustFS需要时间同步,您可以使用以下命令检查时间同步状态:
timedatectl status
如果状态为“synchronized”,则表示时间同步正常。
RustFS启动,我们建议您配置一个专门的无登录权限的用户进行启动RustFS的服务。在rustfs.service启动控制脚本中,默认的用户和用户组是 rustfs-user
和 rustfs-user
。
您可以使用 groupadd 和 useradd 命令创建用户和组. 以下示例创建用户、组并设置权限以访问RustFS指定的数据目录。
请先安装wge或者curl 下载rustfs安装包。
# 下载地址
wget https://dl.rustfs.com/rustfs/rustfs
chmod +x rustfs
mv rustfs /usr/local/bin/
sudo tee /etc/default/rustfs <<EOF
RUSTFS_ROOT_USER=rustfsadmin
RUSTFS_ROOT_PASSWORD=rustfsadmin
RUSTFS_VOLUMES="/data/rustfs{0...3}"
RUSTFS_ADDRESS=":7000"
#RUSTFS_SERVER_DOMAINS="play.rustfs.com:7000"
RUSTFS_CONSOLE_ENABLE=true
RUSTFS_CONSOLE_ADDRESS=":7001"
RUSTFS_OBS_CONFIG="/etc/default/obs.toml"
RUSTFS_TLS_PATH="/opt/tls"
EOF
sudo mkdir -p /data/rustfs{0..3} /var/logs/rustfs /opt/tls
sudo chmod -R 750 /data/rustfs* /var/logs/rustfs
sudo tee /etc/default/obs.toml <<EOF
[observability]
endpoint = "http://localhost:4317"
use_stdout = false
sample_ratio = 2.0
meter_interval = 30
service_name = "rustfs"
service_version = "0.1.0"
environments = "production"
logger_level = "debug"
local_logging_enabled = true
[sinks]
[sinks.kafka]
enabled = false
bootstrap_servers = "localhost:9092"
topic = "logs"
batch_size = 100
batch_timeout_ms = 1000
[sinks.webhook]
enabled = false
endpoint = "http://localhost:8080/webhook"
auth_token = ""
batch_size = 100
batch_timeout_ms = 1000
[sinks.file]
enabled = true
path = "/var/logs/rustfs/app.log"
batch_size = 10
batch_timeout_ms = 1000
[logger]
queue_capacity = 10
EOF
sudo tee /etc/logrotate.d/rustfs <<EOF
/var/logs/rustfs/*.log {
daily
rotate 7
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
systemctl restart rustfs >/dev/null 2>&1 || true
endscript
}
EOF
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 \$RUSTFS_OPTS
LimitNOFILE=1048576
LimitNPROC=32768
TasksMax=infinity
Restart=always
RestartSec=10s
OOMScoreAdjust=-1000
SendSIGKILL=no
TimeoutStartSec=30s
TimeoutStopSec=30s
NoNewPrivileges=true
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictRealtime=true
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now rustfs
systemctl status rustfs
ss -tunlp | grep -E '7000|7001'
curl -u rustfsadmin:rustfsadmin http://localhost:7001/metrics
tail -f /var/logs/rustfs/app.log
curl -X PUT -u rustfsadmin:rustfsadmin \
-H "Content-Type: application/octet-stream" \
--data-binary @testfile \
http://localhost:7000/bucket1/object1