利用ceph-deploy在ubuntu server14.04上部署ceph并进行其它配置
jopen
10年前
1. 环境与说明
在ubuntu14.04 server上部署ceph-0.87;设置rbdmap自动挂载/卸载rbd块设备;利用带rbd支持的tgt导出iscsi的rbd块。
2. 安装ceph
1)配置hostname与无密码登录
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
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
ceph-deploy new mon0 osd1 osd2 ceph-deploy install mon0 osd1 osd2 ceph-deploy mon create mon0 osd1 osd2 ceph-deploy gatherkeys mon0 osd1 osd2 ceph-deploy osd prepare mon0:/cephmp1:/dev/sdf1 mon0:/cephmp2:/dev/sdf2 osd1:/cephmp1:/dev/sdf1 osd1:/cephmp2:/dev/sdf2 osd2:/cephmp1:/dev/sde1 osd2:/cephmp2:/dev/sde2 ceph-deploy osd activate mon0:/cephmp1:/dev/sdf1 mon0:/cephmp2:/dev/sdf2 osd1:/cephmp1:/dev/sdf1 osd1:/cephmp2:/dev/sdf2 osd2:/cephmp1:/dev/sde1 osd2:/cephmp2:/dev/sde2 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文件:
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了。
3. 配置rbdmap
创建rbd块设备并rbd map后,如果不及时rbd unmap,关机的时候系统会hung在umount此rbd设备上。所以配置rbdmap是必须的。首先下载并设置开机启动rbdmap
$ 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块设备了。
4. 配置支持rbd导出的iscsi
安装tgt,并检查是否支持rbd
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
来自:http://my.oschina.net/renguijiayi/blog/342983