Cephfs使用

 Cephfs简介

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

Cephfs架构

 

Cephfs使用方法

  1. Cephfs kernel module
  2. Cephfs-fuse

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

Client端访问Cephfs的流程

 

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

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值