Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

部署一个MinIO集群,个人记录。

规划

首先准备好数个节点,官方要求不低于4个节点,各节点间时间同步,且建议节点数量为偶数,我这里使用6个节点,系统为CentOS 7(官方现已不再支持内核较低的版本,我这里只是测试就无所谓了)。前端由单独的机器做ubuntu 24.04起HAProxy做L4负载均衡。

同时为了防止存储内部传输对业务网络造成影响,存储仅配置L2网络用于局域网通信。

节点上提前做好硬盘的挂载,建议将数据放置在单独的硬盘上。

注意:
MinIO 分布式集群的拓扑是“静态”的,不能动态添加节点或磁盘,必须重建集群。
因此请务必在正式开始建设前确定好稳定的拓扑和架构,一旦集群创建并有数据写入后,整个拓扑就不再能添加节点或磁盘了。

部署

  1. 下载MinIO到本机,目前的话RELEASE.2025-04-22T22-12-26Z是最后一个内置WebUI面板的版本
    1
    2
    wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2025-04-22T22-12-26Z -O minio
    chmod +x minio
    测试有效性,直接执行如下指令:
    1
    ./minio server --address '0.0.0.0:9000' --console-address '0.0.0.0:9001' /storage0/
    正常应该可以访问http://0.0.0.0:9001到MinIO的控制面板,能够访问后kill掉当前minio进程。
  2. 禁用IPv6
    将如下配置项写入/etc/sysctl.conf
    1
    2
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    然后应用:
    1
    sysctl -p
  3. 写hosts文件
    1
    2
    3
    4
    5
    6
    30.20.10.11 storNode01
    30.20.10.12 storNode02
    30.20.10.13 storNode03
    30.20.10.14 storNode04
    30.20.10.15 storNode05
    30.20.10.16 storNode06
  4. 写SystemD配置文件
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    [Unit]
    Description=MinIO
    After=network.target

    [Service]
    Environment="MINIO_ROOT_USER=lxnchan"
    Environment="MINIO_ROOT_PASSWORD=lxnchanminioadmin"
    ExecStart=/root/minio server http://stornode0{1...6}/storage0 --address '0.0.0.0:9000' --console-address '0.0.0.0:9001'
    Restart=always
    LimitNOFILE=1048576
    TasksMax=infinity
    TimeoutStopSec=infinity
    SendSIGKILL=no

    [Install]
    WantedBy=multi-user.target
    注意修改MINIO_ROOT_USERMINIO_ROOT_PASSWORD
  5. hostsminio.service同步到剩余节点
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    scp /etc/hosts root@30.20.10.12:/etc/hosts
    scp /etc/systemd/system/minio.service root@30.20.10.12:/etc/systemd/system/minio.service
    scp /etc/hosts root@30.20.10.13:/etc/hosts
    scp /etc/systemd/system/minio.service root@30.20.10.13:/etc/systemd/system/minio.service
    scp /etc/hosts root@30.20.10.14:/etc/hosts
    scp /etc/systemd/system/minio.service root@30.20.10.14:/etc/systemd/system/minio.service
    scp /etc/hosts root@30.20.10.15:/etc/hosts
    scp /etc/systemd/system/minio.service root@30.20.10.15:/etc/systemd/system/minio.service
    scp /etc/hosts root@30.20.10.16:/etc/hosts
    scp /etc/systemd/system/minio.service root@30.20.10.16:/etc/systemd/system/minio.service
  6. 所有节点起MinIO:
    1
    systemctl enable --now minio
    最后访问任一节点IP都可以访问到MinIO,如果访问不到看一下日志。

HAProxy

  1. 安装HAProxy
    1
    sudo apt update && apt install haproxy -y
  2. 创建CA证书
    因为我这里的业务要求强制使用HTTPS方式链接,因此我这里先本地自签个SSL证书。
    1
    2
    3
    4
    openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
    -keyout private.key -out public.crt \
    -subj "/C=CN/ST=Tianjin/L=Tianjin/O=LxnChan/OU=IT/CN=30.20.10.10" \
    -addext "subjectAltName=IP:30.20.10.10,DNS:storl4lb"
    然后将两个证书和密钥合成一个文件,以便给HAProxy使用:
    1
    cat public.crt private.key > haproxy.pem
  3. 写入配置文件
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    frontend minio_frontend
    #bind *:80
    bind *:443 ssl crt /root/certs/minio.pem
    mode tcp
    default_backend minio_backend

    backend minio_backend
    # Layer7
    #mode http
    #balance roundrobin
    #option httpchk GET /minio/health/ready
    #http-check expect status 200

    # Layer4
    mode tcp
    balance roundrobin
    option tcp-check
    tcp-check connect

    # server [name] [source] [check or empty]
    server minio1 stornode01:9000 check
    server minio2 stornode02:9000 check
    server minio3 stornode03:9000 check
    server minio4 stornode04:9000 check
    server minio5 stornode05:9000 check
    server minio6 stornode06:9000 check
    测试配置文件是否有效:
    1
    2
    root@storl4lb:~# haproxy -c -f /etc/haproxy/haproxy.cfg
    Configuration file is valid
    重启HAProxy:
    1
    systemctl restart haproxy

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

萌ICP备 20219421 号

津公网安备12011602300394号

中国互联网违法和不良信息举报中心

架构版本号:8.1.7 | 本站已全面支持IPv6

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

♥stand with innovative technologies of all kinds♥

Copyright 2024 LingXuanNing, All rights reserved.