要优化Linux上MinIO的安装性能,可以参考以下步骤:
内核参数是影响系统性能的重要因素。可以通过修改 /etc/sysctl.conf
文件进行配置。以下是一些常用的内核参数及其设置:
vm.swappiness = 10 # 将交换空间使用率设置为较低的值
vm.dirty_ratio = 20 # 将脏数据的比例设置为较低的值
vm.dirty_background_ratio = 5 # 将后台写入脏数据的比例设置为较低的值
net.ipv4.tcp_fin_timeout = 30 # 将TCP连接的TIME_WAIT状态的超时时间设置为较短的值
创建 minio
系统用户:
sudo useradd -r -s /sbin/nologin minio-user
创建数据存储目录(替换为你的磁盘路径):
sudo mkdir -p /mnt/data
sudo chown -R minio-user:minio-user /mnt/data
创建配置文件 /etc/default/minio
:
sudo tee /etc/default/minio <<EOF
MINIO_ROOT_USER="admin" # 管理账号
MINIO_ROOT_PASSWORD="your_strong_password" # 管理密码
MINIO_VOLUMES="/mnt/data" # 数据存储路径
MINIO_OPTS="--address :9000 --console-address :9001" # 服务端口和控制台端口
EOF
创建服务文件 /etc/systemd/system/minio.service
:
[Unit]
Description=MinIO
Documentation=https://min.io/docs/minio/linux/index.html
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local
User=minio-user
Group=minio-user
ProtectProc=invisible
EnvironmentFile=-/etc/default/minio
ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ];then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\";exit 1;fi"
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
# MinIO RELEASE.2023-05-04T21-44-30Z adds support for Type=notify
# This may improve systemctl setups where other services use `After=minio.server`
# Uncomment the line to enable the functionality
# Type=notify
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Specifies the maximum number of threads this process can create
TasksMax=infinity
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
# Built for ${project.name}-${project.version} (${project.name})
sudo systemctl daemon-reloads
sudo systemctl enable --now minio
sudo systemctl status minio # 检查运行状态
sudo firewall-cmd --permanent --add-port=9000/tcp
sudo firewall-cmd --reload
通过以上步骤,可以显著提高Linux上MinIO的安装性能。这些优化措施包括使用SSD硬盘、优化内核参数、创建专用用户和存储目录、配置环境变量、创建Systemd服务、启动服务并设置开机自启以及配置防火墙。希望这些建议能帮助你更好地优化MinIO的安装性能。