使用minio做对象存储

[TOC]

安装docker-ce

 dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
 dnf list docker-ce --showduplicates | sort -r
 #指定版本
 dnf install  docker-ce-3:18.09.0-3.el7  

启动minio

 docker run -d  \
 -p 9000:9000 \
 --name myminio   \
 -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" \
 -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
 -e "MINIO_DOMAIN=mlcloud.minio" \
 -v /myminio:/data  \
 minio/minio server /data 

  1. 映射端口9000
  2. 指定访问密钥
  3. 使用域名访问需要配置环境变量MINIO_DOMAIN
  4. 使用本地的/myminio目录做存储

nginx 代理转发

 server {
        listen 80;
        server_name  mlcloud.minio  *.mlcloud.minio;
        # 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_http_version 1.1;
            proxy_set_header Host $http_host;
            # proxy_ssl_session_reuse on; # enable this if you are internally connecting over SSL
            proxy_read_timeout 15m; # Default value is 60s which is not sufficient for MinIO.
            proxy_send_timeout 15m; # Default value is 60s which is not sufficient for MinIO.
            proxy_request_buffering off; # Disable any internal request bufferring.
            proxy_pass http://localhost:9000; # If you are using docker-compose this would be the hostname i.e. minio
            # Health Check endpoint might go here. See https://www.nginx.com/resources/wiki/modules/healthcheck/
            # /minio/health/ready;
        }
    }

s3cmd

yum install s3cmd

➜  ~ cat /etc/hosts|grep minio
192.168.8.73 mlcloud.minio

➜  ~ cat .s3cfg
# 设置endpoint
host_base = mlcloud.minio:9000
host_bucket = mlcloud.minio:9000
bucket_location = us-east-1
use_https = False

# 设置access key和secret key
access_key = AKIAIOSFODNN7EXAMPLE
secret_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

# 启用S3 v4版本签名API
signature_v2 = False

➜  ~ s3cmd ls
2021-04-14 09:53  s3://test
➜  ~ s3cmd ls s3://test
                          DIR  s3://test/block/
                          DIR  s3://test/inode/
                          DIR  s3://test/map/
                          DIR  s3://test/mulang/
                          DIR  s3://test/sqlite/
                          DIR  s3://test/statistics/

更新20210728

docker 启动最新的镜像,需要指定控制台端口.

docker run \
  -p 9000:9000 \
  -p 9001:9001 \
  -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
  -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
  minio/minio server /data --console-address ":9001"

minio-docker-quickstart-guide

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.