Ceph 对象存储及客户端配置(三)

一、对象存储介绍

  作为文件系统的磁盘,操作系统不能直接访问对象存储。相反,它只能通过应用程序级别的API访问。Ceph是一种分布式对象存储系统,通过Ceph对象网关提供对象存储接口,也称为RADOS网关(RGW)接口,它构建在Ceph RADOS层之上。 RGW使用librgw (RADOS Gateway Library)和librados,允许应用程序与Ceph对象存储建立连接。 RGW为应用程序提供了一个RESTful S3 / swift兼容的API接口,用于在Ceph集群中以对象的形式存储数据。 Ceph还支持多租户对象存储,可以通过RESTful API访问。此外, RGW还支持Ceph Admin API,可以使用本机API调用来管理Ceph存储集群。
  由于它提供与OpenStack Swift和Amazon S3兼容的接口,因此Ceph对象网关具有自己的用户管理。Ceph对象网关可以将数据存储在用于存储来自Ceph文件系统客户端或Ceph块设备客户端的数据的相同Ceph存储集群中。S3和Swift API共享一个公共命名空间,因此您可以使用一个API编写数据并使用另一个API检索它。librados软件库非常灵活,允许用户应用程序通过C、 c++、 Java、 Python和PHP绑定直接访问Ceph存储集群。 Ceph对象存储还具有多站点功能,即为灾难恢复提供解决方案。

对于生产环境,建议在物理专用机器上配置RGW。但是,如果对象存储工作负载不太大,可以考虑将任何监视器机器作为RGW节点使用。 RGW是一个独立的服务,它从外部连接到Ceph集群,并向客户端提供对象存储访问。在生产环境中,建议运行多个RGW实例,由负载均衡器屏蔽,如下图所示:

二、对象存储部署

2.1 三个节点安装ceph-radosgw

$ sudo yum install ceph-radosgw -y

2.2 部署集群

[[email protected] ~]$ cd my-cluster/
[[email protected] my-cluster]$ ceph-deploy rgw create ceph01 ceph02 ceph03

2.3 部署完成后默认的端口是7480将其修改为80端口

[[email protected] my-cluster]$ vim ceph.conf
[global]
fsid = 4d02981a-cd20-4cc9-8390-7013da54b161
mon_initial_members = ceph01, ceph02, ceph03
mon_host = 192.168.5.91,192.168.5.92,192.168.5.93
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx

# 增加以下内容,client.rgw.后面为主机名称
[client.rgw.ceph01]
rgw_frontends = "civetweb port=80"
[client.rgw.ceph02]
rgw_frontends = "civetweb port=80"
[client.rgw.ceph03]
rgw_frontends = "civetweb port=80"

2.4 将配置文件推送到集群其它节点中

# 推送完成之后,所有节点的/etc/ceph/ceph.conf配置文件将和上面一致
[[email protected] my-cluster]$ ceph-deploy --overwrite-conf config push ceph01 ceph02 ceph03

2.5 各节点重启服务

[[email protected] ~]$ sudo systemctl restart ceph-[email protected]
[[email protected] ~]#  systemctl restart ceph-[email protected]
[[email protected] ~]#  systemctl restart [email protected] 

2.6 测试验证能否访问集群的80端口

[[email protected] ~]$ sudo netstat -lntp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      151464/radosgw
# 需要使用root帐户进行测试集群
[[email protected] ~]# ceph -s -k /var/lib/ceph/radosgw/ceph-rgw.ceph01/keyring --name client.rgw.ceph01

二、使用S3 API 访问对象存储

2.1 创建创建 radosgw 用户

[[email protected] ~]# radosgw-admin user create --uid=radosgw --display-name=‘radosgw‘ -k /var/lib/ceph/radosgw/ceph-rgw.ceph01/keyring --name client.rgw.ceph01

# 创建完成之后需要把access_key和secret_key保存下来,也可以使用下面的命令来查看
[[email protected] ~]# radosgw-admin user info --uid=radosgw --display-name=‘radosgw‘ -k /var/lib/ceph/radosgw/ceph-rgw.ceph01/keyring --name client.rgw.ceph01

2.2 在客户端安装s3cmd软件

[[email protected]192-168-5-70 ~]# yum install s3cmd -y

2.3 生成配置文件

