Study notes MinIo object storage-Docker distributed cluster construction pitfalls!

1 Overview

1.1 Meaning

MinIO is a high-performance object storage service based on Go language, which has 39K+Stars on Github. It adopts the Apache License v2.0 open source protocol and is very suitable for storing large-capacity unstructured data, such as pictures, videos, log files, backup data and container/virtual machine images. This article will use MinIO to build an object storage service to store pictures.

MinIO is a high-performance, distributed object storage service designed for cloud-native and containerized applications. It has the following main features and functions:

  1. Object storage: MinIO provides a simple and powerful object storage interface that allows you to store and retrieve files of any size, from a few KB to several TB.
  2. High performance: MinIO is designed as a high-performance object storage service. It uses parallel and distributed algorithms to accelerate data upload and download, and provides fast access speeds through multi-threading and streaming.
  3. Scalability: MinIO supports horizontal expansion and can increase storage capacity and processing power according to needs. You can build a distributed storage cluster by adding more MinIO instances to achieve high data availability and fault tolerance.
  4. Highly compatible: MinIO is compatible with the AWS S3 API, which means you can use your existing S3 tools and libraries to interact with MinIO without modification.
  5. Security: MinIO provides a variety of security features, including data encryption, access control, authentication, and network transmission encryption. You can configure appropriate security policies to protect stored data based on your needs.
  6. Highly available: MinIO has a highly available architecture that supports data redundancy and failover. When a node fails, the storage cluster automatically recovers and maintains availability.
  7. Open source and free: MinIO is open source software licensed under the Apache License 2.0. You are free to use, modify and distribute MinIO.

MinIO is very suitable for scenarios such as building private clouds, storing and distributing static content, backup and archiving, etc. It provides an easy-to-use interface and rich functionality, allowing developers to easily build and manage object storage services.

​ This tutorial assumes all hosts running MinIO use a recommended Linux operating system such as RHEL8+ or Ubuntu 18.04+.

1.2 Application scenarios

​ As shown in the figure below, the application scenario of MinIO can be used not only as an object storage service in a private cloud, but also as a gateway layer for cloud object storage, seamlessly connecting Amazon S3orMicroSoft Azure

Insert image description here

1.3 Features

High performance:
As a high-performance storage, under standard hardware conditions, its read and write rates can reach 55Gb/sand respectively 35Gb/s. And MinIO supports that an object file can be of any size, ranging from a few kb to a maximum of 5T.

Scalable:
Different MinIO clusters can form a federation and form a global namespace, and support spanning multiple data centers.

Cloud native:
containerization, K8S-based orchestration, multi-tenant support.

Amazon S3 Compatible:
Uses Amazon S3 v2/v4 API. Minio server can be accessed using Minio SDK, Minio Client, AWS SDK and AWS CLI.

Can be connected to a variety of back-end storage:
In addition to Minio's own file system, it also supports DAS, JBODs, NAS, Google Cloud Storage and Azure Blob storage.

SDK support:

Lambda Computation:
The Minio server triggers Lambda functions through its AWS SNS/SQS-compatible event notification service. Support targets message queues such as Kafka, NATS, AMQP, MQTT, Webhooks and databases such as Elasticsearch, Redis, Postgres and MySQL.

The graphical interface
has an operation page.

Simple functionality:
less error-prone and quick to start.

Supports erasure coding:
MinIO uses erasure coding and checksum to prevent hardware errors and silent data pollution. Under the highest redundancy configuration, data can be recovered even if 1/2 of the disk is lost.

1.4 Basic concepts

Object: Basic objects stored in Minio, such as files, byte streams, Anything...

​Bucket: The logical space used to store Objects. The data between each Bucket is isolated from each other. For the client, it is equivalent to a top-level folder that stores files.

​ Drive: The disk where data is stored is passed in as a parameter when MinlO is started. All object data in Minio will be stored in Drive.

​Set : It is a collection of drives. Distributed deployment automatically divides one or more sets according to the cluster size. The drives in each set are distributed in different locations. An object is stored in a Set. (For example: {1…64} is divided into 4 sets each of size 16.)

  • An object is stored in a Set
  • A cluster is divided into multiple Sets
  • The number of Drives included in a Set is fixed and is automatically calculated by the system based on the cluster size by default. —Drives in a SET are distributed on different nodes as much as possible

