前提先安装好docker
本次实验环境为:操作系统macos docker版本
docker pull ceph/osd
docker pull ceph/mon
sudo docker network create --driver bridge --subnet 172.20.0.0/16 ceph-network
sudo mkdir -p /etc/ceph /var/lib/ceph/ /var/log/ceph/
sudo chmod -R 777 /etc/ceph /var/lib/ceph/ /var/log/ceph/
docker run -itd --name mymon --network ceph-network --ip 172.20.0.10 -e MON_NAME=mymon -e MON_IP=172.20.0.10 -v /etc/ceph:/etc/ceph ceph/mon
添加配置vim /etc/ceph/ceph.conf
在文件末尾添加:
osd journal size = 100
osd pool default pg num = 8
osd pool default pgp num = 8
osd pool default size = 2
osd pool default min size =1
osd max object name len = 256
osd max object namespace len = 64
public network = 172.20.0.0/24
cluster network = 172.20.0.0/24
docker exec mymon ceph osd create
docker run -itd --name osd0 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=mymon -e MON_IP=172.20.0.10 -v /etc/ceph:/etc/ceph -v /var/lib/ceph/osd/0:/var/lib/ceph/osd/ceph-0 ceph/osd
注意:这里的挂载目录 /var/lib/ceph/osd/0是我自己创建的
可以自定义创建一个文件夹作为挂载点
记得将这个文件夹授权: chmod -R 777 文件夹绝对路径
docker exec -it mymon ceph -s
docker exec mymon ceph osd create
docker run -itd --name osd1 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=mymon -e MON_IP=172.20.0.10 -v /etc/ceph:/etc/ceph -v /var/lib/ceph/osd/1:/var/lib/ceph/osd/ceph-1 ceph/osd
docker exec mymon ceph osd create
docker run -itd --name osd2 --network ceph-network -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=mymon -e MON_IP=172.20.0.10 -v /etc/ceph:/etc/ceph -v /var/lib/ceph/osd/2:/var/lib/ceph/osd/ceph-2 ceph/osd
查看集群状态:
docker exec -it mymon ceph -s
docker run -itd --name mymon_1 --network ceph-network --ip 172.20.0.11 -e MON_NAME=mymon_1 -e MON_IP=172.20.0.11 -v /etc/ceph:/etc/ceph ceph/mon
docker run -itd --name mymon_2 --network ceph-network --ip 172.20.0.12 -e MON_NAME=mymon_2 -e MON_IP=172.20.0.12 -v /etc/ceph:/etc/ceph ceph/mon
集群状态:
docker exec -it mymon ceph -s
docker run -itd --name myrgw --network ceph-network --ip 172.20.0.5 -p 9080:80 -e RGW_NAME=myrgw -v /etc/ceph:/etc/ceph ceph/radosgw
集群状态:
docker exec -it mymon ceph -s
docker exec mymon ceph osd tree
sudo docker exec myrgw radosgw-admin user create --uid="test" --display-name="test user"
打印输出:
docker ps