New version configuration of MinIO

Posted by westen on Wed, 29 Sep 2021 04:37:03 +0200

Official documents

MinIO | The MinIO Quickstart Guide

Single node deployment

Deploy through binaries

# Normal direct pass
$ wget https://dl.min.io/server/minio/release/linux-amd64/minio
$ chmod +x minio
$ ./minio server /opt/data
# After startup, you will find that the user name and password are minioadmin by default, and the console listens to a dynamic port, which will change next time.

# Configure user name and password
$ export MINIO_ROOT_USER = admin
$ export MINIO_ROOT_PASSWORD = 12345678
# The default configuration directory is ${HOME}/.minio. You can customize the configuration directory through the -- config dir command
$ ./minio server -config-dir /mnt/config /opt/data
# The console listening port is generated dynamically. You can specify the static port through -- console address ": Port"
./minio server --console-address ":5000" /opt/data

Docker based

$ docker run -p 9000:9000 --name minio \
-v /opt/data:/data \
-v /opt/config:/root/.minio \
minio/minio server /data

There is a problem: the browser cannot access the minio console because there is no exposed console port

$ docker run -p 9000:9000 -p 5000:5000 --name minio \
-e "MINIO_ROOT_USER=admin" \
-e "MINIO_ROOT_PASSWORD=12345678" \
-v /opt/data:/data \
-v /opt/config:/root/.minio \
minio/minio server --console-address ":5000" /data

MinIO erasure code mode

MinIO uses erasure code and checksum to protect data from hardware failure and silent data damage. Even if you lose half (N/2) of your hard drives, you can still use them.

Erasure code is a mathematical algorithm for recovering lost and damaged data, MinIO use Reed-Solomon code Split objects into N/2 Data and N/2 Parity block. This means that if there are 12 hard disks, an object will be divided into 6 data blocks and 6 parity blocks. You can lose any 6 blocks (whether they store data or parity blocks), and you can still recover the data from the remaining disks.

Using the Minio Docker image, start the Minio service on 8 disks:

docker run -d -p 9000:9000 -p 5000:5000 --name minio \
-v /opt/data1:/data1 \
-v /opt/data2:/data2 \
-v /opt/data3:/data3 \
-v /opt/data4:/data4 \
-v /opt/data5:/data5 \
-v /opt/data6:/data6 \
-v /opt/data7:/data7 \
-v /opt/data8:/data8 \
minio/minio server /data{1...8} --console-address ":5000"

Distributed cluster deployment

Distributed Minio It allows you to combine multiple hard disks (even on different machines) into an object storage service. Since hard disks are distributed on different nodes, distributed Minio Single point of failure is avoided.

Distributed Minio advantages

data protection

Distributed Minio Erasure code is used to prevent multiple node downtime and bit attenuation bit rot. 
Distributed Minio At least four hard disks are required and distributed Minio The function of erasure code is automatically introduced.

High availability

A single node has a single point of failure. On the contrary, if it is a single node with N Block hard disk distributed MinIO,As long as there is N/2 If a hard disk is online, your data is safe. But you need to have N/2 + 1 A hard disk to create a new object.
For example, a 16 node MinIO Cluster, 16 hard disks per node. Even if 8 servers are down, the cluster is still readable, but 9 servers are required to write data

uniformity

MinIO In distributed and stand-alone mode, all read and write operations are strictly followed read-adter-write Consistency model

Running distributed MioIO

To start a distributed MinIO instance, you only need to pass the hard disk location as a parameter to the minio server command, and then you need to run the same command on other nodes.

  • All nodes in distributed minio need the same access key and secret key so that these nodes can establish a connection. To achieve this, you need to export the access key and secret key into environment variables before executing the minio server command. The new version uses minio_ ROOT_ USER & minio_ ROOT_ PASSWORD.

  • The disk used by distributed minio must be clean and there is no data in it.

  • The IP in the following example is for reference only. You need to change it to the IP and folder path you really use.

  • The node time difference in distributed minio cannot exceed 3 seconds. NTP can be used to ensure time consistency.

  • Running distributed minio under Windows is in an experimental stage.

There are 8 nodes and 1 hard disk for each node. You need to run the following commands on each node

