适用于 SUSE Enterprise Storage 5

12 安装 NFS Ganesha

使用 NFS Ganesha 可通过 NFS 访问对象网关或 CephFS。SUSE Enterprise Storage 5 支持 NFS 版本 3 和 4。NFS Ganesha 在用户空间而不是内核空间中运行,直接与对象网关或 CephFS 交互。

12.1 准备

12.1.1 一般信息

要成功部署 NFS Ganesha,需要将 role-ganesha 添加到 /srv/pillar/ceph/proposals/policy.cfg。有关详细信息,请参见第 4.5.1 节 “policy.cfg 文件”。要使用 NFS Ganesha,还需要在 policy.cfg 中指定 role-rgwrole-mds

尽管可以在现有的 Ceph 节点上安装并运行 NFS Ganesha 服务器,但建议在能够访问 Ceph 集群的专用主机上运行该服务器。客户端主机通常不是集群的一部分,但需要能够通过网络访问 NFS Ganesha 服务器。

要在完成初始安装后随时启用 NFS Ganesha 服务器,请将 role-ganesha 添加到 policy.cfg,并至少重新运行 DeepSea 阶段 2 和 4。有关详细信息,请参见第 4.3 节 “集群部署”

NFS Ganesha 是通过 NFS Ganesha 节点上的 /etc/ganesha/ganesha.conf 文件配置的。但是,每次执行 DeepSea 阶段 4,都会重写此文件。因此,建议编辑 Salt 使用的模板,即 Salt Master 上的 /srv/salt/ceph/ganesha/files/ganesha.conf.j2 文件。有关配置文件的详细信息,请参见第 14.2 节 “配置”

12.1.2 要求摘要

在执行 DeepSea 阶段 2 和 4 来安装 NFS Ganesha 之前,必须满足以下要求:

  • 至少为一个节点指定 role-ganesha

  • 对于每个 Minion,只能定义一个 role-ganesha

  • NFS Ganesha 需要对象网关或 CephFS 才能正常工作。

  • 如果 NFS Ganesha 预期要使用对象网关来连接集群,则需要填充 Salt Master 上的 /srv/pillar/ceph/rgw.sls

12.2 示例安装

此过程提供了一个安装示例,该示例使用 NFS Ganesha 的对象网关和 CephFS 文件系统抽象层 (FSAL)。

  1. 先执行 DeepSea 阶段 0 和 1(如果尚未这样做),然后继续执行此过程。

    root # salt-run state.orch ceph.stage.0
    root # salt-run state.orch ceph.stage.1
  2. 执行 DeepSea 的阶段 1 之后,编辑 /srv/pillar/ceph/proposals/policy.cfg 并添加下行

    role-ganesha/cluster/NODENAME

    NODENAME 替换为集群中某个节点的名称。

    另外,请确保已指定 role-mdsrole-rgw

  3. 创建文件 /srv/pillar/ceph/rgw.sls 并插入以下内容:

    rgw_configurations:
      rgw:
        users:
          - { uid: "demo", name: "Demo", email: "demo@demo.nil" }
          - { uid: "demo1", name: "Demo1", email: "demo1@demo.nil" }

    系统稍后会将这些用户创建为对象网关用户,并生成 API 密钥。稍后,您可在对象网关节点上运行 radosgw-admin user list 列出所有已创建的用户,并运行 radosgw-admin user info --uid=demo 获取有关单个用户的详细信息。

    DeepSea 确保对象网关和 NFS Ganesha 都能接收 rgw.slsrgw 段落中所列全部用户的身份凭证。

    导出的 NFS 将在文件系统的第一级别上使用这些用户名;在本示例中,将导出路径 /demo/demo1

  4. 至少执行 DeepSea 的阶段 2 和 4。建议运行中间的阶段 3。

    root # salt-run state.orch ceph.stage.2
    root # salt-run state.orch ceph.stage.3 # optional but recommended
    root # salt-run state.orch ceph.stage.4
  5. 通过从客户端节点装入 NFS 共享来校验 NFS Ganesha 是否正常工作:

    root # mount -o sync -t nfs GANESHA_NODE:/ /mnt
    root # ls /mnt
    cephfs  demo  demo1

    /mnt 应包含所有已导出的路径。CephFS 和两个对象网关用户的目录应该存在。对于用户拥有的每个桶,将导出路径 /mnt/USERNAME/BUCKETNAME

12.3 高可用性主动-被动配置

本节提供一个示例来说明如何设置 NFS Ganesha 服务器的双节点主动-被动配置。该设置需要 SUSE Linux Enterprise High Availability Extension。两个节点分别名为 earthmars

有关 SUSE Linux Enterprise High Availability Extension 的详细信息,请参见 https://www.suse.com/documentation/sle-ha-12/

12.3.1 基本安装

在此设置中,earth 的 IP 地址为 192.168.1.1mars 的地址为 192.168.1.2

此外,使用了两个浮动虚拟 IP 地址,这样无论服务在哪个物理节点上运行,客户端都可连接到服务。192.168.1.10 用于通过 Hawk2 进行集群管理,192.168.2.1 专门用于 NFS 导出项。这样,以后便可更轻松地应用安全限制。

