首页 > 代码库 > 利用ceph-deploy在ubuntu server14.04上部署ceph并进行其它配置

利用ceph-deploy在ubuntu server14.04上部署ceph并进行其它配置

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

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





利用ceph-deploy在ubuntu server14.04上部署ceph并进行其它配置