docker安装minio

避坑指南

单机

参考文档:https://blog.csdn.net/BThinker/article/details/125412751

bash 复制代码
# 账号:miniouser
# 密码:miniopassword

# docker安装minio
docker run -d \
--restart=always \
--name minio \
-v /data/ememory/minio/data:/data \
-h minio \
-p 9000:9000 \
-p 9001:9001 \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server /data --address ":9000" --console-address ":9001"

联邦集群

Etcd
bash 复制代码
# 节点1
docker run -d \
-p 2379:2379 \
-p 2380:2380 \
--name etcd1 \
--network=etcd \
--restart=always \
-v /data/etcd/data:/var/lib/etcd \
quay.io/coreos/etcd:v3.5.9 \
etcd \
-name etcd1 \
-advertise-client-urls http://192.168.0.11:2379 \
-initial-advertise-peer-urls http://192.168.0.11:2380 \
-listen-client-urls http://0.0.0.0:2379 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster \
-initial-cluster "etcd1=http://192.168.0.11:2380,etcd2=http://192.168.0.12:2380,etcd3=http://192.168.0.13:2380,etcd4=http://192.168.0.14:2380" \
-initial-cluster-state new

# 节点2
docker run -d \
-p 2379:2379 \
-p 2380:2380 \
--name etcd2 \
--network=etcd \
--restart=always \
-v /data/etcd/data:/var/lib/etcd \
quay.io/coreos/etcd:v3.5.9 \
etcd \
-name etcd2 \
-advertise-client-urls http://192.168.0.12:2379 \
-initial-advertise-peer-urls http://192.168.0.12:2380 \
-listen-client-urls http://0.0.0.0:2379 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster \
-initial-cluster "etcd1=http://192.168.0.11:2380,etcd2=http://192.168.0.12:2380,etcd3=http://192.168.0.13:2380,etcd4=http://192.168.0.14:2380" \
-initial-cluster-state new

# 节点3
docker run -d \
-p 2379:2379 \
-p 2380:2380 \
--name etcd3 \
--network=etcd \
--restart=always \
-v /data/etcd/data:/var/lib/etcd \
quay.io/coreos/etcd:v3.5.9 \
etcd \
-name etcd3 \
-advertise-client-urls http://192.168.0.13:2379 \
-initial-advertise-peer-urls http://192.168.0.13:2380 \
-listen-client-urls http://0.0.0.0:2379 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster \
-initial-cluster "etcd1=http://192.168.0.11:2380,etcd2=http://192.168.0.12:2380,etcd3=http://192.168.0.13:2380,etcd4=http://192.168.0.14:2380" \
-initial-cluster-state new

# 节点4
docker run -d \
-p 2379:2379 \
-p 2380:2380 \
--name etcd4 \
--network=etcd \
--restart=always \
quay.io/coreos/etcd:v3.5.9 \
etcd \
-name etcd4 \
-advertise-client-urls http://192.168.0.14:2379 \
-initial-advertise-peer-urls http://192.168.0.14:2380 \
-listen-client-urls http://0.0.0.0:2379 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster \
-initial-cluster "etcd1=http://192.168.0.11:2380,etcd2=http://192.168.0.12:2380,etcd3=http://192.168.0.13:2380,etcd4=http://192.168.0.14:2380" \
-initial-cluster-state new

# 查看集群列表
docker exec etcd1 etcdctl member list

# 查看leader
docker exec etcd1 etcdctl  endpoint status --write-out=table
Minio
bash 复制代码
# 初始化 Swarm manager
# 如果有云服务占用了vxlan端口,所以需要重新设置端口
# docker swarm init --advertise-addr=192.168.0.11 --data-path-addr=192.168.0.11 --data-path-por=6666
docker swarm init --advertise-addr=192.168.0.11

