NFS启用UDP
NFS启用UDP
目标我们使用的NFS通常是NFSv3和v4
NFSv2支持UDP传输,所以,我们想先配置NFSv2,然后再指定用UDP;
视频演示
https://www.bilibili.com/video/BV1aA411Z7U9?p=32&vd_source=4134b92c3a7468ae0a22c27b16a3440f
服务端的配置
zhaghe@u22:~/桌面$ cat /proc/version
Linux version 5.15.0-43-generic (buildd@lcy02-amd64-076) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022
root@u22:~# sudo apt update ; apt -y install nfs-kernel-server ; systemctl enable --now nfs-server
zhaghe@u22:~/桌面$ cat /etc/exports
/code *(rw)
zhaghe@u22:~/桌面$ sudo mkdir /code ; chmod o+w /code
zhaghe@u22:~/桌面$ sudo systemctl restart nfs-server
root@u22:~# cat /proc/fs/nfsd/versions
-2 +3 +4 +4.1 +4.2
root@u22:~# echo 'RPCNFSDCOUNT="--nfs-version 2 8"' >> /etc/default/nfs-kernel-server
root@u22:~# tail -1 /etc/default/nfs-kernel-server
RPCNFSDCOUNT="--nfs-version 2 8"
root@u22:~# cat /etc/nfs.conf | egrep '(udp|vers2)' | grep -v "^#"
udp=y
vers2=y
root@u22:~# systemctl restart nfs-server
root@u22:~# cat /proc/fs/nfsd/versions
+2 +3 +4 +4.1 +4.2
客户端的配置
[root@C6 ~]# hostname -I
192.168.80.132
[root@C6 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
# 使用centos6,因为centos7以上的版本,mount不再支持nfsv2的版本
[root@C6 ~]# mkdir /nfs
[root@C6 ~]# mount -t nfs -o vers=2,udp 192.168.80.130:/code /nfs
验证
# 服务端开启抓包
root@u22:~# tcpdump -i ens33 -w /tmp/nfs_udp.cap
# 客户端传输文件
[root@C6 ~]# dd if=/dev/zero of=./4M.txt bs=4M count=1
记录了1+0 的读入
记录了1+0 的写出
4194304字节(4.2 MB)已复制,0.00289856 秒,1.4 GB/秒
[root@C6 ~]# cp ./4M.txt /nfs