由於博客改造,新增相冊模塊,需要一個相對安全的文件存儲。
選擇 minio 的原因
- 因為比
fastDFS
用起來方便點 - 和 Golang 相性很好
結構#
- 單機多硬盤
- 一主一從,不同硬盤
直接 docker-compose
version: '3.7'
# starts 2 docker containers running minio server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
services:
minio1:
container_name: minio1
image: minio/minio:RELEASE.2021-06-07T21-40-51Z
hostname: minio1
volumes:
- /硬盤1/data1:/data1
- /硬盤1/data2:/data2
ports:
- "29001:9000"
restart: always
environment:
MINIO_ROOT_USER: 賬號
MINIO_ROOT_PASSWORD: 密碼
MINIO_PROMETHEUS_AUTH_TYPE: public
command: server http://minio{1...2}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
minio2:
container_name: minio2
image: minio/minio:RELEASE.2021-06-07T21-40-51Z
hostname: minio2
volumes:
- /硬盤2/data1:/data1
- /硬盤2/data2:/data2
ports:
- "29002:9000"
restart: always
environment:
MINIO_ROOT_USER: 賬號
MINIO_ROOT_PASSWORD: 密碼
MINIO_PROMETHEUS_AUTH_TYPE: public
command: server http://minio{1...2}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
然後啟動
sudo docker-compose up --no-start
sudo docker-compose start
nginx#
nginx 直接 proxy_pass 兩個 upstream 即可