NFS Ganesha 是一台 NFS 服务器(请参见与 NFS 共享文件系统),它在用户地址空间中运行,而不是作为操作系统内核的一部分运行。借助 NFS Ganesha,您可以插入自己的存储机制(例如 Ceph),并从任何 NFS 客户端访问它。
系统按用户将 S3 桶导出到 NFS,例如,通过路径 GANESHA_NODE:/用户名/桶名
导出。
默认通过路径 GANESHA_NODE:/cephfs
导出 CephFS。
有关安装说明,请参阅第 12 章 “安装 NFS Ganesha”。
有关可在配置文件中使用的所有参数的列表,请参见:
man ganesha-config
man ganesha-ceph-config
,用于 CephFS 文件系统抽象层 (FSAL) 选项。
man ganesha-rgw-config
,用于对象网关 FSAL 选项。
本节包含的信息可帮助您配置 NFS Ganesha 服务器,以导出可通过对象网关和 CephFS 访问的集群数据。
NFS Ganesha 配置通过 /etc/ganesha/ganesha.conf
控制。注意,对此文件所做的更改在执行 DeepSea 阶段 4 时会被覆盖。要永久更改这些设置,请编辑位于 Salt Master 上的文件 /srv/salt/ceph/ganesha/files/ganesha.conf.j2
。
本节介绍如何配置 ganesha.conf
中的 EXPORT
段落。
EXPORT { Export_Id = 1; Path = "/"; Pseudo = "/"; Access_Type = RW; Squash = No_Root_Squash; [...] FSAL { Name = CEPH; } }
每个导出项都需要有唯一的“Export_Id”(强制)。
相关 CephFS 存储池中的导出项路径(强制)。允许从 CephFS 中导出子目录。
目标 NFS 导出项路径(对于 NFSv4 为强制)。它定义在哪个 NFS 导出项路径下可获得导出的数据。
示例:使用值 /cephfs/
并执行
root #
mount GANESHA_IP:/cephfs/ /mnt/
之后,CephFS 数据可在客户端上的目录 /mnt/cephfs/
中获得。
“RO”表示只读访问权限,默认值是“None”。
NFS 匿名访问选项。
导出“文件系统抽象层”。请参见第 14.2.1.2 节 “FSAL 子段落”。
EXPORT { [...] FSAL { Name = CEPH; } }
定义 NFS Ganesha 使用的后端。允许的值为 CEPH
(表示 CephFS)或 RGW
(表示对象网关)。根据您的选择,必须在 policy.cfg
中定义 role-mds
或 role-rgw
。
RGW { ceph_conf = "/etc/ceph/ceph.conf"; name = "name"; cluster = "ceph"; }
指向 ceph.conf
文件。与 DeepSea 一起部署时,不需要更改此值。
NFS Ganesha 使用的 Ceph 客户端用户名。
Ceph 集群的名称。SUSE Enterprise Storage 5 目前只支持一个集群名称,默认为 ceph
。
NFS Ganesha 默认使用端口 2049 提供 NFS 支持,使用 875 提供 rquota 支持。要更改默认端口号,请在 NFS_CORE_PARAM
段落中使用 NFS_Port
和 RQUOTA_Port
选项,例如:
NFS_CORE_PARAM { NFS_Port = 2060; RQUOTA_Port = 876; }
可为集群节点定义自定义 NFS Ganesha 角色。然后可在 policy.cfg
中将这些角色指定给节点。角色允许:
分别使用不同的 NFS Ganesha 节点来访问对象网关和 CephFS。
将不同的对象网关用户指定给 NFS Ganesha 节点。
拥有不同的对象网关用户可让 NFS Ganesha 节点访问不同的 S3 桶。S3 桶可用于进行访问控制。注意:不要将 S3 桶与 CRUSH 地图中使用的 Ceph 桶混淆。
下面针对 Salt Master 的示例过程展示如何创建两个具有不同对象网关用户的 NFS Ganesha 角色。在此示例中,使用了角色 gold
和 silver
,DeepSea 已经提供了它们的示例配置文件。
使用您选择的编辑器打开 /srv/pillar/ceph/stack/global.yml
文件。如果该文件不存在,请予以创建。
该文件需要包含以下几行:
rgw_configurations: - rgw - silver - gold ganesha_configurations: - silver - gold
稍后可以在 policy.cfg
中指定这些角色。
创建 /srv/salt/ceph/rgw/users/users.d/gold.yml
文件并添加以下内容:
- { uid: "gold1", name: "gold1", email: "gold1@demo.nil" }
创建 /srv/salt/ceph/rgw/users/users.d/silver.yml
文件并添加以下内容:
- { uid: "silver1", name: "silver1", email: "silver1@demo.nil" }
现在,需要为每个角色创建 ganesha.conf
的模板。使用 DeepSea 的原始模板是较佳的做法。创建两个副本:
root #
cd
/srv/salt/ceph/ganesha/files/root #
cp
ganesha.conf.j2 silver.conf.j2root #
cp
ganesha.conf.j2 gold.conf.j2
新的角色需要密钥环来访问集群。要提供访问权限,请复制 ganesha.j2
:
root #
cp
ganesha.j2 silver.j2root #
cp
ganesha.j2 gold.j2
复制对象网关的密钥环:
root #
cd
/srv/salt/ceph/rgw/files/root #
cp
rgw.j2 silver.j2root #
cp
rgw.j2 gold.j2
对象网关还需要不同角色的配置:
root #
cd
/srv/salt/ceph/configuration/files/root #
cp
ceph.conf.rgw silver.confroot #
cp
ceph.conf.rgw gold.conf
在 /srv/pillar/ceph/proposals/policy.cfg
中将新建的角色指定给集群节点:
role-silver/cluster/NODE1.sls role-gold/cluster/NODE2.sls
将 NODE1 和 NODE2 分别替换为要将角色指定给的节点的名称。
执行 DeepSea 阶段 0 到 4。
下面针对 Salt Master 的示例过程展示如何创建使用 CephFS 和对象网关的 2 个不同的新角色:
使用您选择的编辑器打开文件 /srv/pillar/ceph/rgw.sls
。如果该文件不存在,请予以创建。
该文件需要包含以下几行:
rgw_configurations: ganesha_cfs: users: - { uid: "demo", name: "Demo", email: "demo@demo.nil" } ganesha_rgw: users: - { uid: "demo", name: "Demo", email: "demo@demo.nil" } ganesha_configurations: - ganesha_cfs - ganesha_rgw
稍后可以在 policy.cfg
中指定这些角色。
现在,需要为每个角色创建 ganesha.conf
的模板。使用 DeepSea 的原始模板是较佳的做法。创建两个副本:
root #
cd
/srv/salt/ceph/ganesha/files/root #
cp
ganesha.conf.j2 ganesha_rgw.conf.j2root #
cp
ganesha.conf.j2 ganesha_cfs.conf.j2
编辑 ganesha_rgw.conf.j2
,删除以下段落:
{% if salt.saltutil.runner('select.minions', cluster='ceph', roles='mds') != [] %} [...] {% endif %}
编辑 ganesha_cfs.conf.j2
,删除以下段落:
{% if salt.saltutil.runner('select.minions', cluster='ceph', roles=role) != [] %} [...] {% endif %}
新的角色需要密钥环来访问集群。要提供访问权限,请复制 ganesha.j2
:
root #
cp
ganesha.j2 ganesha_rgw.j2root #
cp
ganesha.j2 ganesha_cfs.j2
可从 ganesha_rgw.j2
中删除 caps mds = "allow *"
这一行。
复制对象网关的密钥环:
root #
cp
/srv/salt/ceph/rgw/files/rgw.j2 \ /srv/salt/ceph/rgw/files/ganesha_rgw.j2
对象网关需要您对新角色进行配置:
root #
cp
/srv/salt/ceph/configuration/files/ceph.conf.rgw \ /srv/salt/ceph/configuration/files/ceph.conf.ganesha_rgw
在 /srv/pillar/ceph/proposals/policy.cfg
中将新建的角色指定给集群节点:
role-ganesha_rgw/cluster/NODE1.sls role-ganesha_cfs/cluster/NODE1.sls
将 NODE1 和 NODE2 分别替换为要将角色指定给的节点的名称。
执行 DeepSea 阶段 0 到 4。
要启用并启动 NFS Ganesha 服务,请运行以下命令:
root #
systemctl
enable nfs-ganesharoot #
systemctl
start nfs-ganesha
要重启动 NFS Ganesha,请运行以下命令:
root #
systemctl
restart nfs-ganesha
启动或重启动 NFS Ganesha 时,NFS v4 会有 90 秒的超时宽限期。在宽限期内,会主动拒绝来自客户端的新请求。因此,当 NFS 处于宽限状态时,客户端可能会发生请求处理速度变慢的情况。
通过编辑文件 /etc/sysconfig/nfs-ganesha
,可更改默认调试级别 NIV_EVENT
。将 NIV_EVENT
替换为 NIV_DEBUG
或 NIV_FULL_DEBUG
。提高日志详细程度可能会在日志文件中产生大量数据。
OPTIONS="-L /var/log/ganesha/ganesha.log -f /etc/ganesha/ganesha.conf -N NIV_EVENT"
更改日志级别时,需要重启动服务。
使用 NFS v3 时,可以在 NFS Ganesha 服务器节点上校验是否导出了 NFS 共享:
root #
showmount
-e / (everything)
要在客户端主机上挂载导出的 NFS 共享(根据第 14.2 节 “配置”中的配置),请运行以下命令:
root #
mount
-t nfs -o rw,noatime,sync \ nfs_ganesha_server_hostname:/ /path/to/local/mountpoint
https://github.com/nfs-ganesha/nfs-ganesha/wiki/Docs 中提供了原始 NFS Ganesha 文档。