以下过程介绍示例安装。https://www.suse.com/documentation/sle-ha-12/install-quick/data/install-quick.html 上提供了更多详细信息。

  1. 在 Salt Master 上准备 NFS Ganesha 节点:

    1. 在 Salt Master 上运行 DeepSea 阶段 0 和 1。

      root@master # salt-run state.orch ceph.stage.0
      root@master # salt-run state.orch ceph.stage.1
    2. /srv/pillar/ceph/proposals/policy.cfg 中为节点 earthmars 指定 role-ganesha

      role-ganesha/cluster/earth*.sls
      role-ganesha/cluster/mars*.sls
    3. 在 Salt Master 上运行 DeepSea 阶段 3 和 4。

      root@master # salt-run state.orch ceph.stage.3
      root@master # salt-run state.orch ceph.stage.4
  2. earthmars 上注册 SUSE Linux Enterprise High Availability Extension。

    root # SUSEConnect -r ACTIVATION_CODE -e E_MAIL
  3. 在两个节点上安装 ha-cluster-bootstrap

    root # zypper in ha-cluster-bootstrap
    1. earth 上初始化集群:

      root@earth # ha-cluster-init
    2. mars 加入该集群:

      root@mars # ha-cluster-join -c earth
  4. 检查集群的状态。您应该会看到两个节点都已添加到集群中:

    root@earth # crm status
  5. 在这两个节点上,禁用引导时自动启动 NFS Ganesha 服务的功能:

    root # systemctl disable nfs-ganesha
  6. earth 上启动 crm 外壳:

    root@earth # crm configure

    后续命令在 crm 外壳中执行。

  7. earth 上,运行 crm 外壳来执行以下命令,以便将 NFS Ganesha 守护进程的资源配置为 systemd 资源类型的克隆:

    crm(live)configure# primitive nfs-ganesha-server systemd:nfs-ganesha \
    op monitor interval=30s
    crm(live)configure# clone nfs-ganesha-clone nfs-ganesha-server meta interleave=true
    crm(live)configure# commit
    crm(live)configure# status
        2 nodes configured
        2 resources configured
    
        Online: [ earth mars ]
    
        Full list of resources:
             Clone Set: nfs-ganesha-clone [nfs-ganesha-server]
             Started:  [ earth mars ]
  8. 使用 crm 外壳创建一个原始 IPAddr2:

    crm(live)configure# primitive ganesha-ip IPaddr2 \
    params ip=192.168.2.1 cidr_netmask=24 nic=eth0 \
    op monitor interval=10 timeout=20
    
    crm(live)# status
    Online: [ earth mars  ]
    Full list of resources:
     Clone Set: nfs-ganesha-clone [nfs-ganesha-server]
         Started: [ earth mars ]
     ganesha-ip    (ocf::heartbeat:IPaddr2):    Started earth
  9. 为了在 NFS Ganesha 服务器与浮动虚拟 IP 之间建立关系,我们使用了共置和顺序约束。

    crm(live)configure# colocation ganesha-ip-with-nfs-ganesha-server inf: ganesha-ip nfs-ganesha-clone
    crm(live)configure# order ganesha-ip-after-nfs-ganesha-server Mandatory: nfs-ganesha-clone ganesha-ip
  10. 从客户端使用 mount 命令,以确保完成集群设置:

    root # mount -t nfs -v -o sync,nfsvers=4 192.168.2.1:/ /mnt

12.3.2 清理资源

如果其中一个节点(例如 earth)上发生 NFS Ganesha 故障,请解决问题并清理资源。如果 NFS Ganesha 在 mars 上发生故障,则只有在清理资源之后,该资源才能故障回复到 earth

要清理资源,请执行以下命令:

root@earth # crm resource cleanup nfs-ganesha-clone earth
root@earth # crm resource cleanup ganesha-ip earth

12.3.3 设置 Ping 资源

有时,服务器可能由于网络问题而无法访问客户端。Ping 资源可以检测并缓解此问题。配置此资源的操作是可选的。

  1. 定义 ping 资源:

    crm(live)configure# primitive ganesha-ping ocf:pacemaker:ping \
            params name=ping dampen=3s multiplier=100 host_list="CLIENT1 CLIENT2" \
            op monitor interval=60 timeout=60 \
            op start interval=0 timeout=60 \
            op stop interval=0 timeout=60

    host_list 是以空格分隔的 IP 地址列表。系统将会定期 ping 这些 IP 地址,以检查网络中断问题。如果某个客户端必须始终能够访问 NFS 服务器,请将该客户端添加到 host_list

  2. 创建克隆资源:

    crm(live)configure# clone ganesha-ping-clone ganesha-ping \
            meta interleave=true
  3. 以下命令会创建 NFS Ganesha 服务的约束。当 host_list 不可访问时,此约束会强制服务转移到另一节点。

    crm(live)configure# location nfs-ganesha-server-with-ganesha-ping
            nfs-ganesha-clone \
            rule -inf: not_defined ping or ping lte 0

12.3.4 NFS Ganesha HA 和 DeepSea

DeepSea 不支持配置 NFS Ganesha HA。为了防止在配置 NFS Ganesha HA 之后 DeepSea 发生故障,请从 DeepSea 阶段 4 中排除 NFS Ganesha 服务的启动和停止操作:

  1. /srv/salt/ceph/ganesha/default.sls 复制到 /srv/salt/ceph/ganesha/ha.sls

  2. /srv/salt/ceph/ganesha/ha.sls 中删除 .service 项,使文件内容如下所示:

    include:
    - .keyring
    - .install
    - .configure
  3. 将下行添加到 /srv/pillar/ceph/stack/global.yml

    ganesha_init: ha

12.4 更多信息

更多信息可以在第 14 章 “NFS Ganesha:通过 NFS 导出 Ceph 数据中找到。

打印此页