在ubuntu14.04 server上部署ceph-0.87;設置rbdmap自動掛載/卸載rbd塊設備;利用帶rbd支持的tgt導出iscsi的rbd塊。 git
1)配置hostname與無密碼登陸 github
root@mon0:/etc/ceph# cat /etc/hosts 127.0.0.1 localhost 192.168.108.4 osd2.osd2 osd2 192.168.108.3 osd1.osd1 osd1 192.168.108.2 mon0.mon0 mon0
#示例以下 ssh-keygen ssh-copy-id -i /root/.ssh/id_rsa.pub osd1
2)安裝ceph-deploy shell
wget -q -O- 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | sudo apt-key add - echo deb http://ceph.com/debian-dumpling/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list apt-get update apt-get install ceph-deploy
3)安裝ceph ubuntu
ceph-deploy new mon0 osd1 osd2 ceph-deploy install --release giant mon0 osd1 osd2 ceph-deploy mon create mon0 osd1 osd2 ceph-deploy gatherkeys mon0 osd1 osd2 #須要先建立osd盤對應的掛載目錄/cephmp一、/cephmp2,並將osd盤掛載到這些目錄上 ceph-deploy osd prepare mon0:/cephmp1:/dev/sdf1 mon0:/cephmp2:/dev/sdf2 osd1:/cephmp1:/dev/sdf1 osd1:/cephmp2:/dev/sdf2 osd2:/cephmp1:/dev/sdf1 osd2:/cephmp2:/dev/sdf2 ceph-deploy osd activate mon0:/cephmp1:/dev/sdf1 mon0:/cephmp2:/dev/sdf2 osd1:/cephmp1:/dev/sdf1 osd1:/cephmp2:/dev/sdf2 osd2:/cephmp1:/dev/sdf1 osd2:/cephmp2:/dev/sdf2 ceph-deploy mds create mon0 osd1 osd2安裝好後,能夠按須要修改/etc/ceph/ceph.conf文件,而後利用ceph-deploy --overwrite-conf config push osd1 osd2命令將修改的配置文件push到其它主機上。而後利用以下命令重啓:
restart ceph-all
這裏遇到的問題是雖然修改了/etc/apt/sources.list.d/ceph.list,但ceph-deploy會去修改這個文件,並配置成firefly,因此安裝的是0.80.7。安裝完成後,修改ceph.list文件: app
root@mon0:/etc/ceph# cat /etc/apt/sources.list.d/ceph.list deb http://ceph.com/debian-giant/ trusty main修改爲giant版本後:
apt-get update apt-get upgrade ceph restart ceph-all
這樣就將ceph升級到giant 0.87了。 ssh
建立rbd塊設備並rbd map後,若是不及時rbd unmap,關機的時候系統會hung在umount此rbd設備上。因此配置rbdmap是必須的。首先下載並設置開機啓動rbdmap spa
$ sudo wget https://raw.github.com/ceph/ceph/a4ddf704868832e119d7949e96fe35ab1920f06a/src/init-rbdmap -O /etc/init.d/rbdmap $ sudo chmod +x /etc/init.d/rbdmap $ sudo update-rc.d rbdmap defaults而後建立一個rbd塊設備,並利用rbd map掛載此設備,而後mkfs進行格式化,結果以下:
root@mon0:/etc/ceph# rbd ls iscsi iscsi-rbd root@mon0:/etc/ceph# rbd showmapped id pool image snap device 1 iscsi iscsi-rbd - /dev/rbd1 mkfs.xfs /dev/rbd1修改/etc/init.d/rbdmap,將/etc/rbdmap修改成你的rbdmap的實際路徑;而後將掛載信息寫入/etc/ceph/rbdmap(個人rbdmap路徑):
root@mon0:/etc/ceph# cat /etc/ceph/rbdmap # RbdDevice Parameters #poolname/imagename id=client,keyring=/etc/ceph/ceph.client.keyring iscsi/iscsi-rbd由於我禁用了cephx,因此沒必要配置keyring了。
這樣就能夠手動控制、而且開關機能夠自動掛載和卸載rbd塊設備了。 rest
安裝tgt,並檢查是否支持rbd code
root@mon0:/etc/ceph# apt-get install tgt root@mon0:/etc/ceph# tgtadm --lld iscsi --op show --mode system | grep rbd rbd (bsoflags sync:direct)建立一個rbd塊設備並map和格式化;而後修改/etc/tgt/targets.conf:
root@mon0:/etc/ceph# cat /etc/tgt/targets.conf # Empty targets configuration file -- please see the package # documentation directory for an example. # # You can drop individual config snippets into /etc/tgt/conf.d include /etc/tgt/conf.d/*.conf <target iqn.2014-11.rbdstore.com:iscsi> driver iscsi bs-type rbd backing-store iscsi/iscsi-rbd # Format is <iscsi-pool>/<iscsi-rbd-image> </target> service tgt reload總結:在ubuntu上仍是第一次折騰ceph,須要慢慢總結和適應。也但願搞過的童鞋不吝賜教。