1、创建MDS:
ceph-deploy mds create [-h] HOST[:NAME] [HOST[:NAME] ...]
2、查看cephfs状态:
1)ceph fs dump
2)ceph fs status
3)ceph fs ls
3、创建存放数据和元数据的池:
1)ceph osd pool create cephfs_data <pg_num>
2)ceph osd pool create cephfs_metadata <pg_num>
4、创建cephfs:
ceph fs new <fs_name> <metadata> <data>
5、客户端通过内核驱动挂载cephfs:
1)mkdir /mnt/mycephfs
2)挂载指定目录,需要ceph认证的用户名和密钥:
mount -t ceph ip:port/ /mnt/mycephfs -o name=admin,secret=***
3)设定开机自动挂载,vi /etc/fstab,添加后重启:
ip:port/usr1 /mnt/mycephfs ceph name=admin,secret=***,noatime,_netdev 0 2
6、客户端通过用户空间挂载cephfs:
1)yum install -y ceph-fuse.x86_64(需要先将ceph加入yum仓库)
2)mkdir /mnt/cephfs
3)ceph-fuse --name client.admin -m ip:port /mnt/cephfs(需要先将密钥拷贝到客户端,如/etc/ceph/ceph.client.admin.keyring)
4)设定开机自动挂载,vi /etc/fstab,添加后重启(需要拷贝ceph.conf):
id=admin,conf=/etc/ceph/ceph.conf /mnt/mycephfs fuse.ceph defaults 0 0
7、权限控制:
1)创建用户并指定权限(/usr1目录下可读写,其他目录下只读):
ceph auth get-or-create client.usr1 mon 'allow r' mds 'allow r, allow rw path=/usr1' osd 'allow rw' -o /etc/ceph/ceph.client.usr1.keyring
2)获取用户的key:
ceph auth get-key client.usr1
3)删除用户:
ceph auth del client.usr1
8、设置quata限额
内核态只有在kernel 4.17 + Ceph mimic以上的版本才支持Quotas,用户态则没有限制,因此使用ceph-fuse挂载。
1)使用admin用户挂载:
ceph-fuse --name client.admin -m ip:port /mnt/cephfs/
或在服务器本地挂载:
ceph-fuse /mnt/cephfs/
2)新建目录并设置限额:
mkdir /mnt/cephfs/usr1
setfattr -n ceph.quota.max_bytes -v 100000000 /mnt/cephfs/usr1
3)umount卸载后再用usr1用户挂载子目录/usr1:(因为usr1权限受限,无法更改属性)
ceph-fuse --name client.usr1 -m ip:port /mnt/cephfs/ -r /usr1
4)df -h可以看到大小仅为92M:
9、停止MDS服务:
systemctl stop ceph-mds@server0
开启MDS服务:
systemctl start ceph-mds@server0
10、设置多活MDS:
ceph fs set cephfs max_mds 2
11、将目录绑定到不同的MDS:
setfattr -n ceph.dir.pin -v <rank> <path>
setfattr -n ceph.dir.pin -v 0 /mnt/mycephfs/test1/
setfattr -n ceph.dir.pin -v 1 /mnt/mycephfs/test2/