【原文编者的话】 我来自上海Hypers 国内顶尖的大数据分析公司,参加过“云雀Docker巨好玩”并获得一等奖,年纪尚小请大家多多指教。因为有人提出了这个想法,我之前已经成功实践过这些实验,自己也就把百度和Google不到的私房菜贡献出来,只有一个要求,希望大家互相帮助,不要自吹自擂就行,多多分享。
希望大家互相扶持,互相帮助,与DockOne&OSchina还有所有的开源社区一起推动国内的Docker商用和技术能力。
用Docker搭建Ceph非常简单,只需要几条命令就可以搞定,甚至比Ceph出的ceph-deploy还方便,也无需翻墙获得软件包。
我的部署环境是
- Disk free > 30G
- Ceph 0.94.1 hammer
- OS Ubuntu 14.04.2
- Kernel 4.0.5
- overlayfs
- eth0 IPADDR=192.168.1.100
下载mon和osd
- [root@ubuntu ~]# docker pull index.alauda.cn/georce/mon:hammer
- [root@ubuntu ~]# docker pull index.alauda.cn/georce/osd:hammer
一条命令搭建mon
- [root@ubuntu ~]# docker run -itd --name=mon --net=host -e MON_NAME=mymon -e MON_IP=192.168.1.100 -v /etc/ceph:/etc/ceph index.alauda.cn/georce/mon:hammer
查看mon运行日志
- [root@ubuntu ~]# docker logs -f mon
- 2015-06-15 13:48:38.414494 7fd43f5db700 1 mon.mymon@0(leader).osd e1 e1: 0 osds: 0 up, 0 in
- 2015-06-15 13:48:38.416236 7fd43f5db700 0 mon.mymon@0(leader).osd e1 crush map has features 1107558400, adjusting msgr requires
- 2015-06-15 13:48:38.416306 7fd43f5db700 0 mon.mymon@0(leader).osd e1 crush map has features 1107558400, adjusting msgr requires
- 2015-06-15 13:48:38.416391 7fd43f5db700 0 mon.mymon@0(leader).osd e1 crush map has features 1107558400, adjusting msgr requires
- 2015-06-15 13:48:38.416479 7fd43f5db700 0 mon.mymon@0(leader).osd e1 crush map has features 1107558400, adjusting msgr requires
- 2015-06-15 13:48:38.416712 7fd43f5db700 1 mon.mymon@0(leader).paxosservice(auth 1..1) refresh upgraded, format 0 -> 1
- 2015-06-15 13:48:38.418924 7fd43f5db700 0 log_channel(cluster) log [INF] : mdsmap e1: 0/0/0 up
- 2015-06-15 13:48:38.423753 7fd43f5db700 0 log_channel(cluster) log [INF] : osdmap e1: 0 osds: 0 up, 0 in
- 2015-06-15 13:48:38.428045 7fd43f5db700 0 log_channel(cluster) log [INF] : pgmap v2:
查看mon生成的集群配置文件
- [root@ubuntu ~]# ls /etc/ceph
- [root@ubuntu ~]# ceph.client.admin.keyring ceph.conf ceph.mon.keyring monmap
更改集群配置文件
- [root@ubuntu ~]# vi ceph.conf
- [global]
- fsid = 4efc5ee7-8982-4bf4-808b-15372862fb78 #这个要看你生成的 别抄我的
- mon initial members = mymon
- mon host = 192.168.1.100
- auth cluster required = cephx
- auth service required = cephx
- auth client required = cephx
- osd crush chooseleaf type = 0
- osd journal size = 100
- osd pool default pg num = 8
- osd pool default pgp num = 8
- osd pool default size = 1
- public network = 192.168.1.0/24
- cluster network = 192.168.1.0/24
- [root@ubuntu ~]# docker restart mon
两条命令创建osd
- [root@ubuntu ~]# docker exec mon ceph osd create
- 0
如果不知道上面的0是什么,我解释下 ceph osd 0 /var/lib/ceph/osd/ceph-0
创建osd0
- [root@ubuntu ~]# docker run -itd --name=osd0 --net=host -e CLUSTER=ceph -e WEIGHT=1.0 -e MON_NAME=mymon -e MON_IP=192.168.1.100 -v /etc/ceph:/etc/ceph -v /opt/osd/0:/var/lib/ceph/osd/ceph-0 index.alauda.cn/georce/osd:hammer
查看ceph群集状态
- [root@ubuntu ~]# docker exec -it mon ceph -s
- cluster 4efc5ee7-8982-4bf4-808b-15372862fb78
- health HEALTH_OK
- monmap e1: 1 mons at {mymon=192.168.1.100:6789/0}
- election epoch 2, quorum 0 mymon
- osdmap e5: 1 osds: 1 up, 1 in
- pgmap v7: 64 pgs, 1 pools, 0 bytes data, 0 objects
- 3584 MB used, 42028 MB / 48077 MB avail
- 64 active+clean