Skip to main content

MinIO Cluster Deployment

Initialize Docker Swarm Environment

  1. Execute the swarm initialization command on the first node, MinIO Node01.

    docker swarm init

    # The initialization command will output a join command that needs to be run on the other three nodes.
    # When there are multiple IP addresses on the server, you can specify the IP and port for other nodes to connect to the current manager node using the --advertise-addr parameter.
    # docker swarm init --advertise-addr 192.168.1.11
  2. Run the join command on MinIO Node02, Node03, and Node04 to join the swarm cluster.

    docker swarm join --token xxxxxxxx

    # If the token is forgotten, you can view it on MinIO Node01 with the following command:
    # docker swarm join-token worker
  3. View the nodes and record each node ID.

    docker node ls

Deploy MinIO Cluster

All the following steps need to be performed on all four servers

  1. Download the image

    docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-minio:RELEASE.2025-04-22T22-12-26Z
  2. Create a data storage directory

    mkdir -p /data/minio/volume

The following steps need to be performed only on the first node, MinIO Node01

  1. Create a configuration file storage directory

    mkdir -p /usr/local/minio
  2. Create the MinIO configuration file

    cat > /usr/local/minio/minio.yaml <<'EOF'
    version: '3'
    services:
    minio1:
    hostname: minio1
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-minio:RELEASE.2025-04-22T22-12-26Z
    environment:
    MINIO_ROOT_USER: "mingdao"
    MINIO_ROOT_PASSWORD: "123456789"
    volumes:
    - /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
    - /data/minio/volume:/data/storage
    ports:
    - "9011:9000"
    # - "19111:9001" # Access port for MinIO console, uncomment if needed
    command: minio server http://minio{1...4}/data/storage/data --console-address ":9001"
    deploy:
    placement:
    constraints:
    - node.id == xxxxxxxxxxxxxxxx # Docker node.id value of MinIO Node01

    minio2:
    hostname: minio2
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-minio:RELEASE.2025-04-22T22-12-26Z
    environment:
    MINIO_ROOT_USER: "mingdao"
    MINIO_ROOT_PASSWORD: "123456789"
    volumes:
    - /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
    - /data/minio/volume:/data/storage
    ports:
    - "9012:9000"
    command: minio server http://minio{1...4}/data/storage/data --console-address ":9001"
    deploy:
    placement:
    constraints:
    - node.id == xxxxxxxxxxxxxxxx # Docker node.id value of MinIO Node02

    minio3:
    hostname: minio3
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-minio:RELEASE.2025-04-22T22-12-26Z
    environment:
    MINIO_ROOT_USER: "mingdao"
    MINIO_ROOT_PASSWORD: "123456789"
    volumes:
    - /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
    - /data/minio/volume:/data/storage
    ports:
    - "9013:9000"
    command: minio server http://minio{1...4}/data/storage/data --console-address ":9001"
    deploy:
    placement:
    constraints:
    - node.id == xxxxxxxxxxxxxxxx # Docker node.id value of MinIO Node03

    minio4:
    hostname: minio4
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-minio:RELEASE.2025-04-22T22-12-26Z
    environment:
    MINIO_ROOT_USER: "mingdao"
    MINIO_ROOT_PASSWORD: "123456789"
    volumes:
    - /usr/share/zoneinfo/Etc/GMT-8:/etc/localtime
    - /data/minio/volume:/data/storage
    ports:
    - "9014:9000"
    command: minio server http://minio{1...4}/data/storage/data --console-address ":9001"
    deploy:
    placement:
    constraints:
    - node.id == xxxxxxxxxxxxxxxx # Docker node.id value of MinIO Node04
    EOF
    • The access key for the object storage is specified by the MINIO_ROOT_USER environment variable. This is a core credential, and a strong password should be used during deployment.
    • The secret key for the object storage is specified by the MINIO_ROOT_PASSWORD environment variable. This is a critical security key, and a strong password should be used during deployment.
  3. Configure start and stop scripts

    cat > /usr/local/minio/start.sh <<'EOF'
    docker stack deploy -c /usr/local/minio/minio.yaml minio --detach=false
    EOF

    cat > /usr/local/minio/stop.sh <<'EOF'
    docker stack rm minio
    EOF

    chmod +x /usr/local/minio/start.sh
    chmod +x /usr/local/minio/stop.sh
  4. Start the MinIO service

    bash /usr/local/minio/start.sh
  5. Check the status of each MinIO node

    docker stack ps minio