Dịch vụ NFS sử dụng RDMA

Bối cảnh

Kết hợp card mạng IB với dịch vụ NFS để cung cấp chia sẻ lưu trữ đơn giản, thay thế tạm thời thiết bị lưu trữ chưa triển khai. Đồng thời giải quyết vấn đề sao chép dữ liệu không hỗ trợ giao thức RDMA bằng SCP/RSYNC trên mạng IB.

Lưu ý

Yêu cầu hệ thống đã cài đặt driver card IB và hoạt động mạng IB bình thường (tham khảo cấu hình chi tiết tại: https://blog.csdn.net/qq_43652666/article/details/141422514).

Quy trình cài đặt cơ bản có sẵn trên nhiều nguồn, tuy nhiên việc cài đặt module RDMA-NFS vào kernel là bước quan trọng mà hầu như tài liệu không đề cập. Bước này quyết định sự thành công của phương án triển khai. Module này không được cài đặt mặc định trong driver Mellanox.

RoCE (RDMA over Converged Ethernet) là công nghệ cho phép RDMA hoạt động trên mạng Ethernet thông thường, mở rộng khả năng kết nối so với công nghệ InfiniBand truyền thống.

Triển khai

Máy chủ

apt install nfs-kernel-server nfs-common -y

# Cấu hình tiến trình dịch vụ nfsv4
root@server:/opt# egrep "^RPCNFSDCOUNT" /etc/default/nfs-kernel-server
RPCNFSDCOUNT=16
systemctl restart nfs-server.service

# Thiết lập đường dẫn chia sẻ
root@server:/data1# grep data /etc/exports
/data1 *(rw,async,crossmnt,insecure,fsid=0,no_auth_nlm,no_subtree_check,no_root_squash,no_all_squash)

# Áp dụng cấu hình
root@server:~# exportfs -arv
exporting *:/data1

# Kiểm tra kết quả
root@server:/data1# showmount -e
Danh sách xuất bản trên bj4090-19:
/data1 *

Module RDMA-NFS

Cả máy chủ và client đều cần cài đặt module này. Trong gói driver Mellanox có chứa file .deb tương ứng, nếu không tồn tại có thể biên dịch từ mã nguồn.

root@server:~# cd /opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS/
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# ls |grep nfs
mlnx-nfsrdma-dkms_24.04.OFED.24.04.0.7.0.1-1_all.deb

root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# dpkg -i mlnx-nfsrdma-dkms_24.04.OFED.24.04.0.7.0.1-1_all.deb
Chuẩn bị cài đặt gói mlnx-nfsrdma-dkms...
Xây dựng module cho kernel 5.15.0-117-generic...
Đang cài đặt module mlnx-nfsrdma...

# Tải module kernel
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# modprobe rpcrdma
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# modprobe xprtrdma
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# modprobe svcrdma
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# lsmod |grep rdma
svcrdma                16384  0
xprtrdma               16384  0
rpcrdma                81920  0
sunrpc                585728  18 nfsd,rpcrdma,auth_rpcgss,lockd,nfs_acl
rdma_ucm               28672  0
rdma_cm               122880  2 rpcrdma,rdma_ucm
iw_cm                  49152  1 rdma_cm
ib_cm                 131072  2 rdma_cm,ib_ipoib
ib_uverbs             135168  26 rdma_ucm,mlx5_ib
ib_core               434176  9 rdma_cm,ib_ipoib,rpcrdma,iw_cm,ib_umad,rdma_ucm,ib_uverbs,mlx5_ib,ib_cm
mlx_compat             69632  14 rdma_cm,ib_ipoib,mlxdevm,rpcrdma,xprtrdma,iw_cm,svcrdma,ib_umad,ib_core,rdma_ucm,ib_uverbs,mlx5_ib,ib_cm,mlx5_core

# Cấu hình cổng dịch vụ
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# echo "rdma 20049" >> /proc/fs/nfsd/portlist
root@server:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# cat /proc/fs/nfsd/portlist
rdma 20049
rdma 20049
tcp 2049
tcp 2049

Tự động hóa quá trình khởi động dịch vụ:

root@server:~# cat /lib/systemd/system/nfs-server.service
[Unit]
Description=NFS server and services
DefaultDependencies=no
Requires=network.target proc-fs-nfsd.mount
Requires=nfs-mountd.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/usr/sbin/exportfs -r
ExecStartPre=/sbin/modprobe xprtrdma
ExecStartPre=/sbin/modprobe svcrdma
ExecStart=/usr/sbin/rpc.nfsd
ExecStartPost=/bin/bash -c "sleep 3 && echo 'rdma 20049' | tee /proc/fs/nfsd/portlist"

# Áp dụng thay đổi
systemctl daemon-reload

Máy khách

apt install nfs-common -y
root@client:/opt/MLNX_OFED_LINUX-24.04-0.7.0.0-ubuntu22.04-x86_64/DEBS# dpkg -i mlnx-nfsrdma-dkms_24.04.OFED.24.04.0.7.0.1-1_all.deb
root@client:~# modprobe xprtrdma

root@client:~# mount -o rdma,port=20049 10.255.252.19:/data1 /data2
root@client:~# mount |grep nfs
10.255.252.19:/data1 on /data2 type nfs (rw,relatime,vers=3,proto=rdma,port=20049)

Tự động tải module khi khởi động:

# Thêm dòng sau vào file dịch vụ
ExecStartPre=/sbin/modprobe xprtrdma

# Cập nhật file rpcbind.service
sed -i '/Environment="OPTIONS=-w"/a ExecStartPre=/sbin/modprobe xprtrdma' /lib/systemd/system/rpcbind.service
systemctl daemon-reload && systemctl restart rpcbind.service

Kiểm tra hiệu năng

apt install fio -y

root@client:~# fio -filename=/data2/fio_test -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=10240k -size=10G -numjobs=60 -runtime=60 -group_reporting -name=mytest --output=./10240k-read-p60-1.json
root@client:~# [R(60)][100.0%][r=17.6GiB/s][r=1806 IOPS]

Tài liệu tham khảo

Giải pháp cài đặt module kernel https://forums.developer.nvidia.com/t/how-to-use-nfs-over-rdma-with-mlnx-ofed-solution/207263

Tham khảo tổng thể triển khai https://vqiu.cn/nfs-rdma/

Thẻ: RDMA NFS Mellanox OFED Kernel Module

Đăng vào ngày 9 tháng 6 lúc 22:05