Minio related configuration and problem record

Keywords: Programming vim network Docker Linux

First of all, Minio has written clearly and in Chinese on its website. https://docs.min.io/cn/

In the project, the OSS function needs to be replaced and implemented. The code corresponding to the original public cloud implementation has been encapsulated into a tool class, and the factory method mode is adopted. As long as the mini interface and implementation are added, and the implementation bean is replaced at runtime, no code needs to be modified for the client. This replacement implementation does not need to modify all API calls. It is simple, stable, error free, and easy to debug.

The following describes the installation of Minio stand-alone version

1. You can use docker run or binary mode

(1) docker run

#data directory and config directory need to be mapped
mkdir -p /mnt/data /mnt/config
#Use fixed version
docker run -d -p 9000:9000 \
    -e MINIO_ACCESS_KEY=Admin \
    -e MINIO_SECRET_KEY=Admin123 \
    -v /mnt/data:/data \
    -v /mnt/config:/root/.minio \
    minio/minio:RELEASE.2020-03-19T21-49-00Z \
    server /mnt/data

(2) Binary and system CTL self start

#1. Download binaries
wget https://dl.min.io/server/minio/release/linux-amd64/minio
#2. Prepare the data,bin,etc directory, and remember to cp the minio file above to / usr/local/minio/bin
mkdir -p /usr/local/minio/data /usr/local/minio/bin /usr/local/minio/etc
#3. Mini profile
#vim /usr/local/minio/etc/minio.conf
MINIO_VOLUMES="/usr/local/minio/data"
MINIO_OPTS="-C /usr/local/minio/etc --address **ip**:9000"
MINIO_ACCESS_KEY="Admin"
MINIO_SECRET_KEY="Admin123"

#4.systemctl service
#vim /etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/minio/bin/minio
[Service]
# User and group
# User=minio
# Group=minio
EnvironmentFile=/usr/local/minio/etc/minio.conf
ExecStart=/usr/local/minio/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=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
#5. Start service
systemctl daemon-reload && systemctl enable minio.service
systemctl start minio && systemctl status minio


Or as follows

#1. Download minio
#2. Create directory
# Data storage directory / data
# Configuration file directory / etc / Mini
mkdir -p /data/minio/{run,data} && mkdir -p /etc/minio
# The binary file mini and startup script are stored under / data / mini / run

#3. Startup script
#vim /data/minio/run/run.sh
#!/bin/bash
export MINIO_ACCESS_KEY=Admin
export MINIO_SECRET_KEY=Admin123
/data/minio/run/minio server --config-dir /etc/minio \
   http://**ip**:9000/data/minio/data 

#4.vim /etc/systemd/system/minio.service
cat > /etc/systemd/system/minio.service <<EOF
[Unit]
Description=Minio service
Documentation=https://docs.minio.io/
[Service]
WorkingDirectory=/data/minio/run/
ExecStart=/data/minio/run/run.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
#5. Modify permission, service file, binary file, startup script
chmod +x /etc/systemd/system/minio.service && chmod +x /data/minio/run/minio && chmod +x /data/minio/run/run.sh
#6. Start
systemctl daemon-reload && systemctl enable minio
systemctl start minio && systemctl status minio

2. Minio distributed deployment

The distributed deployment of Minio is very simple. At least four nodes are needed. Combined with the official website, I think the system CTL mode is adopted, which starts automatically with the system and is stable.

First, when preparing four machines or testing, you can have four directories on one server and two directories on each server.

#Four servers
192.168.1.5
192.168.1.6
192.168.1.7
192.168.1.8
#Create the corresponding directory / usr / local / mini / {data, bin, etc} on all servers
#Add environment variables on all services
#vim /etc/profile
export MINIO_ACCESS_KEY=Admin
export MINIO_SECRET_KEY=Admin123

source /etc/profile

Modify the mini.service file of each server in the stand-alone version. The mini server command automatically switches to stand-alone and cluster according to the following server list. This is very convenient.

#Modify mini.service
#vim /etc/systemd/system/minio.service
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/minio/bin/minio
[Service]
EnvironmentFile=/usr/local/minio/etc/minio.conf
ExecStart=/usr/local/minio/bin/minio server $MINIO_CLUSTER
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
[Install]
WantedBy=multi-user.target

After modifying the minio.conf file, increase the value of the Minio "cluster variable:

#vim /usr/local/minio/etc/minio.conf
MINIO_CLUSTER=http://192.168.1.5:9000/usr/local/minio/data http://192.168.1.6:9000/usr/local/minio/data http://192.168.1.7:9000/usr/local/minio/data http://192.168.1.8:9000/usr/local/minio/data

matters needing attention:

1. There must be 4 or more nodes here, otherwise the startup is not successful. The official said that the startup was started in the order of minio'u cluster, which was found to be unordered after testing.

Invalid command line arguments: Incorrect number of endpoints provided [http://192.168.1.5:9000/usr/local/minio/data http://192.168.1.6:9000/usr/local/minio/data]
      > Please provide an even number of endpoints greater or equal to 4

2. The environment variables Minio? Access? Key and Minio? Secret? Key must exist.

3. Use the mc client to operate. Here the api can be uploaded, but it can't be displayed according to the picture url. Then set the bucket permission through mc.

#1. Download mc
wget https://dl.min.io/client/mc/release/linux-amd64/mc
#2. Permission and set alias
chmod +x mc
alias mc="./mc"
#3. Add host
mc config host add client1 http://192.168.1.5:9000 Admin Admin123

mc ls client1

mc mb client1/bucketName1

#4. Set the permission to public
mc policy set public client1/bucketName1

4. When the distributed cluster is deployed, the first started server always reports an error

ERROR Unable to initialize backend: found backend fs, expected xl

The reason is that the current server has been deployed as a stand-alone version, resulting in unsuccessful cluster deployment. You need to clean up the original server configuration files and folders.

Posted by friedice on Mon, 20 Apr 2020 03:58:05 -0700