最近团队的小伙伴做了一个Minio的应用,顺道我最近在搞数据库备份相关的插件,就寻思把备份上传到Minio上。

其实,官方的文档已经很具体了,这里我就列出怎么简单使用,后面有时间在深入介绍一下,与我们平台的最佳实践吧。 MINIO Docs

Minio Server

基于测试,本文使用docker-compose.yaml和caddy

# docker-compose.yaml
version: '2.1'
services:
  caddy:
    image: spanda/caddy
    container_name: caddy
    volumes:
    - ./ssl:/root/.caddy
    - /var/log/caddy:/var/log/caddy
    - ./domain/Caddyfile:/etc/Caddyfile
    - ./domain/website:/proxy/data
    - /root/.ssh:/root/.ssh
    network_mode: host
    restart: always
  minio:
    image: minio/minio
    container_name: minio
    command: server /data
    volumes:
    - ./minio/data:/data
    - ./minio/etc:/root/.minio
    network_mode: host
    restart: always

# Caddyfile
s3.pt.spanda.io {
    gzip
    log / /var/log/caddy/s3.pt.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
   	rotate_size 50
	rotate_age  90
	rotate_keep 20
	rotate_compress
    }
    tls root@ysicing.net
    header / {
    	Strict-Transport-Security "max-age=31536000;includeSubDomains;preload"
	    -Server
	}
    proxy / 10.10.10.2:9000 {
        header_upstream X-Forwarded-Proto {scheme}
        header_upstream X-Forwarded-Host {host}
        header_upstream Host {host}
        health_check /minio/health/ready
    }
}

MINIO CLIENT

客户端简单使用.

安装客户端cli工具 mc

# For macOS
brew install minio/stable/mc
mc --help

# For Linux
curl -L  https://dl.minio.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
chmod u+x /usr/local/bin/mc
mc --help

本地添加远端存储

mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> --api <API-SIGNATURE> --lookup <BUCKET-LOOKUP-TYPE>

其中API-SIGNATUREBUCKET-LOOKUP-TYPE可省却,分别有默认值S3v4auto,另外默认配置有

➜  ~ mc config host list
gcs       :  https://storage.googleapis.com  YOUR-ACCESS-KEY-HERE  YOUR-SECRET-KEY-HERE                      S3v2   dns
local     :  http://localhost:9000                                                                                  auto
play      :  https://play.minio.io:9000      Q3AM3UQ867SPQQA43P2F  zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG  S3v4   auto
s3        :  https://s3.amazonaws.com        YOUR-ACCESS-KEY-HERE  YOUR-SECRET-KEY-HERE                      S3v4   dns

那么添加刚刚我们搭建的minio服务

➜  ~ mc config host add google https://s3.pt.spanda.io Iebae5aiThei1vi8yie6eireeghaquae Veeshohr4AeLee8raiphe0aeZ5Choac8
Added `google` successfully.

列出当前所有

➜  ~ mc config host list
gcs       :  https://storage.googleapis.com  YOUR-ACCESS-KEY-HERE             YOUR-SECRET-KEY-HERE                      S3v2   dns
google    :  https://s3.pt.spanda.io         Iebae5aiThei1vi8yie6eireeghaquae Veeshohr4AeLee8raiphe0aeZ5Choac8          s3v4   auto
local     :  http://localhost:9000                                                                                             auto
local-test:  http://9000.gra24dc1.8gotq1...  access_key                       da2edbc3                                  s3v4   auto
play      :  https://play.minio.io:9000      Q3AM3UQ867SPQQA43P2F             zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG  S3v4   auto
s3        :  https://s3.amazonaws.com        YOUR-ACCESS-KEY-HERE             YOUR-SECRET-KEY-HERE                      S3v4   dns

默认的配置都是保存在~/.mc/config.json

创建 bucket

➜  ~ mc ls google
[2018-04-26 23:35:19 CST]     0B google/ #通过ui创建的
➜  ~ mc mb google/baidu
Bucket created successfully `google/baidu`.
➜  ~ mc ls google
[2018-04-26 23:51:40 CST]     0B baidu/
[2018-04-26 23:35:19 CST]     0B google/

cp 操作

➜  ~ mc cp ~/Music/QQ音乐/徐良-花魁.mp3 google/baidu
[0] ◐ /Users/ysicing/Music/QQ音乐/徐良-花魁.mp3                                                                                                                                                            
...usic/QQ音乐/徐良-花魁.mp3:  1.51 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   42.67% 11.99 M
...usic/QQ音乐/徐良-花魁.mp3:  1.79 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   50.50% 4.73 M
...usic/QQ音乐/徐良-花魁.mp3:  2.35 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░   66.38% 4.66 M
...usic/QQ音乐/徐良-花魁.mp3:  3.21 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░░░░░░░░░░░   90.76% 5.11 M
...usic/QQ音乐/徐良-花魁.mp3:  3.46 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░░   97.71% 4.58 M
...usic/QQ音乐/徐良-花魁.mp3:  3.47 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░   98.04% 588.61 K
...usic/QQ音乐/徐良-花魁.mp3:  3.54 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100.00% 369.50 K
...usic/QQ音乐/徐良-花魁.mp3:  3.54 MB / 3.54 MB  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100.00% 297.50 KB/s 12s%
➜  ~

效果图

安利应用

最后,可以在我们平台体验一下 Minio,私有云用户也可以哦,同步一下应用即可。