經過docker能夠快速部署小規模Ceph集羣的流程,可用於開發測試。
如下的安裝流程是經過linux shell來執行的;假設你只有一臺機器,裝了linux(如Ubuntu)系統和docker環境,那麼能夠參考如下步驟安裝Ceph:node
# 要用root用戶建立, 或有sudo權限 # 注: 建議使用這個docker鏡像源:https://registry.docker-cn.com # 1. 修改docker鏡像源 cat > /etc/docker/daemon.json << EOF { "registry-mirrors": [ "https://registry.docker-cn.com" ] } EOF # 關於鏡像, 這裏須要用到三個: ceph/mon, ceph/osd, ceph/radosgw # 若是下載不了的話,能夠嘗試下載我打包的: moxiaomomo/ceph-mon, moxiaomomo/ceph-osd, moxiaomomo/ceph-radosgw # 下載完以後,能夠重命名成官方鏡像名,好比: docker tag moxiaomomo/ceph-mon:latest ceph/mon:latest # 重啓docker systemctl restart docker # 2. 建立Ceph專用網絡 docker network create --driver bridge --subnet 172.20.0.0/16 ceph-network docker network inspect ceph-network # 3. 刪除舊的ceph相關容器 docker rm -f $(docker ps -a | grep ceph | awk '{print $1}') # 4. 清理舊的ceph相關目錄文件,加入有的話 rm -rf /www/ceph /var/lib/ceph/ /www/osd/ # 5. 建立相關目錄及修改權限,用於掛載volume mkdir -p /www/ceph /var/lib/ceph/osd /www/osd/ chown -R 64045:64045 /var/lib/ceph/osd/ chown -R 64045:64045 /www/osd/ # 6. 建立monitor節點 docker run -itd --name monnode --network ceph-network --ip 172.20.0.10 -e MON_NAME=monnode -e MON_IP=172.20.0.10 -v /www/ceph:/etc/ceph ceph/mon # 7. 在monitor節點上標識3個osd節點 docker exec monnode ceph osd create docker exec monnode ceph osd create docker exec monnode ceph osd create # 8. 建立OSD節點 docker run -itd --name osdnode0 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=monnode -e MON_IP=172.20.0.10 -v /www/ceph:/etc/ceph -v /www/osd/0:/var/lib/ceph/osd/ceph-0 ceph/osd docker run -itd --name osdnode1 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=monnode -e MON_IP=172.20.0.10 -v /www/ceph:/etc/ceph -v /www/osd/1:/var/lib/ceph/osd/ceph-1 ceph/osd docker run -itd --name osdnode2 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=monnode -e MON_IP=172.20.0.10 -v /www/ceph:/etc/ceph -v /www/osd/2:/var/lib/ceph/osd/ceph-2 ceph/osd # 9. 增長monitor節點,組件成集羣 docker run -itd --name monnode_1 --network ceph-network --ip 172.20.0.11 -e MON_NAME=monnode_1 -e MON_IP=172.20.0.11 -v /www/ceph:/etc/ceph ceph/mon docker run -itd --name monnode_2 --network ceph-network --ip 172.20.0.12 -e MON_NAME=monnode_2 -e MON_IP=172.20.0.12 -v /www/ceph:/etc/ceph ceph/mon # 10. 建立gateway節點 docker run -itd --name gwnode --network ceph-network --ip 172.20.0.9 -p 9080:80 -e RGW_NAME=gwnode -v /www/ceph:/etc/ceph ceph/radosgw # 11. 查看ceph集羣狀態 sleep 10 && docker exec monnode ceph -s
docker exec -it gwnode radosgw-admin user create --uid=draymonder --display-name=draymonder # 而後就獲得以下信息 { "user_id": "draymonder", "display_name": "draymonder", "email": "", "suspended": 0, "max_buckets": 1000, "auid": 0, "subusers": [], "keys": [ { "user": "draymonder", "access_key": "xxxxxxxxx", "secret_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxx" } ], "swift_keys": [], "caps": [], "op_mask": "read, write, delete", "default_placement": "", "placement_tags": [], "bucket_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "user_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "temp_url_keys": [] }
Docker簡單部署Ceph測試集羣 https://www.imooc.com/article/282861linux