Ceph的架构(一)
2019獨角獸企業重金招聘Python工程師標準>>>
The Ceph storage cluster
Ceph的集群由兩種類型的守護進程組(daemon)成(通常是一個host一個daemon):
????Ceph Monitor & Ceph OSD Daemon
一個ceph的monitor維護了整個cluster map,多個monitor組成的集群可以避免一個Monitor崩潰的單點失效問題。存儲集群的用戶可以從monitor處拷貝一份cluster map作為緩存。
一個Ceph OSD Daemon檢查它自己以及其他OSD的狀態并且報告給monitor。
存儲集群的Client和每個Ceph OSD Daemon使用crush算法來高效地計算關于數據位置的信息,而不是通過一個巨大的中心化的搜索表。
1. 存儲數據
??????? Ceph從Ceph client處獲取數據——無論這些數據是從Ceph塊設備(Ceph Block Device),Ceph對象存儲(Ceph Object Storage),Ceph文件系統(Ceph Filesystem)還是一個你使用librados創建的自定義存儲方式——并且將它們作為對象存儲起來。每個對象對應著文件系統中的一個文件,這些文件存儲在Ceph存儲設備(OSD)中。Ceph OSD守護進程負責處理在磁盤上的讀寫操作。
??????? Ceph OSD Daemon將所有的數據作為對象存儲在一個平坦的空間內(即沒有目錄那種層次結構)。一個對象包括一個標識符,二進制數據,以及由name/value對組成的元數據組成。數據的語義完全由Ceph client決定。比如Ceph Filesystem會使用元數據存儲文件屬性,比如文件的擁有者,創建時間,上一次修改時間等等。
??????? 注意,一個對象的ID在整個集群中都是獨一無二的,而不是僅僅局限在本地文件系統中。
???????
2. 可擴展性與高可用性
??????? 在傳統的架構當中,客戶端是通過訪問一個中心化的組建來訪問整個復雜的子系統,這種方式很容易造成單點失效問題,已經性能和可擴展性的瓶頸問題。Ceph則采用了去中心化的思想,讓客戶端直接與OSD Daemon交換信息。Ceph會在多個節點上保持同一個數據的備份,來保證可用性。Monitor也使用了多個節點構成一個集群,來保證可用性。
??????? 為了實現去中心化,Ceph使用了CRUSH算法。
CRUSH介紹
??????? Ceph Client和Ceph OSD Daemon都使用crush算法來高效地計算對象位置的信息,而不是依賴于一個中心化的查詢表。對于crush的詳細介紹,可以看?CRUSH - Controlled, Scalable, Decentralized Placement of Replicated Data這篇論文。
Cluster Map
??????? Ceph clients和Ceph OSD Daemons都擁有關于集群的拓撲(topology)信息,Ceph依賴于這些信息。這些拓撲信息包含了五個map,分別為:
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.
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.
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.
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.
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?mdsdump.
??????? 這個五個map被合稱為cluster map。
????????每個map都維護了一個它自身操作狀態變化的歷史記錄。Ceph Monitor維護了一個clsuter map的主要備份。 ????
???????????
3. 高可用性Monitor
??????? 在Ceph客戶端讀寫數據之前,客戶端必須聯系monitor并從其獲取最近的cluster map的一份拷貝。為了避免單點失效問題(當monitor失效的時候,客戶端無法進行讀寫),Ceph支持monitor構成的集群。當一個或者多個monitor宕機的時候,Ceph并不會整體失效。
????????
4. 高可用性認證
??????? 為了辨別用戶和保護系統不受中間人(man-in-the-middle)攻擊,Ceph提供cephx認證系統來認證用戶和daemon。注意cephx系統并不解決在傳輸或者其他過程中的數據加密過程。
??????? Cephx使用共享密鑰來進行認證,這意味著客戶端和monitor集群都擁有客戶的密鑰的一份拷貝。這個認證協議允許雙方能夠向對方證明自己的身份,而不用泄漏這個密鑰。
??????? 由于Ceph是可以擴展的,Ceph從設計上就避免去通過一個中心化的接口去訪問Ceph對象存儲設施,這意味這Ceph客戶端能夠直接訪問OSD。Cephx協議的運轉方式類似于Kerberos。
????????A user/actor invokes a Ceph client to contact a monitor. Unlike Kerberos, each monitor can authenticate users and distribute keys, so there is no single point of failure or bottleneck when usingcephx. The monitor returns an authentication data structure similar to a Kerberos ticket that contains a session key for use in obtaining Ceph services. This session key is itself encrypted with the user’s permanent secret key, so that only the user can request services from the Ceph monitor(s). The client then uses the session key to request its desired services from the monitor, and the monitor provides the client with a ticket that will authenticate the client to the OSDs that actually handle data. Ceph monitors and OSDs share a secret, so the client can use the ticket provided by the monitor with any OSD or metadata server in the cluster. Like Kerberos,?cephx?tickets expire, so an attacker cannot use an expired ticket or session key obtained surreptitiously. This form of authentication will prevent attackers with access to the communications medium from either creating bogus messages under another user’s identity or altering another user’s legitimate messages, as long as the user’s secret key is not divulged before it expires.
??????? 為了使用cephx,一個管理員必須首先設置用戶。在下列圖當中,client.admin用戶(應該是位于客戶端)發起一個ceph auth get-or-create-key指令來生成一個用戶名和密鑰。Ceph的auth子系統生成一個用戶名和密鑰后,會在monitor上存儲一份拷貝,并傳輸回給client.admin用戶。這意味著客戶端和monitor共享了一個密鑰。
????????
????????To authenticate with the monitor, the client passes in the user name to the monitor, and the monitor generates a session key and encrypts it with the secret key associated to the user name. Then, the monitor transmits the encrypted ticket back to the client. The client then decrypts the payload with the shared secret key to retrieve the session key. The session key identifies the user for the current session. The client then requests a ticket on behalf of the user signed by the session key. The monitor generates a ticket, encrypts it with the user’s secret key and transmits it back to the client.?The client decrypts the ticket and uses it to sign requests to OSDs and metadata servers throughout the cluster.
????????
??????? Cephx協議對客戶端和Ceph server之間的正在進行的通信都會進行認證。在初始認證之后,客戶端和服務器之間的每一個消息,都會被ticket簽名。
????????
Smart daemon enable hyperscale 關于大規模擴展性的問題
??????? Ceph使用了去中心化的思想:
??????? Ceph OSD和Ceph client都是cluster-aware,即他們一開始就知道整個集群的存在,也知道其他的節點的信息。和Ceph client一樣,每個Ceph OSD Daemon都能感知到集群里其他OSD Daemon的信息。這使得OSD Daemon能夠直接與其他的OSD Daemon和monitor交換信息。除此之外,這種機制也能夠使client直接訪問OSD Daemon。
??????? Ceph client,monitor和OSD他們之間能夠直接互相訪問的能力意味著OSD Daemon能夠充分利用每個節點的CPU和RAM,將中心化的任務分攤到各個節點中去。這種的設計的好處如下:
??????? 1.?讓OSD直接服務client??
????????這個設計移除了訪問的單點失效問題,并且提高了性能和可擴展性。
??????? 2.?OSD membership and status??
????????Ceph OSD Daemon加入一個cluster之后,會主動報告它的狀態。OSD Daemon在掛掉的時候不能主動通知monitor它宕機了,于是Ceph monitor會周期性地ping一下OSD Daemon,檢查它是否在運行。Ceph同時也讓OSD Daemon來檢查它附近的OSD Daemon是否宕機,來更新cluster map并且報告給monitor。這意味著ceph monitor可以做的更加輕量級化。
??????? 3.?數據擦除? data srcubbing
??????? data scrubbing能夠維持數據的一致性和清潔。
????????4. 復制(replication)
??????? 和Ceph客戶端一樣,Ceph OSD Daemon使用crush算法,但不同之處在于OSD Daemon使用crush來計算數據的拷貝應該被放在哪里。在一個典型的寫場景中,一個client使用crush算法來計算存儲對象的位置,將這個對象映射到一個pool和placement group,然后查詢CRUSH map來確定這個placement group的primary OSD。
轉載于:https://my.oschina.net/u/1047616/blog/506039
總結
以上是生活随笔為你收集整理的Ceph的架构(一)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java构造和解析Json数据之org.
- 下一篇: 如何读取jar包外的properties