1.5 Erasure Code EC (Erasure Code)

​ Erasure Code (Erasure Code) is a data encoding technology used for data redundancy and fault tolerance. It achieves data fault tolerance and recovery by splitting the original data into multiple data blocks and generating additional redundant data blocks.

Erasure coding is often used in distributed storage systems to improve data reliability and durability. Compared with traditional data redundancy backup methods, erasure coding has higher storage efficiency.

The following are the main features and advantages of erasure coding:

  1. Lower redundancy : Erasure coding can split the original data into multiple data blocks and generate some redundant data blocks. Compared with traditional backup methods, the required redundancy is lower. This means that erasure coding can provide data redundancy and fault tolerance with higher storage efficiency.
  2. Strong fault tolerance : Erasure coding can recover lost or damaged original data blocks based on part of the information in redundant data blocks. Even in case of data loss or hardware failure, complete data can still be recovered. Different erasure coding schemes provide different levels of fault tolerance, and the appropriate scheme can be selected according to specific needs.
  3. Balanced data distribution : Erasure coding can distribute data across multiple storage nodes to achieve distributed storage of data. This prevents data from being concentrated on a single node and improves the load balancing and performance of the system.
  4. Save storage space : Erasure coding can provide data fault tolerance with lower redundancy and save storage space compared to traditional backup methods. Especially in large-scale data storage scenarios, erasure coding can significantly reduce storage costs.

Erasure coding has a wide range of applications, including cloud storage, distributed file systems, large-scale data centers and other fields. It has unique advantages in data redundancy and fault tolerance, and has become an important technical means when facing large-scale data processing and storage requirements.

1.6 Storage form

​ When the file object is uploaded to MinlO, it will be in the corresponding data storage disk, with the Bucket name as the directory, the file name as the next-level directory, and the file name under the file name is part.1 and xl.meta (the old version, the latest version is as shown below) , the former is the encoding data block and the verification block, and the latter is the metadata file.

Insert image description here

illustrate:

  • Erasure codes are stored in a parity manner.
  • In the new version of MinIo, a Hash code will be stored to verify the integrity of the file. If the hash code verification is different, it means the file is incomplete.

1.7 Storage solution

Insert image description here

illustrate:

​ When the MinIO cluster is built, an API interface will be provided. You only need to expose an additional port to achieve distributed storage.

Insert image description here
illustrate:

8 nodes, 1 hard disk per node

Insert image description here
illustrate:

4 nodes, 4 disks per node

2. Basic use cases

2.1 Stand-alone deployment

2.1.2 No erasure coding mode

2.1.2.1 Overview

Insert image description here

illustrate:

​ When the non-erasure coding mode is started in a single-machine deployment, for each piece of object data, minio stores the data directly under data without creating a copy or enabling the erasure coding mechanism. Therefore, in this model, both the service instance and the disk are "single points" without any high availability guarantee. Disk damage means data loss.

2.1.2.2Linux method

Step 1: Install MinIO service

The following tabs provide examples of installing MinIO onto a 64-bit Linux operating system using RPM, DEB, or binary. RPM and DEB packages will automatically install MinIO to the necessary system paths and create services. MinIO strongly recommends using RPM or DEB to install routing. To update a deployment that uses management, see Updating a systemctl-managed MinIO deployment .

wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20230527055619.0.0.x86_64.rpm -O minio.rpm
sudo dnf install minio.rpm

illustrate:

​ The above operation steps are performed on a system whose system architecture is AMD 64-bit

Step 2: Start the MinIO service

Run the following command from a system terminal or shell to start a local MinIO instance using this folder. You can replace this path with another folder path on your local machine:~/minio

mkdir ~/minio
minio server ~/minio --console-address :9090

illustrate:

​ Use this command to start the MinIO service, and identify the folder in which the server is running by specifying the Path parameter

When the program starts successfully, the console will print the following:

Insert image description here

illustrate:

  • You can see that the default login password and login user are:minioadmin

Notice:

  • The above steps are the normal execution process, but at this time you will find that there is a warning:

    Insert image description here

  • The warning content indicates that the port of the controller is dynamic rather than statically fixed, and the port needs to be manually specified at this time. If you need to modify the initial account password, you also need to specify it additionally. please watch the following part.

