频道栏目
首页 > 资讯 > 云计算 > 正文

对象存储之二:实践

17-06-29        来源:[db:作者]  
收藏   我要投稿

对象存储之二:实践

对Programmer来说,最真实的感觉还是让它跑起来;

本文将基于使用云服务器+Docker部署Ceph存储系统 中部署的Ceph存储系统,近距离看看Ceph对象存储;

rados

rados命令是ceph系统中,直接操作storage cluster的一个对象管理命令;

如下put、get、rm、append操作:retrieving-object-data

[root@cluster1 ~]# echo hello_ceph >hello.txt
[root@cluster1 ~]# rados -p rbd put hello_obj ./hello.txt
[root@cluster1 ~]# rados -p rbd ls
hello_obj
[root@cluster1 ~]# rados -p rbd get hello_obj /home/hello.txt; cat /home/hello.txt
hello_ceph
[root@cluster1 ~]# rados -p rbd rm hello_obj; rados -p rbd ls

root@cluster:/# echo _im_here >/tmp/hello2.txt
root@cluster:/# rados -p rbd append hello_obj /tmp/hello2.txt
root@cluster:/# rados -p rbd get hello_obj /tmp/helloall
root@cluster:/# cat /tmp/helloall
hello_ceph
_im_here

再往里面看一看,object存在哪里? pg 0.e8590363 (0.23) 对应 osd.0下 pg dir名称 0.23_head

[root@cluster1 ~]# rados -p rbd put hello_obj ./hello.txt
[root@cluster1 ~]# ceph osd map rbd hello_obj
osdmap e18 pool ‘rbd’ (0) object ‘hello_obj’ -> pg 0.e8590363 (0.23) -> up ([0], p0) acting ([0], p0)
[root@cluster1 ~]# cd /var/lib/ceph/osd/ceph-0/current/0.23_head/
[root@cluster1 0.23_head]# ls
__head_00000023__0 hello\uobj__head_E8590363__0
[root@cluster1 0.23_head]# cat hello\uobj__head_E8590363__0
hello_ceph
[root@cluster1 0.23_head]# file hello\uobj__head_E8590363__0
hello\uobj__head_E8590363__0: ASCII text

object是直接完整存到底层osd的fs上的;

librados

librados是部署在client端,用于在多种语言环境下开发,使用ceph storage cluster的库;

例如,对python开发者来说,就是在client上安装python-rados包 并做功能开发:python_example

使用librados 操作对象,代码的交互流程很典型,与socket 是挺相似的:

依照配置获取句柄-连接-(在pool中)创建io context-读写增删object或读写meta-关闭context-中断连接

为懒人准备的:

yum install -y python-rados; wget https://raw.githubusercontent.com/kirapangzi/ceph-object-python/master/ceph-client.py; python ceph-client.py

更多的功能

感谢Ceph社区的开发者们,更多的Ceph对象存储功能:Bluestore、EC等,正在不断被加入并稳定下来;这也让越来越多的企业愿意将Ceph应用到生产环境中去。

相关TAG标签
上一篇:对Socket通信、TCP/IP和Http的理解
下一篇:NSObject类中无法跳转控制器
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站