Akemi

使用NFS-Ganesha挂载cephFS

2025/08/06
  • NFS-Ganesha 本质是协议转换层,牺牲少量性能换取最大兼容性;
  • 普通挂载是性能最优路径,但受限于 Linux 生态;
维度 NFS-Ganesha 挂载 CephFS 普通挂载(内核/FUSE)
协议兼容性 ✅ 提供 标准 NFSv3/v4 协议,兼容所有支持 NFS 的系统(Windows、旧版Linux、IoT设备等) ❌ 仅支持原生 CephFS 客户端(Linux 内核 ≥4.0 或 FUSE)
客户端要求 客户端无需安装 Ceph 组件 客户端需部署 ceph-common 和密钥
跨平台能力 ⭐ 支持非 Linux 系统(如 Windows、macOS) ❌ 仅限 Linux 系统
权限管理 继承 NFS 权限模型(如 root_squash 依赖 Ceph 自身的 POSIX 权限
防火墙友好 仅需开放 NFS 端口(2049) 需开放 Ceph 集群多个端口(6789, 6800+)
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
72
73
74
75
76
fs: ws-cephfs
nfs配置池: nfs-ganesha-config
nfs集群: cephfs-nfs
目标挂载点: /mnt/cephfs-nfs

创建身份验证
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的配置池nfs-ganesha-config
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
}
]
}
}

应用导出配置
ceph 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 ceph
192.168.10.141:/mnt/cephfs-nfs nfs4 168G 0 168G 0% /mnt/ceph-nfs

CATALOG