Cephfs簡介
Cephfs是ceph提供的兼容POSIX協議的文件系統,對比rbd和rgw功能,這個是ceph里最晚滿足production ready的一個功能,它底層還是使用rados存儲數據。
Cephfs架構
Cephfs使用方法
- Cephfs kernel module
- Cephfs-fuse
從上面的架構可以看出,Cephfs-fuse的IO path比較長,性能會比Cephfs kernel module的方式差一些;
Client端訪問Cephfs的流程

- client端與mds節點通訊,獲取metadata信息(metadata也存在osd上)
- client直接寫數據到osd
mds部署
使用ceph-deploy部署ceph mds很方便,只需要簡單的一條命令就搞定,不過它依賴之前ceph-deploy時候生成的一些配置和keyring文件;
在之前部署ceph集群的節點目錄,執行ceph-deploy mds create:
# ceph-deploy --overwrite-conf mds create server1:mds-daemon-1 // 去節點檢查下daemon [root@server1 yangguanjun]# ps aux | grep ceph-mds ceph 1138 0.0 0.0 3011880 14301 ? Ssl 10:21 0:00 /usr/bin/ceph-mds -f --cluster ceph --id mds-daemon-2 --setuser ceph --setgroup ceph
創建Cephfs
創建第一個Cephfs
# ceph osd pool create Cephfs_data 512 512 // 創建data pool pool 'Cephfs_data' created # ceph osd pool create Cephfs_metadata 512 512 // 創建metadata pool pool 'Cephfs_metadata' created # ceph fs new tstfs Cephfs_metadata Cephfs_data // 創建Cephfs new fs with metadata pool 10 and data pool 9 # ceph fs ls name: tstfs, metadata pool: Cephfs_metadata, data pools: [Cephfs_data ]
創建第二個Cephfs
默認Cephfs是不支持多個fs的,這個還是試驗階段的feature,需要打開 enable_multiple 的flag
# ceph osd pool create Cephfs_metadata2 512 512 pool 'Cephfs_metadata2’ created # ceph osd pool create Cephfs_data2 512 512 pool 'Cephfs_data2’ created # ceph fs new tstfs2 Cephfs_metadata2 Cephfs_data2 Error EINVAL: Creation of multiple filesystems is disabled. To enable this experimental feature, use 'ceph fs flag set enable_multiple true' # ceph fs flag set enable_multiple true Warning! This feature is experimental.It may cause problems up to and including data loss.Consult the documentation at ceph.com, and if unsure, do not proceed.Add --yes-i-really-mean-it if you are certain. # ceph fs flag set enable_multiple true --yes-i-really-mean-it # ceph fs new tstfs2 Cephfs_metadata2 Cephfs_data2 new fs with metadata pool 11 and data pool 12
查看mds狀態
ceph的mds是一個單獨的daemon,它只能服務於一個Cephfs,若Cephfs指定多個rank了,它只能服務於其中一個rank
# ceph mds stat e8: tstfs-1/1/1 up tstfs2-0/0/1 up {[tstfs:0]=mds-daemon-1=up:active}
對輸出解釋如下:
e8
: e標識epoch,8是epoch號tstfs-1/1/1 up
:tstfs
是Cephfs名字,后面的三個1分別是mds_map.in/mds_map.up/mds_map.max_mds
,up
是Cephfs狀態{[tstfs:0]=mds-daemon-1=up:active}
:[tstfs:0]
指tstfs的rank 0,mds-daemon-1
是服務tstfs的mds daemon name,up:active
是Cephfs的狀態為 up & active
從上面的輸出可以看出,兩個Cephfs只有tstfs
是active的,它的mds daemon為mds-daemon-1
在ceph-deploy節點添加mds-daemon-2-1
# ceph mds stat e11: tstfs-1/1/1 up tstfs2-1/1/1 up {[tstfs2:0]=mds-daemon-2-1=up:active,[tstfs:0]=mds-daemon-1=up:active}
添加新的mds daemon后,它會自動服務於一個沒有mds daemon的Cephfs
在ceph-deploy節點添加mds-daemon-2-2
# ceph mds stat e12: tstfs-1/1/1 up tstfs2-1/1/1 up {[tstfs2:0]=mds-daemon-2=up:active,[tstfs:0]=mds-daemon=up:active}, 1 up:standby
又添加一個新的mds daemon后,它會處於standby狀態,若前兩個mds daemon出問題,它會頂替上去,頂替的規則可以配置,詳情參考文章:http://docs.ceph.com/docs/master/Cephfs/standby/#configuring-standby-daemons
查看節點上的兩個mds daemon進程
[root@server2 yangguanjun]# ps aux | grep ceph-mds ceph 2362 0.0 0.0 3061884 14604 ? Ssl 10:26 0:00 /usr/bin/ceph-mds -f --cluster ceph --id mds-daemon-2-1 --setuser ceph --setgroup ceph ceph 3031 0.0 0.0 3390588 13872 ? Ssl 10:27 0:00 /usr/bin/ceph-mds -f --cluster ceph --id mds-daemon-2-2 --setuser ceph --setgroup ceph
Cephfs的使用
mount & umount
# mount -t ceph 10.10.1.2:6789:/ /mnt/tstfs2/ # umount /mnt/tstfs2 # mount | grep tstfs2 10.10.1.1:6789:/ on /mnt/tstfs2 type ceph (rw,relatime)
是否支持多個Cephfs?
前面我們提到可以在一個ceph cluster里創建多個Cephfs,指定不同的data/metadata pool,有不同的mds daemon服務,但如何使用不同的Cephfs呢?
-
kernel Cephfs
# mount -t ceph 10.10.1.2:6789:/ /mnt/tstfs2/ -o mds_namespace=tstfs mount error 22 = Invalid argument
這個問題的bug信息:http://tracker.ceph.com/issues/18161
-
ceph-fuse
待驗證
查看Cephfs狀態
# ceph fs get tstfs Filesystem 'tstfs' (1) fs_name tstfs epoch 13 flags 0 created 2017-05-23 10:21:55.889234 modified 2017-05-23 10:21:55.889234 tableserver 0 root 0 session_timeout 60 session_autoclose 300 max_file_size 1099511627776 last_failure 0 last_failure_osd_epoch 0 compat compat={},rocompat={},incompat={1=base v0.20,2=client writeable ranges,3=default file layouts on dirs,4=dir inode in separate object,5=mds uses versioned encoding,6=dirfrag is stored in omap,8=file layout v2} max_mds 1 in 0 up {0=4456} failed damaged stopped data_pools 9 metadata_pool 10 inline_data disabled 4456: 10.10.1.1:6820/1655250084 'mds-daemon-1' mds.0.4 up:active seq 484
配置Cephfs的multi mds
Cephfs的multi mds屬性還不是production ready,不要用在生成環境哦,自己測試下玩玩就行
# ceph mds stat e13: tstfs-1/1/1 up tstfs2-1/1/1 up {[tstfs2:0]=mds-daemon-2-1=up:active,[tstfs:0]=mds-daemon-1=up:active}, 1 up:standby # ceph fs set tstfs allow_multimds true --yes-i-really-mean-it # ceph fs set tstfs max_mds 2 # ceph mds stat e17: tstfs-2/2/2 up tstfs2-1/1/1 up {[tstfs2:0]=mds-daemon-2-1=up:active,[tstfs:0]=mds-daemon-1=up:active,[tstfs:1]=mds-daemon-2-2=up:active}
從上面輸出可以看出,設置tstfs
的max_mds
為2后,它會自動尋找一個standby的mds daemon服務,現在看到的tstfs
的信息為:
tstfs-2/2/2 up
和[tstfs:0]=mds-daemon-1=up:active,[tstfs:1]=mds-daemon-2-2=up:active
刪除Cephfs和mds
機器上停止ceph mds服務 # systemctl stop ceph-mds.target 刪除Cephfs,有mds daemons的Cephfs刪除會報錯,然后去mds daemon機器上停止mds服務即可 # ceph fs rm tstfs Error EINVAL: all MDS daemons must be inactive before removing filesystem # ceph fs rm tstfs2 Error EPERM: this is a DESTRUCTIVE operation and will make data in your filesystem permanentlyinaccessible. Add --yes-i-really-mean-it if you are sure you wish to continue. # ceph fs rm tstfs2 --yes-i-really-mean-it # ceph fs rm tstfs --yes-i-really-mean-it 刪除ceph nonactive mds,mds的id默認從0開始,指定不存在的id並不會報錯 # ceph mds rm 0 mds gid 0 dne # ceph mds rm 1 mds gid 1 dne # ceph mds rm 2 mds gid 2 dne 刪除Cephfs使用的pool # ceph osd pool delete Cephfs_metadata Cephfs_metadata --yes-i-really-really-mean-it ...
參考:
2、http://docs.ceph.com/docs/master/cephfs/