docker安装minIO集群(一)
1. docker部署minio集群
- 准备2个节点,每个节点创建2个挂载点,由于集群模式下不能使用根磁盘,这里使用docker卷作为挂载点。
- 2节点的集群,故障一个节点时不影响对集群的读写操作。
2. 所有节点配置主机名解析:
- 两个节点执行以下命令
cat >> /etc/hosts << EOF
192.168.124.122 minio-1
192.168.124.129 minio-2
EOF
3. 创建数据卷
- 两个节点都要创建
docker volume create minio-data1
docker volume create minio-data2
docker volume ls // 查看所有容器卷
# docker volume minio-data2 // 查看指定容器卷详情信息
# docker stop minioyy // 暂停容器实例
# docker rm minioyy // 移除容器实例
# docker volume rm minio-data2 // 删除自定义数据卷
4. 部署minio集群,2个节点每个节点挂载2个目录
- minio-1节点执行
docker run -d --name minioyy \
--restart=always --net=host \
-e "MINIO_ROOT_USER=minioadmin" \
-e "MINIO_ROOT_PASSWORD=minioadmin" \
-v minio-data1:/data1 \
-v minio-data2:/data2 \
minio/minio:RELEASE.2021-06-14T01-29-23Z server \
--address 79.2.78.16:9000 \
http://minio-{1...2}/data{1...2}
- minio-2节点执行
docker run -d --name minioyy \
--restart=always --net=host \
-e "MINIO_ROOT_USER=minioadmin" \
-e "MINIO_ROOT_PASSWORD=minioadmin" \
-v minio-data1:/data1 \
-v minio-data2:/data2 \
minio/minio:RELEASE.2021-06-14T01-29-23Z server \
--address 79.2.78.17:9000 \
http://minio-{1...2}/data{1...2}
- 查看日志
docker logs -f minioyy
- 报错
API: SYSTEM()
Time: 02:59:08 UTC 11/18/2021
Error: Marking http://minio-1:9000/minio/storage/data2/v36 temporary offline; caused by Post "http://minio-1:9000/minio/storage/data2/v36/readall?disk-id=&file-path=format.json&volume=.minio.sys": dial tcp 192.168.124.122:9000: connect: no route to host (*fmt.wrapError)
6: internal/rest/client.go:147:rest.(*Client).Call()
5: cmd/storage-rest-client.go:151:cmd.(*storageRESTClient).call()
4: cmd/storage-rest-client.go:523:cmd.(*storageRESTClient).ReadAll()
3: cmd/format-erasure.go:406:cmd.loadFormatErasure()
2: cmd/format-erasure.go:326:cmd.loadFormatErasureAll.func1()
1: internal/sync/errgroup/errgroup.go:123:errgroup.(*Group).Go.func1()
- 原因是 防火墙没有开端口。
- 解决错误
firewall-cmd --permanent --zone=public --add-port=9000/tcp
firewall-cmd --state
firewall-cmd --reload
# 重启minio
docker restart minioyy
- 再次查看日志
docker logs -f minioyy
Exiting on signal: TERMINATED
Waiting for all MinIO sub-systems to be initialized.. lock acquired
All MinIO sub-systems initialized successfully
Waiting for all MinIO IAM sub-system to be initialized.. lock acquired
IAM initialization complete
Status: 4 Online, 0 Offline.
Endpoint: http://192.168.124.129:9000
Browser Access:
http://192.168.124.129: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
- 说明:docker部署集群模式时必须指定–net=host参数,使用主机网络,使用端口映射无法创建集群。
- 查看容器运行状态
[root@CentOS-7 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de5e0fd719c3 minio/minio:RELEASE.2021-06-14T01-29-23Z "/usr/bin/docker-ent…" 29 minutes ago Up 19 minutes minioyy
- 客户端查看minio状态,2个节点及每个节点上的Drivers全部在线:
5. 访问节点1 minio
- 浏览器访问http://192.168.124.122:9000
6. 登录,创建Bucket
- 创建Bucket: oss、model
7. 访问节点2 minio
- 浏览器访问http://192.168.124.129:9000
- 登录后发现数据已经同步到节点2了
- minio集群配置负载均衡请参考【minIO集群 配置负载均衡(二)】
https://blog.csdn.net/qq_38066812/article/details/122477348