export MINIO_ROOT_USER = admin
export MINIO_ROOT_PASSWORD = 12345678
minio server http://192.168.1.11/export1 http://192.168.1.12/export2 \
 http://192.168.1.13/export3 http://192.168.1.14/export4 \
 http://192.168.1.15/export5 http://192.168.1.16/export6 \
 http://192.168.1.17/export7 http://192.168.1.18/export8 \

4 nodes, 4 hard disks per node

export MINIO_ROOT_USER = admin
export MINIO_ROOT_PASSWORD = 12345678
minio server http://192.168.1.11/export1 http://192.168.1.11/export2
 http://192.168.1.11/export3 http://192.168.1.11/export4
 http://192.168.1.12/export1 http://192.168.1.12/export2
 http://192.168.1.12/export3 http://192.168.1.12/export4
 http://192.168.1.13/export1 http://192.168.1.13/export2
 http://192.168.1.13/export3 http://192.168.1.13/export4
 http://192.168.1.14/export1 http://192.168.1.14/export2
 http://192.168.1.14/export3 http://192.168.1.14/export4

export MINIO_ROOT_USER = admin
export MINIO_ROOT_PASSWORD = 12345678
MINIO_HOME = /usr/local/soft
MINIO_HOST = 192.168.3.14
for i in {01..04}; do
  nohup ${MINIO_HOME}/minio server --address ":90${i}" --console-address ":50${i}" http://${MINIO_HOST}:9001/mnt/data01 http://${MINIO_HOST}:9002/mnt/data02 http://${MINIO_HOST}:9003/mnt/data03 http://${MINIO_HOST}:9004/mnt/data04 > ${MINIO_HOME}/minio-90${i}.log 2>&1 &
done

Implementation of loadbalance based on nginx

upstream minio {
    server 192.168.33.161:9000;
    server 192.168.33.162:9000;
    server 192.168.33.163:9000;
    server 192.168.33.164:9000;
}

upstream console {
    ip_hash;
    server 192.168.33.161:5000;
    server 192.168.33.162:5000;
    server 192.168.33.163:5000;
    server 192.168.33.164:5000;
}

server {
    listen      9000;
    server_name localhost;

    ignore_invalid_headers  off;
    client_max_body_size    0;
    proxy_buffering         off;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $http_x_forwarded_proto;

        proxy_connect_timeout   300;
        proxy_http_version      1.1;
        chunked_transfer_encoding   off;
        proxy_ignore_client_abort   on;

        proxy_pass  http://minio;
    }
}

server {
    listen      5000;
    server_name localhost;

    ignore_invalid_headers  off;
    client_max_body_size    0;
    proxy_buffering         off;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto  $http_x_forwarded_proto;

        proxy_connect_timeout   300;
        proxy_http_version      1.1;
        chunked_transfer_encoding   off;
        proxy_ignore_client_abort   on;

        proxy_pass  http://console;
    }
}

MinIO client mc usage

MinIO Client (mc) by ls,cat,cp,mirror,diff,find etc. UNIX The command provides an alternative. It supports file systems and compatibility Amazon S3 Cloud storage services (AWS Signature v2 and v4). 

ls            List files and folders
mb            Create a bucket or folder
cat           Display file and object contents
pipe          Will one STDIN Redirect to an object or file STDOUT. 
share         Generate for sharing URL. 
cp            Copy files and objects
mirror        Mirror buckets and folders
find          Find files based on parameters
diff          Compare the difference between two folders or buckets
rm            Delete folder or object
enents        Manage object notifications
watch         Monitor events for files and objects
policy        Manage access policies
config        Administration mc configuration file
update        Check for software updates
version       Output version information

Deploy client mc

$ wget http://dl.minio.org.cn/client/mc/release/linux-amd64/mc
$ chmod +x mc
$ ./mc --help

Configure mc

mc stores all configuration information in the ~ /. minio/config.json file

# Query mc host configuration
$ mc config host ls
# Add minio service
$ mc config host add minio-server http://192.168.33.160:9000 admin 12345678
# Delete host
$ mc config host remove minio-server

Refer to the official document for the specific command operation of mc.

Topics: server