Ceph Pool操作總結(jié)
Ceph Pool操作總結(jié)一個(gè)ceph集群可以有多個(gè)pool,每個(gè)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,官方推薦:
- 若少于5個(gè)OSD, 設(shè)置pg_num為128。
- 5~10個(gè)OSD,設(shè)置pg_num為512。
- 10~50個(gè)OSD,設(shè)置pg_num為4096。
- 超過(guò)50個(gè)OSD,可以參考pgcalc計(jì)算。
本文的測(cè)試環(huán)境只有2個(gè)OSD,因此設(shè)置pg_num為128。
- osd pool default pg num = 128
- osd pool default pgp num = 128
創(chuàng)建pool語(yǔ)法:
- 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)建一個(gè)test-pool,pg_num為128:
- ceph osd pool create test-pool 128
設(shè)置pool配額
支持object個(gè)數(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))
取消配額限制只需要把對(duì)應(yīng)值設(shè)為0即可。
重命名pool
- ceph osd poolrename test-pool test-pool-new
刪除pool
刪除一個(gè)pool會(huì)同時(shí)清空pool的所有數(shù)據(jù),因此非常危險(xiǎn)。(和rm -rf /類(lèi)似)。因此刪除pool時(shí)ceph要求必須輸入兩次pool名稱,同時(shí)加上--yes-i-really-really-mean-it選項(xiàng)。
- ceph osd pool delete test-pool test-pool --yes-i-really-really-mean-it
查看pool狀態(tài)信息
- rados df
創(chuàng)建快照
ceph支持對(duì)整個(gè)pool創(chuàng)建快照(和Openstack Cinder一致性組區(qū)別?),作用于這個(gè)pool的所有對(duì)象。但注意ceph有兩種pool模式:
- Pool Snapshot,我們即將使用的模式。創(chuàng)建一個(gè)新的pool時(shí),默認(rèn)也是這種模式。
- Self Managed Snapsoht,用戶管理的snapshot,這個(gè)用戶指的是librbd,也就是說(shuō),如果在pool創(chuàng)建了rbd實(shí)例就自動(dòng)轉(zhuǎn)化為這種模式。
這兩種模式是相互排斥,只能使用其中一個(gè)。因此,如果pool中曾經(jīng)創(chuàng)建了rbd對(duì)象(即使當(dāng)前刪除了所有的image實(shí)例)就不能再對(duì)這個(gè)pool做快照了。反之,如果對(duì)一個(gè)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
通過(guò)以下語(yǔ)法設(shè)置pool的元數(shù)據(jù):
- ceph osd pool set {pool-name} {key} {value}
比如設(shè)置pool的冗余副本數(shù)量為3:
- ceph osd pool set test-pool size 3
其他配置項(xiàng)參考文檔。
通過(guò)get操作能夠獲取pool的配置值,比如獲取當(dāng)前pg_num:
- ceph osd pool get test-pool pg_num
獲取當(dāng)前副本數(shù):
- ceph osd pool get test-pool size
【本文是51CTO專(zhuān)欄作者“付廣平”的原創(chuàng)文章,如需轉(zhuǎn)載請(qǐng)通過(guò)51CTO獲得聯(lián)系】