Replenish:

  • The default username and password are minioadmin:minioadmin. To modify the default username and password, you can use:

    export MINIO_ROOT_USER=root
    export MINIO_ROOT_PASSWORD=qweasdzxc
    
  • The default configuration directory is ${HOME}/.minio. You can customize the configuration directory through the –config-dir command:

    minio server --config-dir /mnt/config /mnt/data
    
  • The console listening port is dynamically generated, and a static port can be specified through –console-address ":port"

    minio server --console-address ":9090" /mnt/data
    

    Insert image description here

Step 3: Connect the browser to the MinIO service

​ Open http://127.0.0.1:9000 in a web browser to access the MinIO console . You can also enter any network address specified as part of the server command output. For example, the console in the sample output : http://192.0.2.10:9090 http://127.0.0.1:9090 indicates two possible addresses for connecting to the console.

Insert image description here

2.1.2.3Docker method

Step 1: Check the system’s designated port occupancy

sudo netstat -tuln | grep 9000
sudo netstat -tuln | grep 9090

illustrate:

  • Check the specified 9000 and 9090 ports to prepare for the next Docker port mapping
  • Usage format: sudo netstat -tuln | grep

If port occupancy occurs, as shown below, Docker’s mapped port needs to be properly replaced.

If there is no port occupation, no message will be returned.

Insert image description here

Step 2: Start the MinIO service
docker run -d \
-p 9000:9000 \
-p 9090:9090 \
--name=minio \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /home/data:/data -v /home/config:/root/.minio \
minio/minio server /data \
--console-address ":9000" \
--address ":9090"

Notice:

  • The default startup of minio is a dynamic port. You need to set a fixed port here.--console-address ":9000" --address ":9090"
  • Step on the trap, here you need to map the S3-API interface port of the MinIO service to the system host.

illustrate:

  • docker run: Used to run a new container in Docker.
  • -d: Indicates running the container in background (daemon) mode.
  • -p 9000:9000: Map port 9000 of the host to port 9000 of the container, allowing access to the MinIO service from the host.
  • -p 9090:9090: Map port 9090 of the host to port 9090 of the container, allowing access to the S3-API interface of the MinIO service from the host.
  • --name=minio: Specify the name of the container as "minio".
  • --restart=always: Set the container to automatically restart on startup.
  • -e "MINIO_ROOT_USER=root": Set the MinIO root user to "root".
  • -e "MINIO_ROOT_PASSWORD=qweasdzxc": Set the MinIO root user password to "qweasdzxc".
  • -v /home/data:/data: Mount the "/home/data" directory of the host to the "/data" directory of the container to store MinIO data.
  • -v /home/config:/root/.minio: Mount the host's "/home/config" directory to the container's "/root/.minio" directory to store MinIO configuration files.
  • minio/minio: Docker image using MinIO.
  • server /data: Specify the data directory of the MinIO server as "/data".
  • --console-address ":9000": Specify the address of the MinIO console as ":9000" to allow access to the MinIO web interface through this address.
  • --address ":9090": Specify the MinIO server address as ":9090" to allow access to the MinIO API interface through this address.
Step 3: Check the listening port information

Insert image description here

View network connection and listening port information on the system

netstat -tpnl

illustrate:

As you can see, the port listener already exists

Step 4: Connect the browser to the MinIO service

​ Open http://127.0.0.1:9000 in a web browser to access the MinIO console . You can also enter any network address specified as part of the server command output. For example, the console in the sample output : http://192.0.2.10:9090 http://127.0.0.1:9090 indicates two possible addresses for connecting to the console.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-75QJ5Qwx-1686235487719) (MiNIO.assets/image-20230605111810325.png)]

2.1.3 With erasure coding mode

2.1.3.1 Overview

Minio uses erasure coding and checksums to protect data from hardware failures and silent data corruption. Even if you lose half (N/2) of your hard drives, you can still recover your data.

Insert image description here

​ Erasure coding is a mathematical algorithm for recovering lost and damaged data. Minio uses Reed-Solomon code to split the object into N/2 data and N/2 parity blocks. This means that if it is 12 disks, an object will be divided into 6 data blocks and 6 parity blocks. You can lose any 6 disks (regardless of whether they are stored data blocks or parity blocks). You It is still possible to recover data from the remaining disk.

illustrate:

