1.Ceph 基础篇 - 存储基础及架构介绍

2022-11-04,,,,

文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247485232&idx=1&sn=ff0e93b91432a68699e0e00a96602b78&chksm=e9fdd2c4de8a5bd22d4801cf35f78ffd9d7ab95b2a254bc5a4d181d9247c31c9b2f5485d4b74&scene=178&cur_album_id=1600845417376776197#rd

常见存储类型

存储类型:DAS、NAS、SAN、Object Storage存储。

DAS,Direct Attached Storage 直接附加存储

服务器通过SCSI 总线或者FC光纤连接到存储陈列上面,它的表现形式是一块裸盘,块设备,可以对其进行格式化,组网简单、成本低廉,但可扩展性不限,传输距离受限,无法做到多对多的使用,也无法共享给其它服务器使用,目前使用的较少,少许了解即可;

NAS,Network Attached Storage 网络附加存储

使用TCP协议进行组网,连接到共享存储的,协议类型主要有NFS、CIFS,远程挂载,表现形式是目录,也就是文件存储,使用简单,通过IP协议实现互访,多机可以同时共享这个存储,性能差,可靠性不高,NFS、Samba、GlusterFS、以及云厂商的AWS EFS、阿里NAS、腾讯云CFS等;

SAN,Storage Area Network 存储区域网络

使用一个存储区域网络IP或FC连接到存储陈列,服务器可以通过IP-SAN(通过IP协议连接到传统交换机,然后再连接后端的存储网络,成本低)或者FC-SAN(服务器需要有一张HBA 光纤通道卡连接到FC交换机,然后再连接到后续存储网络,成本高),它的表现形式是一块裸盘,块设备,性能好,扩展性强,但成本高,产品主要有iSCSI,EMC,NetApp,HP存储,公有云上面也有这种SAN存储,如AWS EBS、腾讯云的CBS、阿里云的块存储;

Object Storage,对象存储

通过网络使用 API 或者命令行访问一个无限扩展的分布式存储系统;最早是使用AWS S3协议类型,现在基本上S3也成为了目前对象存储的标准协议规范,常见的操作都是通过PUT实现上传和GET 实现下载等;它的表现形式,你可以认为后端存储空间无限大,你只需要使用PUT、GET方式实现上传下载即可,无需关心后端存储 ;可扩展性强,使用简单,但上传的文件,无法在对象存储中对其进行修改编辑,如果有需要,下载到本地,然后再上传,无法为服务器提供块级别的存储;产品举例,百度网盘,HDFS、FastDFS、swift、公有云的:ASW S3,腾讯云的COS,阿里云的OSS等;

Ceph 存储架构

Ceph uniquely delivers object, block, and file storage in one unified system.

Ceph 是唯一一个可提供传输对象存储、块存储、文件存储的统一系统。

Ceph is highly reliable, easy to manage, and free. The power of Ceph can transform your company’s IT infrastructure and your ability to manage vast amounts of data.

Ceph 它高度可靠,易于管理,并且免费。Ceph的强大功能可以改变您公司的IT基础架构以及管理大量数据的能力。

CEPH OBJECT STORE (CEPH 对象存储)

RESTful Interface # 提供 RESTful 接口
S3- and Swift-compliant APIs # 兼容S3和Swift的API
S3-style subdomains # S3样式子域
Unified S3/Swift namespace # 统一的S3/Swift名称空间
User management # 用户管理
Usage tracking # 使用情况跟踪
Striped objects # 条纹对象
Cloud solution integration # 云解决方案集成
Multi-site deployment # 多站点部署
Multi-site replication # 多站点复制,异地备份

CEPH BLOCK DEVICE (Ceph 块设备)

hin-provisioned # 精简配置
Images up to 16 exabytes # 块设备最大16EB
Configurable striping # 可配置条带化
In-memory caching # 内存中缓存
Snapshots # 快照
Copy-on-write cloning # 写时复制克隆
Kernel driver support # 内核驱动程序支持
KVM/libvirt support # KVM/libvirt 支持
Back-end for cloud solutions # 后端云解决方案
Incremental backup # 增量备份
Disaster recovery (multisite asynchronous replication) # 灾难恢复(多站点异步复制)

CEPH FILE SYSTEM (CEPH 文件系统)