[[email protected]192-168-5-70 ~]# s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: D028HA7T16KJHU2602YA                                        # 粘贴服务端生成的Access Key
Secret Key: RWczKVORMdDBw2mtgLs2dUPq2xrCehnjOtB6pHPY                    # 粘贴服务端生成的Secret Key
Default Region [US]:                                                    # 直接回车即可

Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: 192.168.5.91                            # 输入对象存储的IP地址

Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]:  %(bucket).192.168.5.91             # 输入对象存储的bucket地址

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:                                                     # 空密码回车
Path to GPG program [/usr/bin/gpg]:                                      # /usr/bin/gpg命令路径 回车

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]: no                                             # 是否使用https,选no

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can‘t connect to S3 directly
HTTP Proxy server name:                                                  # haproxy 留空回车

New settings:
  Access Key: D028HA7T16KJHU2602YA
  Secret Key: RWczKVORMdDBw2mtgLs2dUPq2xrCehnjOtB6pHPY
  Default Region: US
  S3 Endpoint: 192.168.5.91
  DNS-style bucket+hostname:port template for accessing a bucket:  %(bucket).192.168.5.91
  Encryption password:
  Path to GPG program: /usr/bin/gpg
  Use HTTPS protocol: False
  HTTP Proxy server name:
  HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] n

Save settings? [y/N] y                                                    # y 要保存配置文件
Configuration saved to ‘/root/.s3cfg‘                                     # 最后配置文件保存的位置/root.s3cfg

2.4 s3cmd验证基础操作

[[email protected]192-168-5-70 ~]# s3cmd mb s3://my-bucket                            # 创建my-bucket桶
 Bucket ‘s3://my-bucket/‘ created
[[email protected]192-168-5-70 ~]# s3cmd ls                                           # 查看所有的桶
2020-02-12 07:07  s3://my-bucket
[[email protected]192-168-5-70 ~]# s3cmd put /etc/hosts s3://my-bucket                # 向指定桶中上传/etc/hosts文件
upload: ‘/etc/hosts‘ -> ‘s3://my-bucket/hosts‘  [1 of 1]
 158 of 158   100% in    0s     2.67 kB/s  done
[[email protected]192-168-5-70 ~]# s3cmd ls s3://my-bucket                            # 显示my-bucket中的文件
2020-02-12 07:07       158   s3://my-bucket/hosts
[[email protected]192-168-5-70 ~]# s3cmd del s3://my-bucket/hosts                     # 删除my-bucket中的hosts文件
delete: ‘s3://my-bucket/hosts‘
[[email protected]192-168-5-70 ~]# s3cmd rb s3://my-bucket                            # 删除my-bucket
Bucket ‘s3://my-bucket/‘ removed

三、Swift API 访问对象存储

3.1 创建swift api子帐户,若忘记key也可用上面的info查看

[[email protected] ~]# radosgw-admin subuser create --uid=radosgw --subuser=radosgw:swift --access=full

3.2 安装swift客户端

[[email protected]192-168-5-70 ~]# yum install python-pip -y
[[email protected]192-168-5-70 ~]# pip install --upgrade python-swiftclient

3.3 使用swift进行访问

[[email protected]192-168-5-70 ~]# swift -A http://192.168.5.91/auth/1.0 -U radosgw:swift -K IlX5guDnsqPGEpKOGgfR4AtuFxPTGr0VQF6F6Iwy post lin-bucket     # 创建lin-bucket桶
[[email protected]192-168-5-70 ~]# swift -A http://192.168.5.91/auth/1.0 -U radosgw:swift -K IlX5guDnsqPGEpKOGgfR4AtuFxPTGr0VQF6F6Iwy list                # 查看所有的桶lin-bucket

原文地址:https://www.cnblogs.com/cyleon/p/12299192.html

时间: 2024-08-28 18:38:07

Ceph 对象存储及客户端配置(三)的相关文章

Ceph对象存储网关安装配置

引言 基于已部署好的Ceph集群,部署一个网关服务器,进行对象存储服务.操作系统CentOS6.5 CEPH0.94.3其实基于librados可以直接进行访问,但是我看了百度,UCLOUD的对象存储,用户在网页上进行文件的上传.下载时,都通过web服务器间接和存储集群打交道,进行了一层隔离,而不是直接和集群进行通信操作.我得理解是便于访问控制以及隔离. 1.依赖包安装 Ceph rados-gateway依赖Apache和FastCGI, 用户的请求先到web服务器,再走rados-gatew

ceph对象存储(rgw)服务、高可用安装配置

