当前位置:   article > 正文

将 Ceph 文件系统 CephFS 挂载为 NFS_ceph nfs

ceph nfs

 

利用 NFS-Ganesha 或 ceph-fuse 与 nfsd, 我们可以将 CephFS 通过 NFS 协议对外发布出去,用户可以通过 NFS 客户端挂载 CephFS 文件系统进行访问。


目录

  1. Ceph 与 NFS
  2. NFS-Ganesha 挂载 CephFS
    1. 准备条件
    2. 安装 NFS-Ganesha
    3. 配置 NFS-Ganesha
    4. NFS 客户端挂载
  3. ceph-fuse 和 nfsd 挂载 CephFS
    1. NFS 服务端设置
    2. NFS 客户端挂载
  4. 两种方案对比
  5. 参考文献

Ceph 与 NFS

Ceph 是一种开源的分布式存储系统,具有优异的性能、可靠性和可扩展性。 Ceph 底层使用 RADOS,提供 RBD、RGW 和 CephFS 三种标准的访问接口。从 Luminous 版本开始, CephFS 已经具有相当好的稳定性,可用在生产环境。

 Ceph 架构

NFS (Network File System) 是常用的网络文件系统,用户通过 NFS 可以像访问本地文件一样访问远程的文件,NFS 服务端和客户端之间通过 NFS 协议进行通信。

用户可以用 Ceph 提供的 ceph-fuse 挂载 CephFS 进行访问,也可以通过 ceph 的内核模块进行挂载访问,具体可参考 Ceph 文件系统 CephFS 的介绍与配置 。 但有时候,由于各种原因,一些系统无法通过这两种方法访问 CephFS,我们可以将 CephFS 通过 NFS 协议发布出去,用户可以通过 NFS 客户端挂载发布出去的 CephFS。

NFS-Ganesha 挂载 CephFS

CephFS 可以通过 NFS-Ganesha 使用 NFS 协议发布出去。

准备条件

  • 一个设置好的 CephFS 文件系统
  • 在 NFS 服务器上,安装 libcephfs2nfs-ganeshanfs-ganesha-ceph (ganesha >= 2.5) 包。
  • NFS-Ganesha 服务器与 CephFS 网路相连。

安装 NFS-Ganesha

  1. 通过包管理器安装:
$ sudo yum install nfs-ganesha-fsal-ceph
  1. 通过源码安装:
  1. $ mkdir -p ~/tmp/ && cd ~/tmp
  2. $ git clone https://github.com/nfs-ganesha/nfs-ganesha.git
  3. $ mkdir build && cd build
  4. $ cmake -DUSE_FSAL_CEPH=ON ../nfs-ganesha
  5. $ make && sudo make install

配置 NFS-Ganesha

  1. 关闭防火墙或打开 2049 端口:
  1. ### turn off firewall
  2. $ sudo systemctl disable --now firewalld
  3. $ sudo systemctl disable --now iptables
  4. ### or open port 2049
  5. $ sudo firewall-cmd --permanent --add-port=2049/tcp
  6. $ sudo firewall-cmd --reload
  1. 启动 rpcbindrpcstatd 服务:
  1. $ sudo systemctl enable --now rpcbind
  2. $ sudo systemctl enable --now rpcstatd
  1. 复制 Ceph 配置文件到 /etc/ceph/ceph.conf
  2. 根据 NFS-Ganesha 的 Ceph 配置例子 , 创建 /etc/ganashe/ceph.conf,类似如下:
  1. NFS_CORE_PARAM
  2. {
  3. Enable_NLM = false;
  4. Enable_RQUOTA = false;
  5. Protocols = 4;
  6. }
  7. NFSv4
  8. {
  9. Allow_Numeric_Owners = true;
  10. Only_Numeric_Owners = true;
  11. Delegations = active;
  12. }
  13. CACHEINODE
  14. {
  15. Dir_Chunk = 0;
  16. NParts = 1;
  17. Cache_Size = 1;
  18. }
  19. EXPORT
  20. {
  21. Export_ID = 1;
  22. Protocols = 4;
  23. Transports = TCP;
  24. Path = /;
  25. Pseudo = /cephfs/;
  26. Access_type = RW;
  27. Delegations = RW;
  28. # Squash = root;
  29. FSAL{NAME = CEPH;}
  30. }
  1. 启动 NFS-Ganesha 服务:
  1. $ sudo ganesha.nfsd -f /etc/ganesha/ceph.conf -L /var/log/ganesha.log -N NIV_CRIT
  2. $ sudo showmount -e

这样就把 CephFS 通过 NFS 协议导出了。值得注意的是, 目前一个运行的 Ganesha 进程只能导出一个 CephFS 中的一个目录 ;如果多个 CephFS 或 一个 CephFS 中的多个目录需要导出,需要有相应多个 Ganesha 进程。

NFS 客户端挂载

在 NFS 客户端服务器上挂载 CephFS 到 /cephfs

  1. ### Usage:
  2. $ sudo mount -t nfs4 -o nfsvers=4.1,protoc=tcp,rw,notime :
  3. ### e.g.:
  4. $ sudo mount -t nfs4 -o nfsvers=4.1,proto=tcp,rw,notime :/ /cephfs

这样用户就可以通过 NFS 协议访问 CephFS 了。

ceph-fuse 和 nfsd 挂载 CephFS

Ceph 提供了 ceph-fuse 来挂载和访问 CephFS。在 NFS 服务器上通过 ceph-fuse 挂载 CephFS 后,我们可以通过 nfsd 将其发布出去。

NFS 服务端设置

  1. 在 NFS 服务器上挂载 CephFS。
  2. /etc/exports 中添加如下内容:
  1. ### Usage:
  2. /path/to/mount * (rw,sync,no_root_squash,fsid=ceph-id)
  3. ### example:
  4. /cephfs * (rw,sync,no_root_squash,fsid=87761f6e-f839-4597-bfe2-fd850d9a03cf)
  1. 运行 exportfs,并启动 rpcbindnfs-server 服务,将 该节点变成 NFS 服务器。
  1. $ sudo exportfs
  2. $ sudo systemctl enable --now rpcbind
  3. $ sudo systemctl enable --now nfs-server

NFS 客户端挂载

跟前面一样,在 NFS 客户端上通过 NFS 协议挂载 CephFS:

$ sudo mount -t nfs4 -o nfsvers=4.1,proto=tcp,rw,notime :/cephfs /cephfs

这样用户就可以通过 NFS 协议访问 CephFS 了。

两种方案对比

参考文献

  1. NFS+CephFS 构建基于 Ceph 的 NAS 服务
  2. Ceph 提供 NFS 服务 —— RGW+nfs-ganesha
  3. MPI-IO with CephFS?
  4. Exporting Ceph FS Over NFS
  5. NFS CephFS Using Ganesha
  6. NFS RadosGW Using Ganesha
  7. 以 CephFS 为例解析如何在云中提供 NAS 服务
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/832141
推荐阅读
相关标签
  

闽ICP备14008679号