# 结果如下
--------------------------------------------------------------------------------------------
Swarm initialized: current node (e6ub8sz10bepdy2gv3fa32unz) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-1lk8u55bvlr2xnkiztw78qbw56jzfm0lacphsiwo8gvkalydq2p5-ep378x98as8dy4skp8pv7o1ol 192.168.0.11:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
--------------------------------------------------------------------------------------------

# 将其他主机加入 Swarm 集群,依次在其他主机执行下面命令
docker swarm join --token SWMTKN-1-1lk8u55bvlr2xnkiztw78qbw56jzfm0lacphsiwo8gvkalydq2p5-ep378x98as8dy4skp8pv7o1ol 192.168.0.11:2377

# 创建 Overlay 网络
docker network create --driver overlay --attachable minio-cluster-1

# 创建完network之后先看一下网段信息
docker network inspect minio-cluster-1

# 确定网段,下面需要自定义ip地址
{
    "Subnet": "10.0.2.0/24",
    "Gateway": "10.0.2.1"
}

# 所有swarm节点需要设置端口
# 7946:用于容器网络发现
# 4789:用于容器覆盖网络
# firewall-cmd --zone=public --add-port=7946/tcp --permanent && firewall-cmd --reload
# firewall-cmd --zone=public --add-port=7946/udp --permanent && firewall-cmd --reload
# firewall-cmd --zone=public --add-port=4789/udp --permanent && firewall-cmd --reload

# 搭建集群
# 主机192.168.0.11:minio-1
# 主机192.168.0.12:minio-2
# 主机192.168.0.13:minio-3
# 主机192.168.0.14:minio-4
# minio-1
docker run -d \
--restart=always \
--network minio-cluster-1 \
--name minio-1 \
-v /data/minio/cluster1/data:/data \
--ip 10.0.2.11 \
-h minio-1 \
-p 9000:9000 \
-p 9001:9001 \
--add-host="minio-1:10.0.2.11" \
--add-host="minio-2:10.0.2.12" \
--add-host="minio-3:10.0.2.13" \
--add-host="minio-4:10.0.2.14" \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
-e "MINIO_ETCD_ENDPOINTS=http://192.168.0.11:2379,http://192.168.0.12:2379,http://192.168.0.13:2379,http://192.168.0.14:2379" \
-e "MINIO_PUBLIC_IPS=minio-1,minio-2,minio-3,minio-4" \
-e "MINIO_DOMAIN=mydomain.com" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server http://minio-{1...4}/data --address ":9000" --console-address ":9001"

# minio-2
docker run -d \
--restart=always \
--network minio-cluster-1 \
--name minio-2 \
-v /data/minio/cluster1/data:/data \
--ip 10.0.2.12 \
-h minio-2 \
-p 9000:9000 \
-p 9001:9001 \
--add-host="minio-1:10.0.2.11" \
--add-host="minio-2:10.0.2.12" \
--add-host="minio-3:10.0.2.13" \
--add-host="minio-4:10.0.2.14" \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
-e "MINIO_ETCD_ENDPOINTS=http://192.168.0.11:2379,http://192.168.0.12:2379,http://192.168.0.13:2379,http://192.168.0.14:2379" \
-e "MINIO_PUBLIC_IPS=minio-1,minio-2,minio-3,minio-4" \
-e "MINIO_DOMAIN=mydomain.com" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server http://minio-{1...4}/data --address ":9000" --console-address ":9001"

# minio-3
docker run -d \
--restart=always \
--network minio-cluster-1 \
--name minio-3 \
-v /data/minio/cluster1/data:/data \
--ip 10.0.2.13 \
-h minio-3 \
-p 9000:9000 \
-p 9001:9001 \
--add-host="minio-1:10.0.2.11" \
--add-host="minio-2:10.0.2.12" \
--add-host="minio-3:10.0.2.13" \
--add-host="minio-4:10.0.2.14" \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
-e "MINIO_ETCD_ENDPOINTS=http://192.168.0.11:2379,http://192.168.0.12:2379,http://192.168.0.13:2379,http://192.168.0.14:2379" \
-e "MINIO_PUBLIC_IPS=minio-1,minio-2,minio-3,minio-4" \
-e "MINIO_DOMAIN=mydomain.com" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server http://minio-{1...4}/data --address ":9000" --console-address ":9001"