POSIX-compliant semantics # 符合POSI语义
Separates metadata from data # 从数据中分离元数据
Dynamic rebalancing # 动态再平衡
Subdirectory snapshots # 子目录快照功能
Configurable striping # 可配置条带化
Kernel driver support # 内核驱动程序支持
FUSE support # FUSE # 文件系统支持
NFS/CIFS deployable # 可部署为 NFS/CIFS 文件系统
Use with Hadoop (replace HDFS) # 与hadoop一起使用,替换HDFS

ARCHITECTURE

Ceph uniquely delivers object, block, and file storage in one unified system. Ceph is highly reliable, easy to manage, and free. The power of Ceph can transform your company’s IT infrastructure and your ability to manage vast amounts of data. Ceph delivers extraordinary scalability–thousands of clients accessing petabytes to exabytes of data. A Ceph Node leverages commodity hardware and intelligent daemons, and a Ceph Storage Cluster accommodates large numbers of nodes, which communicate with each other to replicate and redistribute data dynamically.

Ceph 提供了灵活的可伸缩性-使得成千上万的的客户可接入PB级别到EB级别的数据。Ceph 节点利用普通的硬件和智能守护进程,Ceph 存储集群容纳大量的 node 节点,它们之间相互复制和数据动态重分配。

Ceph 应用场景

LIBRADOS库:提供一些常用编程语言的库,直接通过程序来调用LIBRADOS库操作Ceph 存储 ;

RADOSGW:对象存储,基于存储桶的REST网关,与S3和Swift兼容,它是建立在LIBRADOS库之上的;

RBD:块设备存储,具有Linux内核客户端和QEMU / KVM驱动程序的可靠且完全分布式的块设备,具有Linux 内核客户端并支持FUS,符合 POSIX 协议的分布式文件系统,它是建立在LIBRADOS库之上的;

CEPHFS:文件存储,它直接操作Ceph 底层的RADOS,不经过LIBRADOS库;

以上这些使用场景,都是构建在RADOS之上的,Ceph 底层 RADOS:可靠、自治、分布式对象存储,包含自我修复、自我管理、智能存储节点。

THE CEPH STORAGE CLUSTER

Ceph provides an infinitely scalable Ceph Storage Cluster based upon RADOS, which you can read about in RADOS - A Scalable, Reliable Storage Service for Petabyte-scale Storage Clusters.

Ceph 提供了一个基于 RADOS 的无限可扩展的Ceph存储集群。

A Ceph Storage Cluster consists of two types of daemons:

Ceph Monitor
Ceph OSD Daemon

Ceph 集群包括两种守护进程,一个是Ceph Monitor 和Ceph OSD Daemon守护进程。

Ceph Monitor

它是集群的核心组件,它主要负责集群状态的情况,Ceph 客户端从Ceph monitor中得到整个集群的运行状态情况,从得到的状态信息中,就可以对集群进行读写操作,在生产环境中,Ceph monitor非常重要,我们需要确保它的高可靠性,Ceph monitor一般部署为奇数个,使用 Paxos 协议进行选举。

A Ceph Monitor maintains a master copy of the cluster map. A cluster of Ceph monitors ensures high availability should a monitor daemon fail. Storage cluster clients retrieve a copy of the cluster map from the Ceph Monitor.

Ceph Monitor 维护群集映射的一个主副本,如果集群中的一个monitor 守护程序发生故障,则Ceph monitor 群集可确保高可用性(这里也可以看出ceph monitor 需要部署为集群形式)。存储群集客户端从Ceph monitor 检索集群映射的副本。

Ceph OSD Daemon

它是真正存储数据的地方,数据存储到Ceph 集群中,最终会落到OSD上面;OSD 会定期把自己的状态,上报给Monitor,或者把异常汇报给Monitor,或者异常恢复了汇报给Monitor,Monitor也会定期检查OSD的状态,当检查到 OSD 检查不到,异常时,就会触发底层 RADOS 数据的重分配,自动修复机制,确保数据完整性。

A Ceph OSD Daemon checks its own state and the state of other OSDs and reports back to monitors.

Ceph OSD 守护程序检查其自身的状态以及其他OSD的状态,并向 monitors 报告。

客户端通过Monitor拿到了整个集群的状态表,客户端和OSD Daemon 就会使用CRUSH算法就能定位到数据最终的存放位置,客户端直接对 OSD进行读写的,后面的读写是不经过 Monitor的。

Storage cluster clients and each Ceph OSD Daemon use the CRUSH algorithm to efficiently compute information about data location, instead of having to depend on a central lookup table. Ceph’s high-level features include providing a native interface to the Ceph Storage Cluster via librados, and a number of service interfaces built on top of librados.

