ceph中强制要求data与metadata分开,创建CephFS需要一个data池与一个MDS元数据池
元数据服务器MDS 为ceph客户端管理元数据
cephfs客户端访问osd的流程
1.cephfs客户端联系MON,验证和检索集群映射 2.cephfs客户端向主MDS查询文件元数据 3.cephfs客户端使用元数据直接与osd通信来访问对象
MDS特性
1.MDS ranks等级 MDS级别定义了元数据负载如何分布在MDS上,rank数量由max_mds配置设置定义,是一次可以激活的MDS守护进程的最大数量
2.Subvolumes Group子卷 cephfs子卷是独立的cephfs文件系统目录树的抽象 客户端可以像挂载普通目录一样,直接挂载子卷,便于管理
3.File System Affinity亲和性 配置cephfs优先使用一个MDS而不是另一个MDS。可以优先配在更快的服务器上 通过mds_Joan_fs选项配置
4.MDS cache size limits 缓存大小设置 mds_cache_memory定义最大使用内存 mds_cache_size定义inode最大数量
5.Quota 资源配额 ceph.quota.max_bytes与ceph.quota.max_files设置配额
6.ceph支持集群中多主MDS,以保证高可用性
部署cephFS 使用volume方式创建cephfs 更简单 ceph fs volume create fs-name –placement=”“
使用手动创建(推荐) 更好地控制部署过程,可以手动创建与cephfs相关的池
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1.创建数据和元数据的pools ceph osd pool create cephfs_data ceph osd pool create cephfs_metadata 2.创建cephfs并部署MDS服务 ceph fs new <fs-name> <mds-pool> <data-pool> ceph fs new ws-cephfs cephfs_metadata cephfs_data Pool 'cephfs_data' (id '11' ) has pg autoscale mode 'on' but is not marked as bulk. Consider setting the flag by running new fs with metadata pool 12 and data pool 11 3.部署MDS服务 ceph orch apply mds <fs-name> --placement="<hosts-name>" ceph orch apply mds ws-cephfs --placement="cephadm-1,cephadm-2,cephadm-3" Scheduled mds.ws-cephfs update... 4.验证 ceph orch ls | grep mds mds.ws-cephfs 3/3 24s ago 61s cephadm-1;cephadm-2;cephadm-3
使用服务规范文件创建 首先也需要手动创建两个所需的池
1 2 3 4 5 6 7 8 9 10 11 12 13 service_type: mds service_id: fs-name placements: hosts: - cephadm-1 - cephadm-2 - cephadm-3 ... ceph orch -i filename.yaml 最后再使用 ceph fs new
挂载CephFS 挂载说明
如果内核版本大于等于4,就可以使用内核客户端 如果内核版本小于4,需要使用FUSE客户端
使用内核客户端进行挂载
需要安装好ceph-common 需要准备好keyring或在命令行中使用明文
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 命令格式 mount -t ceph <monitor_addresses>:<fs_path> <mount_point> -o <options> -t ceph 声明文件系统类型 monitor_addresses mon地址+端口,可写多个 fs_path ceph文件系统路径 mount_point 挂载本地路径 可选options: name=name fs=fs-name secret=secret_value 即密钥 secretfile=secret_key_file 即keyring文件 rsize=bytes 最大可读字节 wsize=bytes 最大可写字节 1.创建cephfs的新用户 格式: ceph fs authorize <fs-name> <keyring-name> <path> <permission> ceph fs authorize ws-cephfs client.cephfs / rwps [client.cephfs] key = AQCoXG5o6SzNARAAY51PjUORXStYTrlFbE7VpA== echo "AQCoXG5o6SzNARAAY51PjUORXStYTrlFbE7VpA==" > /etc/ceph/ceph.client.cephfs.keyringchmod 600 /etc/ceph/ceph.client.cephfs.keyring2.进行挂载 mkdir /mnt/cephfs-datamount -t ceph \ cephadm-1:6789,cephadm-2:6789,cephadm-3:6789:/ \ /mnt/cephfs-data \ -o name=cephfs,secretfile=/etc/ceph/ceph.client.cephfs.keyring,_netdev,fs=ws-cephfs 3.验证 df -Th | grep ceph192.168.10.141:6789,192.168.10.142:6789,192.168.10.143:6789:/ ceph 169G 0 169G 0% /mnt/cephfs-data 4.持久化挂载 vim /etc/fstab cephadm-1,cephadm-2,cephadm-3:/ /mnt/cephfs-data ceph name=cephfs,secretfile=/etc/ceph/ceph.client.cephfs.keyring,_netdev 0 0 systemctl daemon-reload 卸载之前挂载的 umount /mnt/cephfs-data mount -a df -Th192.168.10.141,192.168.10.142,192.168.10.143:/ ceph 169G 0 169G 0% /mnt/cephfs-data
删除cephFS 1 2 3 4 5 6 7 8 如果需要,你可以删除一个cephfs文件系统 首先要备份所有数据,删除cephfs文件系统会破坏所有数据 删除cephfs的步骤是首先将其标记为down ceph fs set fs-name down true 然后,你可以用下面的命令删除它 ceph fs rm fs-name --yes-i-really-mean-it
使用NFS-Ganesha挂载cephFS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 创建身份验证 ceph auth get-or-create client.nfs-ganesha \ mon 'allow r' \ osd 'allow rw' \ mds 'allow rw fsname=ws-cephfs' \ -o /etc/ceph/ceph.client.nfs-ganesha.keyring 创建nfs的配置池 ceph osd pool create nfs-ganesha-config 16 16 开启nfs特性 ceph osd pool application enable nfs-ganesha-config nfs 部署nfs cluster ceph nfs cluster create cephfs-nfs "cephadm-1,cephadm-2,cephadm-3" 验证 ceph orch ls |grep nfs nfs.cephfs-nfs ?:2049 3/3 100s ago 35m cephadm-1;cephadm-2;cephadm-3 ceph nfs cluster info cephfs-nfs { "cephfs-nfs" : { "virtual_ip" : null, "backend" : [ { "hostname" : "cephadm-1" , "ip" : "192.168.10.141" , "port" : 2049 }, { "hostname" : "cephadm-2" , "ip" : "192.168.10.142" , "port" : 2049 }, { "hostname" : "cephadm-3" , "ip" : "192.168.10.143" , "port" : 2049 } ] } } 应用导出配置 nfs export create cephfs <cluster_id> <pseudo_path> <fsname> [<path>] [--readonly ] [--client_addr <value>...] [--squash <value>] [--sectype <value>...] ceph nfs export create cephfs cephfs-nfs /mnt/cephfs-nfs ws-cephfs { "bind" : "/mnt/cephfs-nfs" , "fs" : "ws-cephfs" , "path" : "/" , "cluster" : "cephfs-nfs" , "mode" : "RW" } 验证导出 ceph nfs export ls cephfs-nfs [ "/mnt/cephfs-nfs" ] 测试挂载 mkdir -p /mnt/ceph-nfs使用任一后端挂载,也可以使用VIP挂载 mount -t nfs 192.168.10.141:/mnt/cephfs-nfs /mnt/ceph-nfs df -Th | grep ceph192.168.10.141:/mnt/cephfs-nfs nfs4 168G 0 168G 0% /mnt/ceph-nfs