concept
Erasure Coding
Erasure Coding splits data into data and parity shards. For example, MinIO might use a 4:2 erasure code (should use 6 disks), meaning each object is split into 4 data shards and 2 parity shards.
In a 4:2 erasure coding setup:
4 data shards hold the actual object data.
2 parity shards are created for redundancy.
In this configuration, every object is broken into smaller pieces, with redundancy pieces (parity shards) stored to allow recovery if a disk or node fails.
server
1 | service file |
minio.service
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
27
28
29
30
31
32
33
34
35
36
37
38[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
Type=notify
WorkingDirectory=/usr/local
User=dingofs
Group=dingofs
ProtectProc=invisible
EnvironmentFile=-/etc/default/minio
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=1048576
# Turn-off memory accounting by systemd, which is buggy.
MemoryAccounting=no
# Specifies the maximum number of threads this process can create
TasksMax=infinity
# Disable timeout logic and wait until process is stopped
TimeoutSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target/etc/default/minio
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
27
28MINIO_VOLUMES="http://minio{1...3}.dev.net:19000/mnt/disk2/minio"
#MINIO_VOLUMES="http://minio{1...3}.dev.net:19000/mnt/disk{0...1}/minio"
#MINIO_VOLUMES="http://minio1.dev.net:19000/mnt/disk1/minio http://minio2.dev.net:19000/mnt/disk1/minio http://minio3.dev.net:19000/mnt/disk1/minio"
#MINIO_VOLUMES="http://minio2.dev.net:19000/mnt/minio http://minio3.dev.net:19000/mnt/minio"
# Set all MinIO server options
#
# The following explicitly sets the MinIO Console listen address to
# port 9001 on all network interfaces. The default behavior is dynamic
# port selection.
#MINIO_OPTS="--console-address :9001"
MINIO_OPTS=' --console-address=":19001" --address=":19000" '
# Set the root username. This user has unrestricted permissions to
# perform S3 and administrative API operations on any resource in the
# deployment.
#
# Defer to your organizations requirements for superadmin user name.
MINIO_ROOT_USER=minioadmin
# Set the root password
#
# Use a long, random, unique string that meets your organizations
# requirements for passwords.
MINIO_ROOT_PASSWORD=minioadmin
client
install
1 | curl https://dl.min.io/client/mc/release/linux-amd64/mc \ |
command
- log
1 | mc admin logs myminio |
- development
1 | add development |
bucket
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
27create bucket
mc mb <ALIAS>/<BUCKET>
list bucket
mc ls <ALIAS>
check bucket
mc ls <ALIAS>/<BUCKET>
count total object/file num
mc ls --summarize --recursive gateway-minio
check object
mc cat <ALIAS>/<BUCKET>/<OBJECT>
delete object
mc rm <ALIAS>/<BUCKET>/<OBJECT>
delete according specify time
mc find <alias/bucket-name> --older-than <time> --exec "mc rm {}"
e.g. mc find myminio/mybucket --older-than 30d --exec "mc rm {}"
delete all data
mc rm --recursive --force <ALIAS>/<BUCKET>
force delete bucket
mc rb --force <ALIAS>/<BUCKET> # must delete bucket's object file firstheal
1 | Use MinIO’s heal command to ensure the data and metadata are consistent: |
- erasure code
1 | set erasure code |
TLS
172.20.61.102 minio1.dev.net
172.20.61.103 minio2.dev.net
172.20.61.105 minio3.dev.net/etc/default/minio:
MINIO_VOLUMES=”https://minio{1...3}.dev.net:19000/mnt/minio{1...2}"
MINIO_OPTS=’ –console-address=”:19001” –address=”:19000” ‘
By default, the MinIO server looks for the TLS keys and certificates for each node in the following directory: ${HOME}/.minio/certs
(该证书存放各自机器的private.key
和 public.crt
, 每台机器的 private.key
和 public.crt
都不一样)
If using Certificates signed by a non-global or non-public Certificate Authority, or if using a global CA that requires the use of intermediate certificates, you must provide those CAs to the MinIO Server /root/.minio/certs/CAs
(用来存放私有的证书ca.crt
,该证书用于生成机器的private.key
和 public.crt
, 集群的每台机器存放的ca.crt
应该保持一致)
- Generate CA and Certificates
generate_certificate.sh
1 | # Generate CA private key |
Distribute Certificates
copy_certificate.sh
1
2
3
4
5
6
7
8
9# Create certificate directories
for node in minio1 minio2 minio3; do
# Copy node-specific certificate and key
scp ${node}.crt root@${node}.dev.net:/root/.minio/certs/public.crt
scp ${node}.key root@${node}.dev.net:/root/.minio/certs/private.key
# Copy CA certificate to trusted CAs
scp ca.crt root@${node}.dev.net:/root/.minio/certs/CAs/
doneUpdate MinIO Configuration
Modify/etc/default/minio
on each node to ensure proper TLS configuration:1
2# Update MINIO_VOLUMES to use https
MINIO_VOLUMES="https://minio{1...3}.dev.net:19000/mnt/minio{1...2}"Set Correct Permissions (optional)
1
2
3
4
5
6
7
8for node in minio1 minio2 minio3; do
ssh root@${node}.dev.net "
chown -R minio:minio /root/.minio/certs
chmod 700 /root/.minio/certs
chmod 600 /root/.minio/certs/private.key
chmod 644 /root/.minio/certs/public.crt /root/.minio/certs/CAs/*
"
doneRestart MinIO Cluster
1
2systemctl daemon-reload
systemctl restart minioTrust certificate globally
每台机器均需要操作一遍(这样可以保证mc设置alias成功)
1 | sudo cp ca.crt /etc/pki/ca-trust/source/anchors/ |
- Verification
1 | # Check TLS configuration on each node |
browser check