​ Start in a single-machine deployment without erasure coding mode. In this mode, multiple local disk parameters are passed in for the minio server instance. Once more than one disk parameter is encountered, minio server will automatically enable erasure code mode. Erasure code has requirements for the number of disks. If the requirements are not met, the instance startup will fail. After erasure code is enabled, at least 4 endpoints (in standalone mode, that is, directories on the local disk) passed to the minio server are required.

Insert image description here

illustrate:

​ If the file is less than 10M, it will be stored in the form of a file. If the file is larger than 10M, the file object will be stored in blocks.

2.1.3.2 Operation steps

Step 1: Start the MinIO service
docker run -d \
-p 9000:9000 \
-p 9090:9090 \
--name=minio \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /home/minio/data1:/data1 \
-v /home/minio/data2:/data2 \
-v /home/minio/data3:/data3 \
-v /home/minio/data4:/data4 \
-v /home/minio/data5:/data5 \
-v /home/minio/data6:/data6 \
-v /home/minio/data7:/data7 \
-v /home/minio/data8:/data8 \
minio/minio server /data{1...8} \
--console-address ":9000" \
--address ":9090"

Notice:

  • The default startup of minio is a dynamic port. You need to set a fixed port here.--console-address ":9000" --address ":9090"
  • Step on the trap, here you need to map the S3-API interface port of the MinIO service to the system host.

illustrate:

  • docker run: Used to run a new container in Docker.
  • -d: Indicates running the container in background (daemon) mode.
  • -p 9000:9000: Map port 9000 of the host to port 9000 of the container, allowing access to the MinIO service from the host.
  • -p 9090:9090: Map port 9090 of the host to port 9090 of the container, allowing access to the S3-API interface of the MinIO service from the host.
  • --name=minio: Specify the name of the container as "minio".
  • --restart=always: Set the container to automatically restart on startup.
  • -e "MINIO_ROOT_USER=root": Set the MinIO root user to "root".
  • -e "MINIO_ROOT_PASSWORD=qweasdzxc": Set the MinIO root user password to "qweasdzxc".
  • -v /home/data:/data: Mount the "/home/data" directory of the host to the "/data" directory of the container to store MinIO data.
  • -v /home/config:/root/.minio: Mount the host's "/home/config" directory to the container's "/root/.minio" directory to store MinIO configuration files.
  • minio/minio: Docker image using MinIO.
  • server /data: Specify the data directory of the MinIO server as "/data".
  • --console-address ":9000": Specify the address of the MinIO console as ":9000" to allow access to the MinIO web interface through this address.
  • --address ":9090": Specify the MinIO server address as ":9090" to allow access to the MinIO API interface through this address.

Supplement: Check the storage directory

Insert image description here

  • You can see through the mc client tool that the check codes and source file information of the disk files are stored in the 8 disks in the photo bucket.
Step 2: Connect the browser to the MinIO service

Insert image description here

illustrate:

​ After seeing this interface, you can successfully use the MinIo service

2.2 Distributed cluster deployment

2.2.1 Overview

2.2.1.1 Meaning

Distributed Minio allows you to combine multiple hard drives (even on different machines) into an object storage service. Since the hard disks are distributed on different nodes, distributed Minio avoids single points of failure.

Insert image description here

2.2.1.2 Common methods

​ Distributed storage, a key point is the reliability of data, that is, ensuring the integrity of the data, without loss or damage. Only on the premise of achieving reliability can we have the foundation to pursue consistency, high availability, and high performance. In the storage field, there are generally two main types of methods to ensure data reliability, one is the redundancy method and the other is the verification method.

Redundancy The redundancy method is the simplest and most direct, that is, making a copy
of the stored data . When the data is lost or damaged, the backup content can be used to restore it. The number of copies determines the reliability of the data. There will be cost considerations in this. The more copies of data, the more reliable the data will be, but the more equipment required, the higher the cost. Reliability allows for the loss of one piece of data. Currently, many distributed systems are implemented in this way, such as Hadoop's file system (3 copies), Redis cluster, MySQL's active-standby mode, etc.

