4.5 KiB
4.5 KiB
本文作者:丁辉
Docker单机部署Ceph集群(无裸盘)
无压力 C+V 即可部署成功
-
创建Ceph专用网络
docker network create --driver bridge --subnet 172.20.0.0/16 ceph-network
-
拉取搭建用镜像
docker pull ceph/daemon:latest
-
搭建mon节点
docker run -d --name ceph-mon \ --restart=always \ --network ceph-network --ip 172.20.0.10 \ -e MON_NAME=ceph-mon \ -e MON_IP=172.20.0.10 \ -e CEPH_PUBLIC_NETWORK=172.20.0.0/16 \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest mon
-
禁用不安全认证
这个参数控制是否允许在集群中通过全局 ID 回收机制(global ID reclaim)来认证用户身份
docker exec ceph-mon ceph config set mon auth_allow_insecure_global_id_reclaim false
-
创建 osd 秘钥
docker exec ceph-mon ceph auth get client.bootstrap-osd -o /var/lib/ceph/bootstrap-osd/ceph.keyring
-
搭建 osd 节点
docker run -d --name ceph-osd-1 \ --privileged=true \ --restart=always \ --network ceph-network --ip 172.20.0.11 \ -e OSD_TYPE=directory \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /var/lib/ceph/osd/osd-1:/var/lib/ceph/osd \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest osd docker run -d --name ceph-osd-2 \ --privileged=true \ --restart=always \ --network ceph-network --ip 172.20.0.12 \ -e OSD_TYPE=directory \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /var/lib/ceph/osd/osd-2:/var/lib/ceph/osd \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest osd docker run -d --name ceph-osd-3 \ --privileged=true \ --restart=always \ --network ceph-network --ip 172.20.0.13 \ -e OSD_TYPE=directory \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /var/lib/ceph/osd/osd-3:/var/lib/ceph/osd \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest osd
-
搭建 mgr 节点
docker run -d --name ceph-mgr \ --restart=always \ --network ceph-network --ip 172.20.0.14 \ -p 7000:7000 \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest mgr
-
开启管理界面(查看此文档)
-
创建 rgw 秘钥
docker exec ceph-mon ceph auth get client.bootstrap-rgw -o /var/lib/ceph/bootstrap-rgw/ceph.keyring
-
搭建 rgw 节点
docker run -d --name ceph-rgw \ --restart=always \ --network ceph-network --ip 172.20.0.15 \ -p 7480:7480 \ -e RGW_NAME=ceph-rgw \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /etc/localtime:/etc/localtime:ro \ ceph/daemon:latest rgw
-
搭建 mds 节点
docker run -d --name ceph-mds \ --restart=always \ --network ceph-network --ip 172.20.0.16 \ -v /etc/ceph:/etc/ceph \ -v /var/lib/ceph/:/var/lib/ceph/ \ -v /var/log/ceph/:/var/log/ceph/ \ -v /etc/localtime:/etc/localtime:ro \ -e MDS_NAME=ceph-mds \ -e CEPHFS_CREATE=1 \ -e CEPHFS_NAME=cephfs \ -e CEPHFS_DATA_POOL=cephfs_data \ -e CEPHFS_DATA_POOL_PG=128 \ -e CEPHFS_METADATA_POOL=cephfs_metadata \ -e CEPHFS_METADATA_POOL_PG=64 \ ceph/daemon:latest mds
-
检查Ceph状态
docker exec ceph-mon ceph -s
挂载地址为:172.20.0.10:6789
卸载清理
-
清理容器
docker rm -f ceph-mon docker rm -f ceph-osd-1 docker rm -f ceph-osd-2 docker rm -f ceph-osd-3 docker rm -f ceph-mgr docker rm -f ceph-rgw docker rm -f ceph-mds
-
清理持久化目录
rm -rf {/etc/ceph,/var/lib/ceph,/var/log/ceph}
-
清理 Docker 网络
docker network rm ceph-network