cephfs export

export cephfs

创建用户目录

使用admin用户将根目录挂载,并创建用户使用需要的目录

1
mount -t ceph <monitor ip>:6789:/ /mnt/ -o name=admin,secret=xxxxxxxxxxxxxxxxxxxxxxxx==

/mnt目录下创建kubefs目录

给目录设置配额(Quota)

设置目录配额是linux内核本身提供的功能,cephfs只是支持了该功能。设置前需要先安装attr的rpm包yum install -y attr

设置目录配额

1
setfattr -n ceph.quota.size_bytes -v <size byte> /mnt/kubefs

通过getfattr可以获取该quota值。

cephfs quota 不能精确的限制配额,容量统计有延时,大概10s左右。

创建用户

创建一个名称为client.kubefs的用户,使其在/目录下有只读的权限,在/kubefs目录下有读写权限

1
ceph fs authorize cephfs client.kubefs / r /kubefs rw

cephfsfilesystem name,可以通过ceph fs ls查询。用户创建成功后,可以通过ceph auth list查询用户权限。需要删除用户也可以通过ceph auth rm仅限删除操作。

挂载

1
mount -t ceph <monitor ip>:6789:/kubefs /mnt/ -o name=kubefs,secret=xxxxxxxxxxxxxxxxxxxxxx==

export nfs

cephfs本身不支持nfs协议,可以通过nfs-ganesha将cephfs转成nfs提供出去。

镜像

ananace/nfs-ganesha-ceph

ganesha配置

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
# NFS protocol options
EXPORT
{
# Export Id (mandatory, each EXPORT must have a unique Export_Id)
Export_Id = 77;

# Exported path (mandatory)
Path = /;

# Pseudo Path (for NFS v4)
Pseudo = /;

# Access control options
Access_Type = RW;
Squash = No_Root_Squash;

# NFS protocol options
SecType = "sys";
Transports = TCP;
Protocols = 4;

# Exporting FSAL
FSAL {
Name = CEPH;
}
}

运行ganesha容器

1
docker run -d --net=host  -v /home/xxx/ceph/etc_ceph/:/etc/ceph -v /home/xxx/ceph/ganesha/:/etc/ganesha --name nfs -e GANESHA_BOOTSTRAP_CONFIG=no ananace/nfs-ganesha-ceph