1. 程式人生 > 其它 >1.Ceph 基礎篇 - 儲存基礎及架構介紹

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