存储集群客户端和每个 Ceph OSD 守护程序都使用 CRUSH 算法来有效地计算有关数据位置的信息,而不必依赖中央查找表。Ceph的高级功能包括通过librados提供原生的接口到 Ceph 存储集群,以及在 librados 之上构建的许多服务接口。

CLUSTER MAP(集群状态表)

Ceph depends upon Ceph Clients and Ceph OSD Daemons having knowledge of the cluster topology, which is inclusive of 5 maps collectively referred to as the “Cluster Map”:

Ceph依赖于具有集群拓扑知识的Ceph客户端和Ceph OSD守护程序,其中包括5个映射,这些映射被统称为“集群映射”:

    The Monitor Map: Contains the cluster fsid, the position, name address and port of each monitor. It also indicates the current epoch, when the map was created, and the last time it changed. To view a monitor map, execute ceph mon dump.

    Monitor 映射:包含群集fsid,每个监视器的位置,名称地址和端口。它还表示当前状态信息,创建映射的时间以及上次更改的时间。要查看监视器映射,请执行ceph mon dump。

2.The OSD Map: Contains the cluster fsid, when the map was created and last modified, a list of pools, replica sizes, PG numbers, a list of OSDs and their status (e.g., up, in). To view an OSD map, execute ceph osd dump.

OSD映射:包含群集fsid,映射创建时间以及最后修改时间,pools 列表,副本大小,PG号,OSD列表及其状态。要查看OSD映射,请执行ceph osd dump。

3.The PG Map: Contains the PG version, its time stamp, the last OSD map epoch, the full ratios, and details on each placement group such as the PG ID, the Up Set, the Acting Set, the state of the PG (e.g., active + clean), and data usage statistics for each pool.

PG映射:包含PG版本,及其时间戳,最后一个OSD Map 元信息,完整比例以及每个放置组的详细信息,例如PG ID,Up Set,Acting Set,PG的状态(例如 ,活动+清除)以及每个池的数据使用情况统计信息。

4.The CRUSH Map: Contains a list of storage devices, the failure domain hierarchy (e.g., device, host, rack, row, room, etc.), and rules for traversing the hierarchy when storing data. To view a CRUSH map, execute ceph osd getcrushmap -o {filename}; then, decompile it by executing crushtool -d {comp-crushmap-filename} -o {decomp-crushmap-filename}. You can view the decompiled map in a text editor or with cat.

CRUSH映射:包含存储设备,故障域层次结构(例如,设备,主机,机架,行,机房等)的列表,以及在存储数据时遍历层次结构的规则。要查看CRUSH映射,请执行ceph osd getcrushmap -o {filename} 或者通过crushtool -d {comp-crushmap-filename} -o {decomp-crushmap-filename}对其进行反编译。您可以在文本编辑器中或使用 cat 命令查看反编译的地图。

5.The MDS Map: Contains the current MDS map epoch, when the map was created, and the last time it changed. It also contains the pool for storing metadata, a list of metadata servers, and which metadata servers are up and in. To view an MDS map, execute ceph fs dump.

MDS映射:包含当前MDS映射元信息,创建映射的时间以及上次更改的时间。它还包含用于存储元数据的池,元数据服务器列表以及启用和启用的元数据服务器。要查看MDS映射,请执行ceph fs dump。(这个主要是 cephfs 文件系统使用)

Each map maintains an iterative history of its operating state changes. Ceph Monitors maintain a master copy of the cluster map including the cluster members, state, changes, and the overall health of the Ceph Storage Cluster.

每个映射都维护其操作状态更改的迭代历史记录。Ceph Monitors 维护群集映射的主副本,包括群集成员,状态,更改以及Ceph存储群集的整体运行状况。

Ceph 数据写入流程

Ceph 存储中一切皆对象,一个文件先被切割成多个objects(默认4M一个Object),然后每个对象都有一个Oid(Object ID),这些Objects需要存放在PG组里面,PG组可以理解为装载Object的文件夹,Object 对象通过hash和掩码运算,最终得到一个pgid,得到你最终落到哪个PG上面,一个PG上面会存储很多的Object,之后再通过 CRUSH算法,把pg分配到集群中的OSD节点上,根据CRUSH使用算法的不同,也会落到不同的OSD上面;CURSH 默认是使用host为单位。

1.Ceph 基础篇 - 存储基础及架构介绍的相关教程结束。

《1.Ceph 基础篇 - 存储基础及架构介绍.doc》

下载本文的Word格式文档,以方便收藏与打印。