創(chuàng)建CephFS文件系統(tǒng)
Ceph文件系統(tǒng)至少需要兩個(gè)RADOS池琐馆,一個(gè)用于數(shù)據(jù)滋饲,一個(gè)用于元數(shù)據(jù)。在配置這些池時(shí)俯树,您可以考慮:為元數(shù)據(jù)池使用較高的復(fù)制級(jí)別,因?yàn)樵摮刂械娜魏螖?shù)據(jù)丟失都可能導(dǎo)致整個(gè)文件系統(tǒng)不可訪問菩浙。
為元數(shù)據(jù)池使用低延遲存儲(chǔ)(如ssd)陆淀,因?yàn)檫@將直接影響在客戶機(jī)上觀察到的文件系統(tǒng)操作延遲疫蔓。用于創(chuàng)建文件系統(tǒng)的數(shù)據(jù)池是“默認(rèn)”數(shù)據(jù)池和存儲(chǔ)所有inode回溯信息的位置,用于硬鏈接管理和災(zāi)難恢復(fù)。
因此樱哼,在CephFS中創(chuàng)建的所有inode在默認(rèn)數(shù)據(jù)池中至少有一個(gè)對(duì)象茄唐。如果文件系統(tǒng)計(jì)劃使用擦寫編碼的池蚁廓,那么通常最好為默認(rèn)數(shù)據(jù)池使用復(fù)制池腿时,以提高用于更新回溯的小對(duì)象寫和讀性能满败。
另外净嘀,還可以添加另一個(gè)可在目錄和文件的整個(gè)層次結(jié)構(gòu)上使用的擦除編碼的數(shù)據(jù)池(也請(qǐng)參閱擦除代碼)。
創(chuàng)建文件系統(tǒng)
bash> ceph osd pool create cephfs_data #創(chuàng)建數(shù)據(jù)pool
bash> ceph osd pool create cephfs_metadata #創(chuàng)建元數(shù)據(jù)pool
bash> ceph fs new <fs_name> <metadata> <data> #創(chuàng)建文件系統(tǒng)
example:
ceph fs new mycephfs cephfs_metadata cephfs_data
bash> ceph fs ls #查看文件系統(tǒng)
bash> ceph mds stat #查看mds狀態(tài)
如果想用糾刪碼:
bash> ceph osd erasure-code-profile get default #醒看糾刪碼默認(rèn)配置
bash> ceph osd pool create cephfs_data erasure #創(chuàng)建使用糾刪除碼的對(duì)象池
bash> ceph osd pool set cephfs_data allow_ec_overwrites true #開啟糾刪碼覆蓋功能
掛載文件系統(tǒng)
- 在掛載CephFS之前侠讯,確蓖诓兀客戶機(jī)主機(jī)(必須掛載和使用CephFS的地方)擁有Ceph配置文件的副本(即Ceph文件)和CephX用戶的一個(gè)密鑰環(huán),該用戶擁有訪問MDS的權(quán)限厢漩。這兩個(gè)文件必須已經(jīng)存在于Ceph MON所在的主機(jī)上膜眠。
- 創(chuàng)建client秘鑰
bash> ceph fs authorize <fs_name> client.<client_id> <path-in-cephfs> rw
example:
ceph fs authorize mycephfs client.001 / rw > /etc/ceph/ceph.fs.client.001.keyring
- 掛協(xié)CephFs
example:
mount -t ceph 192.168.0.1:6789,192.168.0.2:6789:/ /mnt/mycephfs -o name=foo,secret=AQATSKdNGBnwLhAAnNDKnH65FmVKpXZJVasUeQ==
bash> mount -t ceph 192.168.10.42:6789:/ /home/mycephfs -o name=001,secret=AQCndpZf5YaPDRAA6TKEOHmaGXMcvLO/yNHUqw==
or
bash> mount -t ceph 192.168.10.42:6789:/ /home/mycephfs -o name=001,secret=/etc/ceph/client.001.secret
如果掛載的時(shí)候出錯(cuò),使用dmesg
查看錯(cuò)誤:
libceph: mon0 192.168.10.42:6789 feature set mismatch, my 107b84a842aca < server's 40107b84a842aca, missing 400000000000000
[611629.824664] libceph: mon0 192.168.10.42:6789 missing required protocol features
如果有此類提示溜嗜,則說明客戶端(執(zhí)行掛載的機(jī)器宵膨,與集群的版本不匹配):
bash> ceph osd crush show-tunables
---
{
"choose_local_tries": 0,
"choose_local_fallback_tries": 0,
"choose_total_tries": 50,
"chooseleaf_descend_once": 1,
"chooseleaf_vary_r": 1,
"chooseleaf_stable": 1,
"straw_calc_version": 1,
"allowed_bucket_algs": 54,
"profile": "jewel",
"optimal_tunables": 1,
"legacy_tunables": 0,
"minimum_required_version": "jewel",
"require_feature_tunables": 1,
"require_feature_tunables2": 1,
"has_v2_rules": 0,
"require_feature_tunables3": 1,
"has_v3_rules": 0,
"has_v4_buckets": 1,
"require_feature_tunables5": 1,
"has_v5_rules": 0
}
bash> ceph osd crush tunables hammer #將最低要求客戶端版本限制為hammer
bash> ceph osd crush show-tunables
---
{
"choose_local_tries": 0,
"choose_local_fallback_tries": 0,
"choose_total_tries": 50,
"chooseleaf_descend_once": 1,
"chooseleaf_vary_r": 1,
"chooseleaf_stable": 0,
"straw_calc_version": 1,
"allowed_bucket_algs": 54,
"profile": "hammer",
"optimal_tunables": 0,
"legacy_tunables": 0,
"minimum_required_version": "hammer",
"require_feature_tunables": 1,
"require_feature_tunables2": 1,
"has_v2_rules": 0,
"require_feature_tunables3": 1,
"has_v3_rules": 0,
"has_v4_buckets": 1,
"require_feature_tunables5": 0,
"has_v5_rules": 0
}
做完以上步驟后,再次掛載則成功了炸宵。在client上可以看到:
bash> df -h
---
192.168.10.42:6789:/ 60G 3.3G 57G 6% /home/mycephfs