1.Ceph 基礎篇 - 存儲基礎及架構介紹


文章轉載自: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個映射,這些映射被統稱為“集群映射”:

  1. 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為單位。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM