devops
minio bin部署
Table of Contents
一、准备工作
主机资源准备
确保有三台机器可用,每台机器的配置应满足 minio 的运行需求。例如:
主机名 IP 地址 备注 node1 192.168.174.130 需要额外的数据盘 node2 192.168.174.131 需要额外的数据盘 node3 192.168.174.132 需要额外的数据盘 注意:集群版本的minio部署需要有单独的数据盘分区后进行挂载,才能作为driver的配置目录
设置免密登录
在三台机器上分别执行以下命令,生成 SSH 密钥并分发到其他机器:
ssh-keygen ssh-copy-id root@192.168.174.130 ssh-copy-id root@192.168.174.131 ssh-copy-id root@192.168.174.132- 关闭并且禁用防火墙自动启动
systemctl stop firewalld systemctl disable firewalld - 关闭selinux
setenforce 0 sed 's/SELINUX=enforcing/SELINUX=permissive/' -i /etc/selinux/config
二、部署 minio
下载 minio 二进制文件
在任意一台机器上下载 minio 的二进制文件,并分发到其他机器。例如:
wget https://dl.min.io/server/minio/release/linux-amd64/minio chmod +x minio mkdir -p /data/service/minio/{bin,conf,data/volume{1..2}} mv minio /data/service/minio/bin将二进制文件分发到其他机器:
ssh 192.168.174.131 "mkdir -p /data/service/minio/{bin,conf,data/volume{1..2}}" ssh 192.168.174.132 "mkdir -p /data/service/minio/{bin,conf,data/volume{1..2}}" scp /data/service/minio/bin/minio 192.168.174.131:/data/service/minio/bin scp /data/service/minio/bin/minio 192.168.174.132:/data/service/minio/bin创建minio driver的挂载点
在每台机器上创建 mino的挂载点。以下是每台机器都要执行的操作:
以node1 (192.168.174.130)举例
# 假设数据盘是nvme0n2,对其分两个区,每个占50%的大小 parted /dev/nvme0n2 -s mklabel gpt mkpart data1 ext4 0% 50% mkpart data2 ext4 50% 100% # 格式化文件系统 mkfs.xfs -f /dev/nvme0n2p1 mkfs.xfs -f /dev/nvme0n2p2 # 查看对应的UUID,并写入fstab ll /dev/disk/by-uuid/ echo "UUID=<替换为nvme0n2p1对应UUID> /data/service/minio/data/volume1 xfs defaults 0 0" >> /etc/fstab echo "UUID=<替换为nvme0n2p2对应UUID> /data/service/minio/data/volume2 xfs defaults 0 0" >> /etc/fstab mount -a # 挂载磁盘 lsblk # 查看确认挂载完毕配置systemd启动相关文件
在每台机器上创建minio 的配置文件 minio.env。以下是单台机器的配置示例:
- 配置minio的启动配置文件
cat > /data/service/minio/conf/minio.env << 'EOF' MINIO_VOLUMES="http://192.168.174.13{0...2}:9000/data/service/minio/data/volume{1...2}" MINIO_OPTS="--console-address :9001" MINIO_ROOT_USER=minioadmin MINIO_ROOT_PASSWORD=miniopass EOF - 配置对应的systemd文件
cat > /etc/systemd/system/minio.service << 'EOF' [Unit] Description=MinIO Documentation=https://min.io/docs/minio/linux/index.html Wants=network-online.target After=network-online.target AssertFileIsExecutable=/data/service/minio/bin/minio [Service] WorkingDirectory=/data/service/minio/ ProtectProc=invisible EnvironmentFile=-/data/service/minio/conf/minio.env ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /data/service/minio/conf/minio.env\"; exit 1; fi" ExecStart=/data/service/minio/bin/minio server $MINIO_OPTS $MINIO_VOLUMES Type=notify User=root Group=root Restart=always LimitNOFILE=65536 TasksMax=infinity TimeoutStopSec=infinity SendSIGKILL=no [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl restart minio systemctl enable minio- 配置minio的启动配置文件
三、部署 NGINX
在nginx的服务器上部署nginx,配置后启动服务
yum install nginx -y cat > /etc/nginx/conf.d/minio.conf << 'EOF' upstream minio_s3 { least_conn; server 192.168.174.130:9000; server 192.168.174.131:9000; server 192.168.174.132:9000; } upstream minio_console { least_conn; server 192.168.174.130:9001; server 192.168.174.131:9001; server 192.168.174.132:9001; } server { listen 9010; listen [::]:9010; server_name _; # Allow special characters in headers ignore_invalid_headers off; # Allow any size file to be uploaded. # Set to a value such as 1000m; to restrict file size to a specific value client_max_body_size 0; # Disable buffering proxy_buffering off; proxy_request_buffering off; location / { 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_pass http://minio_s3; # This uses the upstream directive definition to load balance } } server { listen 9011; listen [::]:9011; server_name _; # Allow special characters in headers ignore_invalid_headers off; # Allow any size file to be uploaded. # Set to a value such as 1000m; to restrict file size to a specific value client_max_body_size 0; # Disable buffering proxy_buffering off; proxy_request_buffering off; location / { 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_set_header X-NginX-Proxy true; # This is necessary to pass the correct IP to be hashed real_ip_header X-Real-IP; proxy_connect_timeout 300; # To support websocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; chunked_transfer_encoding off; proxy_pass http://minio_console/; # This uses the upstream directive definition to load balance } } EOF systemctl restart nginx systemctl status nginx通过 http://<NGINX-IP:9011> 访问前端,可以访问即可 ,用户名密码为minioadmin/miniopass
DEVOPS · MINIO · DEPLOYMENT
devops minio deployment