# minio-4
docker run -d \
--restart=always \
--network minio-cluster-1 \
--name minio-4 \
-v /data/minio/cluster1/data:/data \
--ip 10.0.2.14 \
-h minio-4 \
-p 9000:9000 \
-p 9001:9001 \
--add-host="minio-1:10.0.2.11" \
--add-host="minio-2:10.0.2.12" \
--add-host="minio-3:10.0.2.13" \
--add-host="minio-4:10.0.2.14" \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
-e "MINIO_ETCD_ENDPOINTS=http://192.168.0.11:2379,http://192.168.0.12:2379,http://192.168.0.13:2379,http://192.168.0.14:2379" \
-e "MINIO_PUBLIC_IPS=minio-1,minio-2,minio-3,minio-4" \
-e "MINIO_DOMAIN=mydomain.com" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server http://minio-{1...4}/data --address ":9000" --console-address ":9001"


# 搭建单机minio测试etcd是否可行,在控制台新增bucket看其他minio集群是否可以看到
docker run -d \
--restart=always \
--name minio-test \
-h minio-test \
-p 9100:9000 \
-p 9200:9001 \
-e "MINIO_ROOT_USER=miniouser" \
-e "MINIO_ROOT_PASSWORD=miniopassword" \
-e "MINIO_ETCD_ENDPOINTS=http://192.168.0.11:2379,http://192.168.0.12:2379,http://192.168.0.13:2379,http://192.168.0.14:2379" \
-e "MINIO_PUBLIC_IPS=minio-test" \
-e "MINIO_DOMAIN=mydomain.com" \
minio/minio:RELEASE.2024-04-18T19-09-19Z.fips \
server /data --address ":9000" --console-address ":9001"

minio控制台

http://192.168.0.11:9001

http://192.168.0.12:9001

http://192.168.0.13:9001

http://192.168.0.14:9001

账号:miniouser

密码:miniopassword

其他

Minio数据迁移

bash 复制代码
# 创建一个临时的minio-client容器
docker run -it --rm --entrypoint /bin/sh bitnami/minio-client

# 源minio服务器
mc alias set source http://192.168.0.11:9000 miniouser miniopassword

# 目标minio服务器
mc alias set target http://xxx.xxx.x.xx:9000 miniouser miniopassword

# copy文件
mc cp --recursive source/bucket1/ target/bucket1/
相关推荐
秋邱3 小时前
高等教育 AI 智能体的 “导学诊践” 闭环
开发语言·网络·数据库·人工智能·python·docker
芥子沫3 小时前
日记应用推荐-Docker安装DailyNotes应用
docker·容器·日记
贝锐12 小时前
Docker部署Teemii本地漫画库,并通过花生壳内网穿透实现远程访问
docker
i***220715 小时前
springboot整合libreoffice(两种方式,使用本地和远程的libreoffice);docker中同时部署应用和libreoffice
spring boot·后端·docker
羑悻的小杀马特17 小时前
轻量跨云·掌控无界:Portainer CE + cpolar 让远程容器运维像点外卖一样简单——免复杂配置,安全直达对应集群
运维·网络·安全·docker·cpolar
EAIReport1 天前
企业级报表自动化:基于Docker的部署实践
运维·docker·自动化
cui_win1 天前
Docker Compose 部署一个完整的Prometheus监控告警系统
docker·容器·prometheus
ALex_zry1 天前
Docker Compose运维技术实战分享:从安装到架构解析
运维·docker·架构
roman_日积跬步-终至千里2 天前
【Docker】Docker Stop 后到底发生了什么?——从信号机制到优雅停机
运维·docker·容器
z***6262 天前
Docker:基于自制openjdk8镜像 or 官方openjdk8镜像,制作tomcat镜像
docker·容器·tomcat