minio
部署 minio 非常灵活,以下是常用配置参数:
binary deploy
使用二进制部署
1 2 3
| wget -O /usr/local/bin/minio https://dl.min.io/server/minio/release/linux-amd64/minio chmod +x /usr/local/bin/minio minio server /data
|
docker deploy
使用 docker 命令部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| export MINIO_ROOT_USER=minio export MINIO_ROOT_PASSWORD=minio123 export MINIO_ADDRESS_PORT=9000 export MINIO_CONSOLE_PORT=9001 export MINIO_DOCKER_NAME=minio export MINIO_BUCKET=bucket_name docker run -p $MINIO_ADDRESS_PORT:9000 -p $MINIO_CONSOLE_PORT:9001 --name $MINIO_DOCKER_NAME \ -d --restart=always \ -e MINIO_ROOT_USER=$MINIO_ROOT_USER \ -e MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD \ -v .data:/data \ -v .minio:/root/.minio \ minio/minio server /data --address ":9000" --console-address ":9001"
docker run --rm --link $MINIO_DOCKER_NAME -e MINIO_BUCKET=$MINIO_BUCKET --entrypoint sh minio/mc -c "\ while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \ sleep 5 && \ mc config host add myminio http://minio:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD && \ if ! mc ls myminio | grep --quiet $MINIO_BUCKET; then mc mb myminio/$MINIO_BUCKET; else echo 'bucket $MINIO_BUCKET already exists'; fi && \ mc mb myminio/$MINIO_BUCKET && \ mc policy download myminio/$MINIO_BUCKET \ "
|
docker-compose deploy
使用 docker-compose 部署,参考如下:
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 39 40 41 42
| services: minio: image: minio/minio:RELEASE.2023-06-02T23-17-26Z ports: - ${MINIO_ADDRESS_PORT:-9000}:9000 - ${MINIO_CONSOLE_PORT:-9001}:9001 environment: MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minio} MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minio123} command: server /data --address ":9000" --console-address ":9001" healthcheck: test: [ "CMD", "curl", "-f", "http://minio:9000/minio/health/live" ] interval: 10s timeout: 10s retries: 3
create_models_buckets: image: minio/mc:RELEASE.2023-05-30T22-41-38Z depends_on: minio: condition: service_healthy entrypoint: > bash -c 'mc config host add myminio http://minio:9000 ${MINIO_ROOT_USER:-minio} ${MINIO_ROOT_PASSWORD:-minio123}; if ! mc ls myminio | grep --quiet models; then mc mb myminio/models; else echo "bucket models already exists in host myminio"; fi; mc anonymous set public myminio/models; exit 0;'
|
使用环境变量配置启动端口
1
| MINIO_ADDRESS_PORT=9999 docker-compose up --remove-orphans -V
|
mc
1,连接服务(hellominio)
1 2 3
| mc config host add hellominio http://minio:9001 minio minio123
|
2,创建策略 (readwrite)
1 2 3 4
| mc admin policy add hellominio readwrite readwrite.json
|
3, 创建用户 密码必须为 8 位以上 (用户名 hello 密码 hello123123)
1 2 3
| mc admin user add hellominio hello hello123123
|
4,成功创建用户后, 为该用户应用策略(readwrite)。
1 2 3 4
| mc admin policy set hellominio readwrite user=hello
|
5, 创建分组 (hellominiogroup)
1 2 3
| mc admin group add hellominio hellominiogroup hello
|
6, 成功创建组后,对该组应用策略。
1 2 3
| mc admin policy set hellominio readwrite group=newgroup
|
7,更改权限后 需重新导入
1 2 3
| mc admin policy add hellominio readwrite readwrite.json
|