Minio 提供了两种部署方式:单机部署和分布式。以上两种部署方式都非常简单,其中分布式部署还提供了纠删码功能来降低数据丢失的风险。本章节将介绍 MinIO 单机部署。
Docker 中,MinIO 需要一个持久卷来存储配置和应用数据。不过,如果只是为了测试一下,可以通过简单地传递一个目录(在下面的示例中为 /root/data)启动 MinIO。这个目录会在容器启动时在容器的文件系统中创建,不过所有的数据都会在容器退出时丢失。
启动 MinIO 命令如下:
[root@localhost ~]# docker run -p 9000:9000 minio/minio server /root/data No credential environment variables defined. Going with the defaults. It is strongly recommended to define your own credentials via environment variables MINIO_ROOT_USER and MINIO_ROOT_PASSWORD instead of using default values Endpoint: http://172.17.0.2:9000 http://127.0.0.1:9000 Browser Access: http://172.17.0.2:9000 http://127.0.0.1:9000 Object API (Amazon S3 compatible): Go: https://docs.min.io/docs/golang-client-quickstart-guide Java: https://docs.min.io/docs/java-client-quickstart-guide Python: https://docs.min.io/docs/python-client-quickstart-guide JavaScript: https://docs.min.io/docs/javascript-client-quickstart-guide .NET: https://docs.min.io/docs/dotnet-client-quickstart-guide Detected default credentials 'minioadmin:minioadmin', please change the credentials immediately by setting 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment values IAM initialization complete
要创建具有永久存储的 MinIO 容器,您需要将本地持久目录从主机操作系统映射到虚拟配置 ~/.minio 并导出 /root/data 目录。为此,请运行以下命令:
[root@localhost ~]# docker run -p 9000:9000 --name minio1 \ > -v /root/data:/data \ > -v /root/config:/root/.minio \ > minio/minio server /data No credential environment variables defined. Going with the defaults. It is strongly recommended to define your own credentials via environment variables MINIO_ROOT_USER and MINIO_ROOT_PASSWORD instead of using default values Endpoint: http://172.17.0.2:9000 http://127.0.0.1:9000 Browser Access: http://172.17.0.2:9000 http://127.0.0.1:9000 Object API (Amazon S3 compatible): Go: https://docs.min.io/docs/golang-client-quickstart-guide Java: https://docs.min.io/docs/java-client-quickstart-guide Python: https://docs.min.io/docs/python-client-quickstart-guide JavaScript: https://docs.min.io/docs/javascript-client-quickstart-guide .NET: https://docs.min.io/docs/dotnet-client-quickstart-guide Detected default credentials 'minioadmin:minioadmin', please change the credentials immediately by setting 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment values IAM initialization complete
此时,我们访问 MinIO 且创建 images 桶和上传两张图片到 images 桶。查看本机 /root/data 目录,如下:
[root@localhost data]# tree . . └── images ├── 20210704171301.jpg └── 20210704173839.jpg 1 directory, 2 files [root@localhost data]#