linux系统部署minio,强烈推荐( 二 )


#!/bin/bash RUNNING_USER=minio MINIO_HOST=192.168.1.110 MINIO_ROOT_USER="minioadmin" MINIO_ROOT_PASSWORD="miniopwd" for i in {1..4}; do START_CMD="MINIO_ROOT_USER=${MINIO_ROOT_USER} MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}nohup minio server --address "${MINIO_HOST}:900${i}" --console-address "${MINIO_HOST}:1900${i}"http://${MINIO_HOST}:9001/mnt/mdata/node1/disk{1...4}http://${MINIO_HOST}:9002/mnt/mdata/node2/disk{1...4}http://${MINIO_HOST}:9003/mnt/mdata/node3/disk{1...4}http://${MINIO_HOST}:9004/mnt/mdata/node4/disk{1...4}> ./minio-multi-run${i}.log 2>&1 &" su ${RUNNING_USER} -c "${START_CMD}" echo "${START_CMD}" done
3.管理操作
# 启动实例 ./minio-multi-start.sh # 访问控制台 (注意:访问http://ip:9001也会直接重定向到19001端口) http://ip:19001 http://ip:19002 ... # 查看日志 tail -100f minio-multi-run1.log tail -100f minio-multi-run2.log ... # 查看所有minio进程 ps -ef |grep minio # 杀死所有minio进程 ps -aux | grep minio | awk '{print $2}' | xargs kill
4.多节点Nginx负载均衡
【linux系统部署minio,强烈推荐】upstream minio { server 192.168.1.110:9001; server 192.168.1.110:9002; server 192.168.1.110:9003; server 192.168.1.110:9004; } server{ listen 9000; server_name 192.168.1.110; ignore_invalid_headers off; proxy_buffering off; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host:$server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_header Host $http_host; proxy_connect_timeout 300; #秒 proxy_http_version 1.1; client_body_buffer_size 100m; client_max_body_size 1000m; chunked_transfer_encoding off; proxy_ignore_client_abort on; proxy_pass http://minio; } }
然后就可以通过:192.168.1.110:9000 直接访问API了,当然访问控制台还是会重定向到1900{1...4}端口 。

linux系统部署minio,强烈推荐

文章插图
 
服务方式部署 官方文档
官方文档
https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-single-drive.html
 
使用多驱动器的建议
  1. 如果使用多驱动器,强烈建议使用具有 XFS 格式磁盘的直连 JBOD 阵列,以获得最佳性能 。
  2. 多个磁盘确保具有相同的容量和格式,否则minio会限制每个磁盘的容量为最小的那个 。
  3. 挂在磁盘时确保使用/etc/fstab,保证每次重启自动挂载磁盘 。
  4. MinIO 不支持将具有现有 MinIO 数据的驱动器任意迁移到新的挂载位置
mkfs.xfs /dev/sdb -L DISK1 mkfs.xfs /dev/sdc -L DISK2 mkfs.xfs /dev/sdd -L DISK3 mkfs.xfs /dev/sde -L DISK4 nano /etc/fstab # LABEL=DISK1 /mnt/disk1 xfs defaults,noatime 0 2 LABEL=DISK2 /mnt/disk2 xfs defaults,noatime 0 2 LABEL=DISK3 /mnt/disk3 xfs defaults,noatime 0 2 LABEL=DISK4 /mnt/disk4 xfs defaults,noatime 0 2 单节点单/多驱动器部署 
1.创建 /etc/systemd/system/minio.service 服务
cd /etc/systemd/system/ touch minio.service
/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 # Run Os User User=minio Group=minio 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 # 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}) 
2.创建和授权minio用户数据模拟的驱动器目录
# 用于模拟多驱动器的目录 mkdir /mnt/disk1 /mnt/disk2 /mnt/disk3 /mnt/disk4 chown minio:minio /mnt/disk1 /mnt/disk2 /mnt/disk3 /mnt/disk4 # 用于单驱动器的目录 mkdir /mnt/data chown minio:minio /mnt/data
3.创建环境变量(注意更改用户名/密码)
# windows的在C:minioconfig touch /etc/default/minio vi /etc/default/minio
/etc/default/minio 文件内容如下
# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server. # This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment. # Omit to use the default values 'minioadmin:minioadmin'. # MinIO recommends setting non-default values as a best practice, regardless of environment MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=miniopwd # MINIO_VOLUMES sets the storage volume or path to use for the MinIO server. # 单驱动器 # MINIO_VOLUMES="/mnt/data" # 多驱动器(至少4个以上) MINIO_VOLUMES="/mnt/disk{1...4}" # 控制台访问端口 MINIO_OPTS="--console-address :19000" # 该参数设置为true支持挂载根目录的多驱动器部署(不建议) CI=true # MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server # MinIO assumes your network control plane can correctly resolve this hostname to the local machine # Uncomment the following line and replace the value with the correct hostname for the local machine. #MINIO_SERVER_URL="http://minio.example.net"


推荐阅读