Verification The verification method uses the mathematical calculation
of the check code to verify and restore lost or damaged data. Note that there are two functions here. One is verification. By calculating the checksum of the data, you can check whether the data is complete and whether it is damaged or changed. It is often used in data transmission and storage, such as TCP protocol. ; The second is recovery and restoration. By combining data with check codes and mathematical calculations, lost or damaged data can be restored, which can reduce redundancy while ensuring data reliability, such as RAID technology and erasure coding in stand-alone hard disk storage . (Erasure Code) technology, etc. MinIO uses erasure coding technology.

2.2.1.3 Advantages

Data Protection
Distributed Minio uses erasure coding to prevent multiple node downtime and bit rot. Distributed Minio requires at least 4 hard disks . Using distributed Minio automatically introduces the erasure coding function .

High availability
: There is a single point of failure in the stand-alone Minio service. On the contrary, if it is a distributed Minio with N hard disks, as long as N/2 hard disks are online, your data is safe. But you need at least N/2+1 hard disks to create new objects.
For example, a 16-node Minio cluster has 16 hard disks per node. Even if 8 servers are down, the cluster will still be readable, but you need 9 servers to write data.

Consistency
Minio In distributed and stand-alone modes, all read and write operations strictly adhere to the read-after-write consistency model.

2.2.1.4 Precautions

​ To start a distributed Minio instance, you only need to pass the hard disk location as a parameter to the minio server command. Then, you need to run the same command on all other nodes.

  • All nodes in distributed Minio need to have the same access key and secret key so that these nodes can establish connections. In order to achieve this, you need to export the access key and secret key into environment variables before executing the minicserver command. The new version uses MINIO_ROOT_USER&MINIO_ROOT_PASSWORD.
  • The disk used by distributed Minio must be clean and contain no data.
  • The node time difference in distributed Minio cannot exceed 3 seconds. You can use NTP to ensure time consistency.
  • Running distributed Minio under Windows is in the experimental stage, please use it with caution.

2.2.2 Basic use cases

Experiment 3: Start Docker cluster mode

premise:

This tutorial assumes that all hosts running MinIO are using the recommended Linux operating system , such as RHEL8+ or Ubuntu 18.04+.

Step 1: Create a file directory
cd /opt
mkdir minio
Step 2: Mount the resource directory
sudo mount /dev/sda3 /opt/minio

illustrate:

  • Check the resource directory in advance

    lsblk
    

    Insert image description here

Step 3: Set up auto-mounting at startup
sudo nano /etc/fstab
/dev/sda3 /info/minio ext4 defaults 0 0
Step 4: Docker starts

Notice:

  • All nodes need to be completed within 3 seconds
  • Resources in all nodes need to be empty
  • The hostnames of all nodes must be different and in order

Execute the following commands on the four virtual machines respectively

sudo docker run -d -p 9000:9000 -p 9090:9090 \
--name=minio-node \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /info/minio/data1:/data1 \
-v /info/minio/data2:/data2 \
-v /info/minio/data3:/data3 \
-v /info/minio/data4:/data4 \
-v /info/minio/data5:/data5 \
-v /info/minio/data6:/data6 \
-v /info/minio/data7:/data7 \
-v /info/minio/data8:/data8 \
-v /info/minio/config:/root/.minio \
--network host \
--hostname "host1" \
minio/minio server http://10.13.165.121:9000/data{1...8} http://10.13.165.122:9000/data{1...8} http://10.13.165.125:9000/data{1...8} http://10.13.165.199:9000/data{1...8} \
--console-address ":9090" \
sudo docker run -d -p 9000:9000 -p 9090:9090 \
--name=minio-node \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /info/minio/data1:/data1 \
-v /info/minio/data2:/data2 \
-v /info/minio/data3:/data3 \
-v /info/minio/data4:/data4 \
-v /info/minio/data5:/data5 \
-v /info/minio/data6:/data6 \
-v /info/minio/data7:/data7 \
-v /info/minio/data8:/data8 \
-v /info/minio/config:/root/.minio \
--network host \
--hostname "host2" \
minio/minio server http://10.13.165.121:9000/data{1...8} http://10.13.165.122:9000/data{1...8} http://10.13.165.125:9000/data{1...8} http://10.13.165.199:9000/data{1...8} \
--console-address ":9090" \
sudo docker run -d -p 9000:9000 -p 9090:9090 \
--name=minio-node \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /info/minio/data1:/data1 \
-v /info/minio/data2:/data2 \
-v /info/minio/data3:/data3 \
-v /info/minio/data4:/data4 \
-v /info/minio/data5:/data5 \
-v /info/minio/data6:/data6 \
-v /info/minio/data7:/data7 \
-v /info/minio/data8:/data8 \
-v /info/minio/config:/root/.minio \
--network host \
--hostname "host3" \
minio/minio server http://10.13.165.121:9000/data{1...8} http://10.13.165.122:9000/data{1...8} http://10.13.165.125:9000/data{1...8} http://10.13.165.199:9000/data{1...8} \
--console-address ":9090" \
sudo docker run -d -p 9000:9000 -p 9090:9090 \
--name=minio-node \
--restart=always \
-e "MINIO_ROOT_USER=root" \
-e "MINIO_ROOT_PASSWORD=qweasdzxc" \
-v /info/minio/data1:/data1 \
-v /info/minio/data2:/data2 \
-v /info/minio/data3:/data3 \
-v /info/minio/data4:/data4 \
-v /info/minio/data5:/data5 \
-v /info/minio/data6:/data6 \
-v /info/minio/data7:/data7 \
-v /info/minio/data8:/data8 \
-v /info/minio/config:/root/.minio \
--network host \
--hostname "host4" \
minio/minio server http://10.13.165.121:9000/data{1...8} http://10.13.165.122:9000/data{1...8} http://10.13.165.125:9000/data{1...8} http://10.13.165.199:9000/data{1...8} \
--console-address ":9090" \

