banner
NEWS LETTER

Docker单机部署Ceph集群(无裸盘)

Scroll down

本文作者:丁辉

Docker单机部署Ceph集群(无裸盘)

无压力 C+V 即可部署成功

  1. 创建Ceph专用网络

    1
    docker network create --driver bridge --subnet 172.20.0.0/16 ceph-network
  2. 拉取搭建用镜像

    1
    docker pull ceph/daemon:latest
  3. 搭建mon节点

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    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
  4. 禁用不安全认证

    这个参数控制是否允许在集群中通过全局 ID 回收机制(global ID reclaim)来认证用户身份

    1
    docker exec ceph-mon ceph config set mon auth_allow_insecure_global_id_reclaim false
  5. 创建 osd 秘钥

    1
    docker exec ceph-mon ceph auth get client.bootstrap-osd -o /var/lib/ceph/bootstrap-osd/ceph.keyring
  6. 搭建 osd 节点

    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
    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
  7. 搭建 mgr 节点

    1
    2
    3
    4
    5
    6
    7
    8
    9
    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
  8. 开启管理界面(查看此文档)

    MGR开启监控管理界面

  9. 创建 rgw 秘钥

    1
    docker exec ceph-mon ceph auth get client.bootstrap-rgw -o /var/lib/ceph/bootstrap-rgw/ceph.keyring
  10. 搭建 rgw 节点

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    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
  11. 搭建 mds 节点

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    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
  12. 检查Ceph状态

    1
    docker exec ceph-mon ceph -s

    挂载地址为:172.20.0.10:6789

卸载清理

  1. 清理容器

    1
    2
    3
    4
    5
    6
    7
    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
  2. 清理持久化目录

    1
    rm -rf {/etc/ceph,/var/lib/ceph,/var/log/ceph}
  3. 清理 Docker 网络

    1
    docker network rm ceph-network

I'm so cute. Please give me money.

其他文章
cover
Ceph挂载文件系统
  • 70/01/01
  • 00:00
  • Kubernetes-存储
cover
Docker部署高可用Ceph集群
  • 70/01/01
  • 00:00
  • Kubernetes-存储
目录导航 置顶
  1. 1. Docker单机部署Ceph集群(无裸盘)
  2. 2. 卸载清理
请输入关键词进行搜索