1 Ceph存储类型介绍
Ceph提供了三种存储类型:块存储、文件存储和对象存储,本文主要介绍对象存储的RGW基本原理和应用场景。本文的主题就是RGW(对象存储)。
对象存储(云存储)是面向对象/文件的、海量的互联网存储。对象存储里的对象是经过封装了的文件,在对象存储系统里, 不能直接打开/修改文件,但可以像ftp一样上传文件,下载文件等。另外,对象存储没有像文件系统那样有一个很多层级 的文件结构,而是只有一个“桶”的概念(也就是存储空间),“桶”里面全部都是对象,是一种非常扁平化的存储方式。 其最大的特点就是它的对象名称就是一个域名地址,一旦对象被设置为“公开”,所有网民都可以访问到。对象存储最主 流的使用场景,就是存储网站、移动app等互联网/移动互联网应用的静态内容(视频、图片、文件、软件安装包等等)。
2 什么是RGW?
RGW是对象存储网关服务Rados Gateway的缩写,ceph通过RGW为互联网云服务提供商提供对象存储服务。RGW在librados之上向应用提供访问ceph集群的RestAPI, 支持Amazon S3和openstack swift两种接口。对RGW最直接的理解就是一个协议转换层,把从上层应用符合S3或Swift协议的请求转换成rados的请求, 将数据保存在rados集群中。RGW基于HTTP协议标准,因此非常适合用户Web类的互联网应用场景,用户通过使用SDK或者其他客户端工具,能够很方便的介入RGW进程图片,视频以及各类文件的上传,下载,并设置相应的访问权限,共享给其他用户。如:云服务,云盘。
3 搭建RGW
3.1 civetweb方式搭建
这个部署方式比较简单,在使用ceph-deploy部署好基本环境以后,在ceph-deploy部署目录下会有一个{cluster-name}.bootstrap-rgw.keyring的文件。下面就使用ceph-deploy在该目录下进行部署。
3.1.1 新建RGW
[root@ceph-mon1 ceph-cluster]# ceph-deploy rgw create ceph-osd2
[ceph_deploy.conf][DEBUG ] found configuration file at: /root/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (1.5.36): /usr/bin/ceph-deploy rgw create ceph-osd2
[ceph_deploy.cli][INFO ] ceph-deploy options:
......
[ceph-osd2][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf
[ceph_deploy.rgw][ERROR ] RuntimeError: config file /etc/ceph/ceph.conf exists with different content; use --overwrite-conf to overwrite
注意:ceph-osd2是主机名。这里部署报错了,提示很明显,说ceph配置文件内容不同,使用--overwrite-conf
[root@ceph-mon1 ceph-cluster]# ceph-deploy --overwrite-conf rgw create ceph-osd2
..........
[ceph-osd2][WARNIN] Created symlink from /etc/systemd/system/ceph-radosgw.target.wants/ceph-radosgw@rgw.ceph-osd2.service to /usr/lib/systemd/system/ceph-radosgw@.service.
[ceph-osd2][INFO ] Running command: systemctl start ceph-radosgw@rgw.ceph-osd2
[ceph-osd2][INFO ] Running command: systemctl enable ceph.target
[ceph_deploy.rgw][INFO ] The Ceph Object Gateway (RGW) is now running on host ceph-osd2 and default port 7480
成功了。
3.1.2 修改RGW配置
默认情况下,civetweb端口是7480,可以通过修改ceph.conf并重启RADOSGW服务来改变端口。如下:
[client]
rgw frontends = civetweb port=666
3.1.3 重启服务
[root@ceph-osd2 ~]# radosgw restart
或者有些操作系统是:
[root@ceph-osd2 ~]# ceph-radosgw restart
3.1.4 检查服务是否启动
[root@ceph-osd2 ~]# ps -ef|grep radosgw
ceph 10525 1 0 10:38 ? 00:00:01 /usr/bin/radosgw -f --cluster ceph --name client.rgw.ceph-osd2 --setuser ceph --setgroup ceph
root 11264 10236 0 10:44 pts/0 00:00:00 grep --color=auto radosgw
3.1.5 测试访问
[root@ceph-osd2 ~]# curl http://ceph-osd2:7480 --主机名
<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>anonymous</ID><DisplayName></DisplayName></Owner><Buckets></Buckets></ListAllMyBucketsResult>
[root@ceph-osd2 ~]#
版权声明:本文为博主原创文章,未经博主允许不得转载。
ceph rgw