ceph实践笔记第二篇-ceph块存储

一、什么是块存储

ceph通过统一的方式提供存储容量,比如块、文件系统、对象存储
08pg1
ceph块设备也叫RADOS块设备,提供可靠的分布式和高性能块存储磁盘给客户端,RADOS使用librbd库把数据以顺序条带形式存放到ceph集群的多个osd

二、配置ceph客户端

客户端指linux常见主机,主机通过ceph集群网络来相互交互来存储数据或者检索数据

modprobe rbd检查客户机是否支持rbd,支持$?为0

ceph-node01上操作
配置hosts
echo 10.0.0.33 client-node01 >> /etc/hosts
配置免密
ssh-copy-id -i .ssh/id_rsa.pub clinet-node01
安装ceph程序到client-node01
cd /etc/ceph && ceph-deploy install client-node01
复制配置文件ceph.conf到client-node01
cd /etc/ceph && ceph-deploy config push client-node01
权限配置
客户机本身需要密钥来访问集群,ceph默认会创建一个用户client.admin可以访问集群,但是就类似数据库一样,不建议将该默认用户client.admin共享到所有节点,可以用分开的密钥创建一个新的ceph用户去访问特定的存储池
ceph auth get-or-create client.rbd mon 'allow r' osd 'allow class-read object_prefix rbd_children,allow rwx pool=rbd'
返回

[client.rbd]
key = AQDBUShhpV+JJRAAsANqEW+fehCEWqbKfTyecA==

在client-node01上添加用户client.rbd的密钥
ceph auth get-or-create client.rbd | ssh client-node01 tee /etc/ceph/ceph.client.rbd.keyring
返回

You have logged onto a secured server..All accesses logged
[client.rbd]
key = AQDBUShhpV+JJRAAsANqEW+fehCEWqbKfTyecA==

client-node01上操作
cat /etc/ceph/ceph.client.rbd.keyring >> /etc/ceph/keyring
使用非默认用户(无需密码)client.rbd来连接ceph集群
ceph -s --name client.rbd

ceph-node01上操作
查看权限
ceph auth list
返回

installed auth entries:

osd.0
	key: AQDUiwVhm8BhJRAAwvxjJWIXR7c62mqMEFVY5Q==
	caps: [mon] allow profile osd
	caps: [osd] allow *
osd.1
	key: AQDiTQdhi+aeFRAAfvtawdk7bz2NRkCIF5llJg==
	caps: [mon] allow profile osd
	caps: [osd] allow *
osd.2
	key: AQAJTgdhgRaXExAA7YrvuAKd5JZLBDQ4tDszfg==
	caps: [mon] allow profile osd
	caps: [osd] allow *
client.admin
	key: AQBriAVhhlUvNxAAU2KkI63T05sf6Jqwb4zzDQ==
	caps: [mds] allow *
	caps: [mon] allow *
	caps: [osd] allow *
client.bootstrap-mds
	key: AQBsiAVhEivxJxAAJ33N2D1IJCovuNsevxGwDg==
	caps: [mon] allow profile bootstrap-mds
client.bootstrap-mgr
	key: AQBviAVh5/PYABAAFJpioWJe8hh71H9Fkn/ejQ==
	caps: [mon] allow profile bootstrap-mgr
client.bootstrap-osd
	key: AQBsiAVhqIFWChAA6lHtkus6zXX3Y9DJsyVy3g==
	caps: [mon] allow profile bootstrap-osd
client.bootstrap-rgw
	key: AQBsiAVhCzE9GRAAovmo/vj+TYkEoTgFrxojuA==
	caps: [mon] allow profile bootstrap-rgw
client.rbd
	key: AQDBUShhpV+JJRAAsANqEW+fehCEWqbKfTyecA==
	caps: [mon] allow r
	caps: [osd] allow class-read object_prefix rbd_children,allow rwx pool=rbd

从上面输出的信息可以看到前面创建的用户client.rbd

三、创建块设备