[root@k8s-node1 mnt]# showmount -e 172.31.0.12
Export list for 172.31.0.12:
/mnt/nfs 172.0.0.0/8
在客户端创建并挂载对应目录:
> mkdir -p /mnt/nfs
> mount -t nfs 172.31.0.12:/mnt/nfs /mnt/nfs
最后检查一下是否挂载成功:
[root@k8s-node1 mnt]# df -hT /mnt/nfs
Filesystem Type Size Used Avail Use% Mounted on
172.31.0.12:/mnt/nfs nfs4 493G 72M 467G 1% /mnt/nfs
[root@k8s-node1 mnt]# mount | grep /mnt/nfs
172.31.0.12:/mnt/nfs on /mnt/nfs type nfs4 (rw,relatime,vers=4.1,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.18.0.7,local_lock=none,addr=172.31.0.12)
3.4 配置自动挂载
在客户端编辑/etc/fstab,加入如下配置:
172.31.0.12:/mnt/nfs /mnt/nfs nfs defaults 0 0
最后重新加载systemctl,即可实现重启后自动挂载
> systemctl daemon-reload
4. NFS 读写速度测试
写速度:
[root@k8s-node1 mnt]# time dd if=/dev/zero of=/mnt/nfs/jenkins.war bs=8k count=1024
1024+0 records in
1024+0 records out
8388608 bytes (8.4 MB) copied, 0.122319 s, 68.6 MB/s
real 0m0.138s
user 0m0.000s
sys 0m0.008s
读速度:
[root@k8s-node1 mnt]# time dd if=/mnt/nfs/jenkins.war of=/dev/null bs=8k count=1024
1024+0 records in
1024+0 records out
8388608 bytes (8.4 MB) copied, 0.0020144 s, 4.2 GB/s
real 0m0.004s
user 0m0.000s
sys 0m0.002s