关键
- rpcrdma模块加载
- /proc/fs/nfsd/portlist写入rdma端口
你可以直接输入下面命令下载脚本并执行。
curl -o ./load-nfs-rdma.sh https://file.homelabproject.cc/d/local/Server/Src/rdma-tools/load-nfs-rdma.sh
或者自行粘贴
#!/bin/bash LOGFILE="/var/log/rdma_setup.log" RDMA_PORT=${RDMA_PORT:-20049} # Redirect output to log file exec > >(tee -a "$LOGFILE") 2>&1 echo "Starting RDMA setup script at $(date)" # Ensure script is run as root if [ "$(id -u)" -ne 0 ]; then echo "This script must be run as root. Please re-run with sudo or as root user." >&2 exit 1 fi # Check if the rpcrdma module is available if ! modinfo rpcrdma &>/dev/null; then echo "The rpcrdma module is not available on this system. Please ensure it is installed." >&2 exit 1 fi # Check if the rpcrdma module is loaded if ! lsmod | grep -q "^rpcrdma"; then echo "The rpcrdma module is not loaded, loading it now..." modprobe rpcrdma if [ $? -eq 0 ]; then echo "The rpcrdma module was successfully loaded." else echo "Failed to load the rpcrdma module. Please check permissions or module availability." >&2 exit 1 fi else echo "The rpcrdma module is already loaded." fi # Check if /proc/fs/nfsd/portlist contains the RDMA port if ! grep -q "rdma $RDMA_PORT" /proc/fs/nfsd/portlist; then echo "'rdma $RDMA_PORT' is not present in /proc/fs/nfsd/portlist, adding it now..." echo "rdma $RDMA_PORT" > /proc/fs/nfsd/portlist if [ $? -eq 0 ]; then echo "'rdma $RDMA_PORT' was successfully added to /proc/fs/nfsd/portlist." else echo "Failed to write to /proc/fs/nfsd/portlist. Please check permissions." >&2 exit 1 fi else echo "'rdma $RDMA_PORT' is already present in /proc/fs/nfsd/portlist." fi #echo "RDMA setup script completed successfully at $(date)"
另外可以放入定时任务,自动检测模块加载和端口,确保服务正常