ceph对象存储服务.高可用安装配置 简介:    Ceph本质上就是一个rados,利用命令rados就可以访问和使用ceph的对象存储,但作为一个真正产品机的对象存储服务,通常使用的是Restfulapi的方式进行访问和使用.而radosgw其实就是这个作用,安装完radosgw以后,就可以使用api来访问和使用ceph的对象存储服务了.    首先明白一下架构,radosgw其实名副其实,就是rados的一个网关,作用是对外提供对象存储服务.本质上radosgw(其实也是一个命令)和rbd

Ceph对象存储RGW对接企业级网盘OwnCloud三步走

上篇文章我们把Ceph对象存储搭建成功了,但是成功了之后我们怎么用呢?下面我们本文就来讲下Ceph对象存储对接企业私有云网盘OwnCloud. OwnCloud分为企业版和社区版,我们只说社区版,在这里我就不多赘述了. 那么Ceph对接OwnCloud分三步走. 第一:安装Ceph配置RGW对象存储 第二:安装OwnCloud 第三:对接 第一步在上个文章里面已经做了,那么第二步是安装OwnCloud,可以看下我之前的文章进行安装. 如何搭建OwnCloud网盘 主要讲下第三步 要点:网盘节点D

Ceph对象存储介绍与安装

一:概念介绍 Ceph对象网关是建立在librados之上的对象存储接口,可为应用程序提供通往Ceph存储集群的RESTful网关, Ceph对象存储支持两个接口 1.S3兼容:为对象存储功能提供与Amazon S3 RESTful API的大部分子集兼容的接口2.Swift兼容:为对象存储功能提供与OpenStack Swift Ceph对象存储使用Ceph对象网关守护进程(radosgw),该守护进程是用于与Ceph存储群集进行交互的HTTP服务器,由于它提供与OpenStack Swift

Ceph对象存储安装部署及验证

今天来玩下Ceph的对象存储,之前一直觉得对象存储对于玩OpenStack的我来说用不到,但随着越来越多的海量文件的需求,不得不促使我们来学习对象存储.所谓活到老学到老,尤其是我们搞IT的,每天都得学习新技术. 首先呢就是部署一套Ceph环境,这里就不再赘述了,网上好多安装文档,都比较清晰了. 重点说下RGW部分 安装完集群之后 ceph-deploy install --rgw devin-ceph1    #因为是测试所以只用一个rgw 然后创建RGW实例 ceph-deploy rgw c

基于LAMP php7.1搭建owncloud云盘 与ceph对象存储S3借口整合案例

ownCloud简介:      是一个来自 KDE 社区开发的免费软件,提供私人的 Web 服务.当前主要功能包括文件管理(内建文件分享).音乐.日历.联系人等等,可在PC和服务器上运行.     简单来说就是一个基于Php的自建网盘.基本上是私人使用这样,因为直到现在开发版本也没有暴露注册功能.我这里采用基于php7.1的LAMP环境搭建这个owncloud 下一篇将介绍和ceph对象存储整合案例 一.环境准备,这里的owncloud是10版本,所以需要php5.6以上的LAMP环境,否则会

基于redhat7.3 ceph对象存储集群搭建+owncloud S3接口整合生产实践

一.环境准备 安装redhat7.3虚拟机四台 在四台装好的虚拟机上分别加一块100G的硬盘.如图所示: 3.在每个节点上配置主机名 4.集群配置信息如下 admin-node node1 node2 node3 192.168.42.110 192.168.42.111 192.168.42.112 192.168.42.113 deploy.osd*1 mon*1.osd*1. rgw*1.mds*1 mon*1.osd*1 mon*1.osd*1 5.各节点配置yum源 #需要在每个主机上

ceph 对象存储s3

ceph s3cmd的命令 问题: 1. 使用access_key和secret_key获取的对象url,会缓存在浏览器disk cache中,导致每次第二次访问资源的时候,会报no-cors的错误 2. 浏览器获取数据时,会显示(from disk cache) 针对问题2,调研强缓存 强缓存 强缓存:不会向服务器发送请求,直接从缓存中读取资源,在 chrome 控制台的 Network 选项中可以看到该请求返回 200 的状态码,并且 Size 显示 from disk cache 或 fr

CEPH 对象存储的系统池介绍

RGW抽象来看就是基于rados集群之上的一个rados-client实例. Object和pool简述 Rados集群网上介绍的文章很多,这里就不一一叙述,主要要说明的是object和pool.在rados集群中任意一个对象都会映射为一个(pool,object).其中pool是存储池,object为对象名.如果你只是做rados集群上层应用的开发(类似开发rgw).只需要设计如何将数据存储到rados集群中哪个pool及哪个对象即可. RGW中pool和object应用 RGW中存在的poo