掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
Ceph Pool操作總結(jié)一個ceph集群可以有多個pool,每個pool是邏輯上的隔離單位,不同的pool可以有完全不一樣的數(shù)據(jù)處理方式,比如Replica Size(副本數(shù))、Placement Groups、CRUSH Rules、快照、所屬者等。

打印pool列表
- ceph osd lspools
創(chuàng)建pool
通常在創(chuàng)建pool之前,需要覆蓋默認(rèn)的pg_num,官方推薦:
本文的測試環(huán)境只有2個OSD,因此設(shè)置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
設(shè)置pool配額
支持object個數(shù)配額以及容量大小配額。
設(shè)置允許***object數(shù)量為100:
- ceph osd pool set-quota test-pool max_objects 100
設(shè)置允許容量限制為10GB:
- ceph osd pool set-quota test-pool max_bytes $((10 * 1024 * 1024 * 1024))
取消配額限制只需要把對應(yīng)值設(shè)為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中曾經(jīng)創(chuàng)建了rbd對象(即使當(dāng)前刪除了所有的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
設(shè)置pool
通過以下語法設(shè)置pool的元數(shù)據(jù):
- ceph osd pool set {pool-name} {key} {value}
比如設(shè)置pool的冗余副本數(shù)量為3:
- ceph osd pool set test-pool size 3
其他配置項參考文檔。
通過get操作能夠獲取pool的配置值,比如獲取當(dāng)前pg_num:
- ceph osd pool get test-pool pg_num
獲取當(dāng)前副本數(shù):
- ceph osd pool get test-pool size
【本文是專欄作者“付廣平”的原創(chuàng)文章,如需轉(zhuǎn)載請通過獲得聯(lián)系】
戳這里,看該作者更多好文

我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流