Ceph对象存储的使用

Ceph对象存储 RadosGW的使用

一、介绍

作为文件系统的磁盘,操作系统不能直接访问对象存储。相反,它只能通过应用程序级别的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对象存储还具有多站点功能,即为灾难恢复提供解决方案。

二、对象存储部署

RadosGW部署请参见:https://blog.csdn.net/weixin_38137049/article/details/119817661
部署完成后可通过浏览器访问api。
http://rgw-ip:7480在这里插入图片描述

2. 启用ssl

生成签名证书并配置 radosgw 启用 SSL

2.1 自签名证书
[root@ceph-mgr2 ~]# cd /etc/ceph/ 
[root@ceph-mgr2 ceph]# mkdir certs 
[root@ceph-mgr2 ceph]# cd certs/ 
[root@ceph-mgr2 certs]# openssl genrsa -out civetweb.key 2048 
[root@ceph-mgr2 certs]# openssl req -new -x509 -key civetweb.key -out civetweb.crt -subj "/CN=rgw.radosgw.net" 
[root@ceph-mgr2 certs]# cat civetweb.key civetweb.crt > civetweb.pem 
[root@ceph-mgr2 certs]# tree 
.
├── civetweb.crt 
├── civetweb.key 
└── civetweb.pem 
0 directories, 3 files
2.2 SSL配置
[root@ceph-mgr2 certs]# vim /etc/ceph/ceph.conf 
[client.rgw.ceph-mgr2] 
rgw_host = ceph-mgr2 
rgw_frontends = "civetweb port=7480+8443s ssl_certificate=/etc/ceph/certs/civetweb.pem" 
[root@ceph-mgr2 certs]# systemctl restart ceph-radosgw@rgw.ceph-mgr2.service

然后就可以通过https访问啦。

二、使用S3 API访问对象存储
1. 创建 radosgw 用户
[root@ceph-01 ~]# radosgw-admin user create --uid=zhangsan --display-name="zhangsan"
{
    "user_id": "zhangsan",
    "display_name": "zhangsan",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "subusers": [],
    "keys": [
        {
            "user": "zhangsan",
            "access_key": "0WMUEXKPD1093MMF6L22",
            "secret_key": "CmRFiHNZhRbRb6l2vgDtilOiFYjf1vV1S1olDxtn"
        }
    ],
...
2. s3cmd客户端使用
2.1 下载s3cmd工具包并安装

下载s3cmd工具包:https://s3tools.org/download

[root@ceph-client ~]# unzip s3cmd-master.zip
[root@ceph-client ~]# cp -a s3cmd-master /usr/local/s3cmd 
[root@ceph-client ~]# ln -s /usr/local/s3cmd/s3cmd /usr/bin/s3cmd
[root@ceph-client ~]# s3cmd --version
2.2 在客户端上配置 s3
[root@client ~]# s3cmd --configure 
Access Key:《输入access key》
Secret Key: 《输入secret key》
Default Region [US]: 注意直接回车,不要改
S3 Endpoint [s3.amazonaws.com]: rgw.radosgw.net	\\对象网关地址
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: %(bucket)s.rgw.radosgw.net:7480   \\访问bucket的方式
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method isslower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]: No
Test access with supplied credentials? [Y/n] y 
Save settings? [y/N] y
配置文件最终保存在了/root/.s3cfg
2.3 客户端配置完成,就可以执行上传、下载、删除等操作了
[root@client ~]# s3cmd ls    \\查看
[root@client ~]# s3cmd mb s3://my_bucket   \\创建一个bucket
[root@client ~]# s3cmd put /var/log/messages s3://my_bucket   \\上传文件
[root@client ~]# s3cmd ls s3://my_bucket    \\查看 my_bucket 中的内容
[root@client ~]# s3cmd get s3://my_bucket/messages /tmp/   \\下载
[root@client ~]# s3cmd del s3://my_bucket/messages     \\删除
三、Ceph dashboard及监控

Ceph的官方Dashboard正式是从Ceph luminous版本开始,最初是一个简单的只读视图,可查看Ceph集群的各种运行时信息和性能数据,而无需身份验证或任何管理功能。
Ceph Nautilus后的Dashboard可实现管理Ceph的功能,其来源于suse收购的的商业Ceph管理软件openATTIC的功能移植。
现在的Ceph Dashboard后端代码使用CherryPy框架和自定义REST API实现。WebUI基于Angular 实现。
在这里插入图片描述

1. 启用dashboard模块
[ceph@ceph-deploy ceph-cluster]$ ceph mgr module enable
# 注:模块启用后还不能直接访问,需要配置关闭 SSL 或启用 SSL 及指定监听地址。
[ceph@ceph-deploy ceph-cluster]$ ceph config set mgr mgr/dashboard/ssl false #关闭 SSL
[ceph@ceph-deploy ceph-cluster]$ ceph config set mgr mgr/dashboard/ceph-mgr1/server_port 9009 #指定 dashboard 监听端口

在mgr节点验证端口与进程

[root@ceph-mgr1 ~]# lsof -i:9009 
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 
ceph-mgr 2338 ceph 28u IPv4 23986 0t0 TCP *:pichat (LISTEN)
1.1 设置 dashboard 账户及密码:
ceph@ceph-deploy:/home/ceph/ceph-cluster$ touch pass.txt 
ceph@ceph-deploy:/home/ceph/ceph-cluster$ echo "12345678" > pass.txt 
ceph@ceph-deploy:/home/ceph/ceph-cluster$ ceph dashboard set-login-credentials jack -i pass.txt 
****************************************************************** 
*** WARNING: this command is deprecated. *** 
*** Please use the ac-user-* related commands to manage users. *** 
****************************************************************** 
Username and password updated

验证并访问 dashboard

四、通过Prometheus监控Ceph node节点

Ceph manager 内部的模块中包含了 prometheus 的监控模块,并监听在每个 manager 节点的 9283 端口,该端口用于将采集到的信息通过 http 接口向 prometheus 提供数据。

1. 启用prometheus监控模块
[root@ceph-01 ~]# ceph mgr module enable prometheus
#manager 节点验证端口:
[root@ceph-01 ~]# netstat -tunlp | grep 9283
tcp6       0      0 :::9283                 :::*                    LISTEN      4086743/ceph-mgr    
[root@ceph-01 ~]# 

验证manager数据
在这里插入图片描述

2. 配置 prometheus 采集数据:
[root@ceph-mgr1 prometheus]# pwd 
/apps/prometheus 
[root@ceph-mgr1 prometheus]# vim prometheus.yml
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']
      labels:
        monitor: prometheus
  - job_name: 'ceph'
    static_configs:
      - targets: ['10.31.0.1:9128']
        labels:
          storage: ceph
2.1 验证数据

在这里插入图片描述

2.2 通过 grafana 显示监控数据

通过 granfana 显示对 ceph 的集群监控数据
在这里插入图片描述

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值