illustrate:

  • The configuration here is to mount 8 hard disks on one node.
  • It is worth noting that the number of mounted hard disks ranges from 2 to 16
  • When the MinIo object storage service is built using a distributed cluster, the erasure coding mode will be automatically turned on within MinIo.

Replenish:

The premise is that each virtual machine needs to be able to ping each other.

Notice:

  • If the initial file contains files, the following prompt will appear

    ERROR Unable to initialize backend: /data1 drive is already being used in another erasure deployment. (Number of drives specified: 16 but the number of drives found in the 1st drive's format.json: 4)
    

    illustrate:

    At this time, delete the resources that require the mounting path or change the mounting directory.

Notice:

  • If there is a problem with other hosts, the following prompt will appear

    API: SYSTEM()
    Time: 08:07:08 UTC 06/06/2023
    Error: Read failed. Insufficient number of drives online (*errors.errorString)
           6: internal/logger/logger.go:258:logger.LogIf()
           5: cmd/prepare-storage.go:246:cmd.connectLoadInitFormats()
           4: cmd/prepare-storage.go:304:cmd.waitForFormatErasure()
           3: cmd/erasure-server-pool.go:103:cmd.newErasureServerPools()
           2: cmd/server-main.go:810:cmd.newObjectLayer()
           1: cmd/server-main.go:611:cmd.serverMain()
    Waiting for a minimum of 2 drives to come online (elapsed 16s)
    

    illustrate:

    ​ View the logs of other nodes at this time

Notice:

Notice:

  • If the capacity of the mounted hard disk is not large enough, the following prompt will appear.

    Error: Unable to initialize backend: failed to load rebalance data: Storage resources are insufficient for the read operation .minio.sys/rebalance.bin, retrying in 4.452062213s (*fmt.wrapError)
    

    illustrate:

    It is necessary to increase the hard disk capacity, check whether the hard disk is mounted successfully, and change the hard disk mounting path.

Step 5: Use MinIo

Insert image description here

Notice:

  • If the node goes down during normal use, the following prompt will appear

    Storage resources are insufficient for the write operation .minio.sys/tmp/d74be3f0-856f-4532-802b-871b44204f2a/92c33006-b79a-4560-bd65-0f40cb810d63/part.1
    

    illustrate:

    At this point, please check using node service

Step 6: Create a load balancer

Prerequisite: Nginx service needs to be installed on the computer. Please check the log for details.

1. Modify the default.conf configuration file of nginx

upstream minio{
    server 10.13.165.121:9000;
    server 10.13.165.122:9000;
    server 10.13.165.125:9000;
    server 10.13.165.199:9000;
}
upstream console{
    ip_hash;
    server 10.13.165.121:9090;
    server 10.13.165.122:9090;
    server 10.13.165.125:9090;
    server 10.13.165.199:9090;
}

server {
    listen       8000;
    listen  [::]:8000;
    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       8080;
    listen  [::]:8080;
    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;

        proxy_pass http://console;
         
     }
}

