Ceph Pool操作總結
Ceph Pool操作總結一個ceph集群可以有多個pool,每個pool是邏輯上的隔離單位,不同的pool可以有完全不一樣的數(shù)據(jù)處理方式,比如Replica Size(副本數(shù))、Placement Groups、CRUSH Rules、快照、所屬者等。
打印pool列表
- ceph osd lspools
創(chuàng)建pool
通常在創(chuàng)建pool之前,需要覆蓋默認的pg_num,官方推薦:
- 若少于5個OSD, 設置pg_num為128。
- 5~10個OSD,設置pg_num為512。
- 10~50個OSD,設置pg_num為4096。
- 超過50個OSD,可以參考pgcalc計算。
本文的測試環(huán)境只有2個OSD,因此設置pg_num為128。
- osd pool default pg num = 128
- osd pool default pgp num = 128
創(chuàng)建pool語法:
- ceph osd pool create {pool-name} {pg-num} [{pgp-num}] [replicated] \
- [crush-ruleset-name] [expected-num-objects]
- ceph osd pool create {pool-name} {pg-num} {pgp-num} erasure \
- [erasure-code-profile] [crush-ruleset-name] [expected_num_objects]
創(chuàng)建一個test-pool,pg_num為128:
- ceph osd pool create test-pool 128
設置pool配額
支持object個數(shù)配額以及容量大小配額。
設置允許***object數(shù)量為100:
- ceph osd pool set-quota test-pool max_objects 100
設置允許容量限制為10GB:
- ceph osd pool set-quota test-pool max_bytes $((10 * 1024 * 1024 * 1024))
取消配額限制只需要把對應值設為0即可。
重命名pool
- ceph osd poolrename test-pool test-pool-new
刪除pool
刪除一個pool會同時清空pool的所有數(shù)據(jù),因此非常危險。(和rm -rf /類似)。因此刪除pool時ceph要求必須輸入兩次pool名稱,同時加上--yes-i-really-really-mean-it選項。
- ceph osd pool delete test-pool test-pool --yes-i-really-really-mean-it
查看pool狀態(tài)信息
- rados df
創(chuàng)建快照
ceph支持對整個pool創(chuàng)建快照(和Openstack Cinder一致性組區(qū)別?),作用于這個pool的所有對象。但注意ceph有兩種pool模式:
- Pool Snapshot,我們即將使用的模式。創(chuàng)建一個新的pool時,默認也是這種模式。
- Self Managed Snapsoht,用戶管理的snapshot,這個用戶指的是librbd,也就是說,如果在pool創(chuàng)建了rbd實例就自動轉化為這種模式。
這兩種模式是相互排斥,只能使用其中一個。因此,如果pool中曾經(jīng)創(chuàng)建了rbd對象(即使當前刪除了所有的image實例)就不能再對這個pool做快照了。反之,如果對一個pool做了快照,就不能創(chuàng)建rbd image了。
- ceph osd pool mksnap test-pool test-pool-snapshot
刪除快照
- ceph osd pool rmsnap test-pool test-pool-snapshot
設置pool
通過以下語法設置pool的元數(shù)據(jù):
- ceph osd pool set {pool-name} {key} {value}
比如設置pool的冗余副本數(shù)量為3:
- ceph osd pool set test-pool size 3
其他配置項參考文檔。
通過get操作能夠獲取pool的配置值,比如獲取當前pg_num:
- ceph osd pool get test-pool pg_num
獲取當前副本數(shù):
- ceph osd pool get test-pool size
【本文是51CTO專欄作者“付廣平”的原創(chuàng)文章,如需轉載請通過51CTO獲得聯(lián)系】