minio的单节点和集群部署
0、下载
官网下载地址:https://min.io/download
1、单节点部署
# 01. 下载软件包
mkdir /app/tools -p
cd /app/tools
wget https://dl.minio.io/server/minio/release/linux-amd64/minio
# 02. 授权
chmod +x minio
# 03. 创建数据目录
mkdir /data/minio -p
# 03. 编写启动脚本
cat > /etc/systemd/system/minio.service <<EOF
[Unit]
Description=Minio Service
Documentation=https://docs.minio.io/
[Service]
Environment="MINIO_ACCESS_KEY=simple"
Environment="MINIO_SECRET_KEY=Minio@2023!"
ExecStart=/minio目录/minio server /data/minio --address "0.0.0.0:9000" --console-address "0.0.0.0:9001"
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
EOF
# 04. 启动minio服务
systemctl daemon-reload
systemctl start minio.service
systemctl enable minio.service > /dev/null 2>&1
# 05. 查看进程
netstat -lntup|grep minio
# 06. 访问
浏览器访问:http://loaclahost:9001
2、minio分布式集群部署
测试环境搭建minio分布式集群部署
采用3节点+nginx负载均衡实现
一、集群规划
首先在vm里创建好4台虚拟机
ip | 作用 | 磁盘 |
---|---|---|
192.168.10.25 | minio1 | 200G |
192.168.10.26 | minio2 | 200G |
192.168.10.27 | minio3 | 200G |
192.168.10.28 | nginx | 无 |
注意事项:
minio服务节点如果使用虚拟机,需要调度虚拟机到不同的物理宿主机,避免资源竞争
minio服务器数据磁盘需申请独立的磁盘,在物理底层要相互独立避免遇到磁盘io竞争,导致minio性能直线下降(性能下降严重,数据量大时会导致集群不可用)
如果使用lvm方式扩展集群容量,请在部署阶段minio数据目录就使用lvm
二、部署集群
1、服务器优化脚本
#!/bin/bash
cat > sysctl.conf <<EOF
# maximum number of open files/file descriptors
fs.file-max = 4194303
# use as little swap space as possible
vm.swappiness = 1
# prioritize application RAM against disk/swap cache
vm.vfs_cache_pressure = 50
# minimum free memory
vm.min_free_kbytes = 1000000
# follow mellanox best practices https://community.mellanox.com/s/article/linux-sysctl-tuning
# the following changes are recommended for improving IPv4 traffic performance by Mellanox
# disable the TCP timestamps option for better CPU utilization
net.ipv4.tcp_timestamps = 0
# enable the TCP selective acks option for better throughput
net.ipv4.tcp_sack = 1
# increase the maximum length of processor input queues
net.core.netdev_max_backlog = 250000
# increase the TCP maximum and default buffer sizes using setsockopt()
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
net.core.rmem_default = 4194304
net.core.wmem_default = 4194304
net.core.optmem_max = 4194304
# increase memory thresholds to prevent packet dropping:
net.ipv4.tcp_rmem = "4096 87380 4194304"
net.ipv4.tcp_wmem = "4096 65536 4194304"
# enable low latency mode for TCP:
net.ipv4.tcp_low_latency = 1
# the following variable is used to tell the kernel how much of the socket buffer
# space should be used for TCP window size, and how much to save for an application
# buffer. A value of 1 means the socket buffer will be divided evenly between.
# TCP windows size and application.
net.ipv4.tcp_adv_win_scale = 1
# maximum number of incoming connections
net.core.somaxconn = 65535
# maximum number of packets queued
net.core.netdev_max_backlog = 10000
# queue length of completely established sockets waiting for accept
net.ipv4.tcp_max_syn_backlog = 4096
# time to wait (seconds) for FIN packet
net.ipv4.tcp_fin_timeout = 15
# disable icmp send redirects
net.ipv4.conf.all.send_redirects = 0
# disable icmp accept redirect
net.ipv4.conf.all.accept_redirects = 0
# drop packets with LSR or SSR
net.ipv4.conf.all.accept_source_route = 0
# MTU discovery, only enable when ICMP blackhole detected
net.ipv4.tcp_mtu_probing = 1
EOF
echo "Enabling system level tuning params"
sysctl --quiet --load sysctl.conf && rm -f sysctl.conf
# `Transparent Hugepage Support`*: This is a Linux kernel feature intended to improve
# performance by making more efficient use of processor’s memory-mapping hardware.
# But this may cause https://blogs.oracle.com/linux/performance-issues-with-transparent-huge-pages-thp
# for non-optimized applications. As most Linux distributions set it to `enabled=always` by default,
# we recommend changing this to `enabled=madvise`. This will allow applications optimized
# for transparent hugepages to obtain the performance benefits, while preventing the
# associated problems otherwise. Also, set `transparent_hugepage=madvise` on your kernel
# command line (e.g. in /etc/default/grub) to persistently set this value.
echo "Enabling THP madvise"
echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
二、磁盘挂载
把数据磁盘格式化为ext4或xfs
创建minio数据目录,挂载数据磁盘到数据目录
并写入到/etc/fstab文件实现永久挂载
我在3台minio机器的磁盘都挂载到了 /data 下
三、配置
MINIO_ROOT_USER管理员用户名
MINIO_ROOT_PASSWORD管理员密码
如果minio服务器IP地址连续可以直接写IP地址写法
MINIO_OPTS控制台端口
vi /etc/systemd/system/minio.service
[Unit]
Description=Minio Service
Documentation=https://docs.minio.io/
[Service]
Environment="MINIO_ACCESS_KEY=simple"
Environment="MINIO_SECRET_KEY=Minio@2023!"
ExecStart=/data/minio server http://192.168.10.25/data http://192.168.10.26/data http://192.168.10.27/data --address "0.0.0.0:9000" --console-address "0.0.0.0:9001"
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
四、启动
分别在三台服务器节点启动minio
systemctl enable minio
systemctl start minio
systemctl status minio
五、负载均衡
在nginx服务器部署好nginx后,在配置了进行负载均衡
vi /etc/nginx/conf.d/nginx.conf
upstream minio {
server 192.168.10.25:9000;
server 192.168.10.26:9000;
server 192.168.10.27:9000;
}
upstream console {
ip_hash;
server 192.168.10.25:9001;
server 192.168.10.26:9001;
server 192.168.10.27:9001;
}
server {
listen 9000;
listen [::]:9000;
server_name localhost;
# To 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;
# To disable buffering
proxy_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;
}
}
server {
listen 9001;
listen [::]:9001;
server_name localhost;
# To 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;
# To disable buffering
proxy_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;
# 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://console;
}
}
nginx -t
ngins -s reload
六、访问地址:
如果可以访问成功,则负载成功,存入集群的文件会同时存在三台服务器磁盘中
http://192.168.10.28:9001
账户密码:
simple / Minio@2023!
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果