illustrate:

The above is an example of an Nginx configuration file. The following is an explanation of the meaning of each configuration item:

  • listen: Specify the port number that Nginx listens on, here it is 9000, and use IPv6 [::]:9000to indicate listening for IPv6 and IPv4 requests at the same time.

  • server_name: Defines the domain name or hostname of this server block. Set here localhostto mean that requests with the requested domain name of localhost will be processed.

  • ignore_invalid_headers: Controls whether to ignore invalid request headers. The default is off, indicating not to ignore.

  • client_max_body_size: Defines the maximum size of the client request body. Setting to 0 means no file size limit.

  • proxy_buffering: Controls whether proxy buffering is enabled. The default is off, which means it is disabled.

  • location /: Define the request processing location of Nginx, here is the root directory /. Indicates that all requests will be processed according to the configuration of this location.

  • proxy_set_header: Set some variable values ​​in the request header, such as Host, X-Real-IP, X-Forwarded-Forand X-Forwarded-Protoetc.

  • proxy_connect_timeout: Set the timeout for establishing a connection with the backend server.

  • proxy_http_version: Specify the HTTP protocol version used to communicate with the backend server.

  • proxy_set_header Connection "";: Set the field in the request header Connectionto empty, indicating that the connection will not be maintained.

  • chunked_transfer_encoding: Controls whether to enable chunked transfer encoding, the default is off, which means disabled.

  • proxy_pass: Specifies the target server address for proxy forwarding, here http://minio, indicating that the request will be forwarded to miniothe backend server named.

Through the above configuration, Nginx will listen for requests on port 9000 and forward the requests to miniothe backend server named for processing. At the same time, you can also customize the request by setting the request header, timeout period, HTTP protocol version, etc.

2. Start Nginx

docker run \
-p 8000:8000 \
-p 8080:8080 \
--name nginx \
--restart=always \
-v /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /opt/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /opt/nginx/log:/var/log/nginx \
-v /opt/nginx/html:/usr/share/nginx/html \
-d nginx:latest

illustrate:

​ At this point, the nginx setup is completed. Visit http://10.13.165.121:8080/, http://10.13.165.121:8000/ and the agent will be successful.

Insert image description here

3.Interface usage

3.1 Obtain accessKey and secretKey

1.Create user
Insert image description here

2. Create a key

Insert image description here

Log

Reference documentation:

MinIO | High Performance, Kubernetes Native Object Storage

Minio SDKs - Python Client API Documentation - "Minio Cookbook Chinese Version" - BookStack.com · BookStack

minio/minio-py: MinIO Client SDK for Python (github.com)

Complete example - Java Photo API Service - "Minio Cookbook Chinese Version" - BookStack.com · BookStack

minio/minio: High Performance Object Storage for AI (github.com)

Notice:

When referring to the documentation, this is a pitfall. You need to refer to the English document because the Chinese document is not updated in time.

Docker install Nginx

Step 1: Create a directory

# 创建挂载目录
mkdir -p /opt/nginx/conf
mkdir -p /opt/nginx/log
mkdir -p /opt/nginx/html

Step 2: Add execution permissions

chmod 777 nginx

Step 3: Generate container

docker run --name nginx -p 9001:80 -d nginx

Step 4: Copy the nginx.conf file

docker cp nginx:/etc/nginx/nginx.conf /opt/nginx/conf/nginx.conf

Insert image description here

Step 5: Copy the conf.d folder

docker cp nginx:/etc/nginx/conf.d /opt/nginx/conf/conf.d

Insert image description here

Step 6: Copy the html folder

docker cp nginx:/usr/share/nginx/html /opt/nginx/

Insert image description here

Step 7: Delete the container

# 关闭该容器
docker stop nginx
# 删除该容器
docker rm nginx

Step 8: Rerun the container

docker run \
-p 8080:80 \
--name nginx \
--restart=always \
-v /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /opt/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /opt/nginx/log:/var/log/nginx \
-v /opt/nginx/html:/usr/share/nginx/html \
-d nginx:latest

Step 9: Access nginx through the browser

Insert image description here

Guess you like

Origin blog.csdn.net/D_boj/article/details/131117462
Recommended