cephfs介绍和功能测试

cephfs简介

cephfs是ceph提供的兼容POSIX协议的文件系统,对比rbd和rgw功能,这个是ceph里最晚满足production ready的一个功能,它底层还是使用rados存储数据

cephfs的架构

cephfs介绍和功能测试_第1张图片
cephfs arch

使用cephfs的两种方式

  1. cephfs kernel module
  2. cephfs-fuse

从上面的架构可以看出,cephfs-fuse的IO path比较长,性能会比cephfs kernel module的方式差一些;

client端访问cephfs的流程

cephfs介绍和功能测试_第2张图片
cephfs cilent access
  1. client端与mds节点通讯,获取metadata信息(metadata也存在osd上)
  2. 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_mdsup是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呢?

  1. 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

  2. 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}

从上面输出可以看出,设置tstfsmax_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
...

参考

http://docs.ceph.com/docs/master/cephfs/
https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html-single/ceph_file_system_guide_technology_preview/

你可能感兴趣的:(cephfs介绍和功能测试)