将 Ceph 文件系统 CephFS 挂载为 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. 通过源码安装:
$ mkdir -p ~/tmp/ && cd ~/tmp
$ git clone https://github.com/nfs-ganesha/nfs-ganesha.git
$ mkdir build && cd build
$ cmake -DUSE_FSAL_CEPH=ON ../nfs-ganesha
$ make && sudo make install

配置 NFS-Ganesha

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

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

NFS 客户端挂载

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

### Usage:
$ sudo mount -t nfs4 -o nfsvers=4.1,protoc=tcp,rw,notime : 
### e.g.:
$ 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 中添加如下内容:
### Usage:
/path/to/mount * (rw,sync,no_root_squash,fsid=ceph-id)
### example:
/cephfs * (rw,sync,no_root_squash,fsid=87761f6e-f839-4597-bfe2-fd850d9a03cf)
  1. 运行 exportfs,并启动 rpcbindnfs-server 服务,将 该节点变成 NFS 服务器。
$ sudo exportfs
$ sudo systemctl enable --now rpcbind
$ 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 服务
  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值