搭建nfs服务器
centOS7、centOS8搭建nfs服务器
http://blog.huatai.me/2014/10/14/CentOS-7-NFS-Server-and-Client-Setup/https://www.howtoforge.com/tutorial/setting-up-an-nfs-server-and-client-on-centos-7/
关闭
selinux、firewalld安装
nfs-serverbashyum install nfs-utils -y systemctl start nfs-server systemctl enable nfs-server配置
nfs共享/data文件夹,编辑/etc/exports文件内容如下:bash/data *(rw,sync,no_root_squash,no_subtree_check)使
nfs-server export配置立即生效bashexportfs -a显示
/data文件夹是否被nfs exportbashshowmount -e客户端
mount nfs-server测试,挂载nfs-server /data文件夹到本地/opt/temp文件夹nfs挂载参数https://help.aliyun.com/zh/nas/user-guide/mount-an-nfs-file-system-on-a-linux-ecs-instance?spm=a2c4g.11186623.help-menu-27516.d_2_0_2_1_0.4c1cda29aX7laNbashmkdir /opt/temp mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 192.168.235.191:/data /opt/tempvers=3:使用NFS v3协议挂载文件系统。rsize:定义数据块的大小,用于客户端与文件系统之间读取数据。建议值:1048576。wsize:定义数据块的大小,用于客户端与文件系统之间写入数据。建议值:1048576。如果您需要更改
IO大小参数(rsize和wsize),建议您尽可能使用最大值(1048576),以避免性能下降。hard:在文件存储NAS暂时不可用的情况下,使用文件系统上某个文件的本地应用程序时会停止并等待至该文件系统恢复在线状态。建议启用该参数。timeo:指定时长,单位为0.1秒,即NFS客户端在重试向文件系统发送请求之前等待响应的时间。建议值:600(60秒)。如果您必须更改超时参数(
timeo),建议您使用150或更大的值。该timeo参数的单位为0.1秒,因此150表示的时间为15秒。retrans:NFS客户端重试请求的次数。建议值:2。noresvport:在网络重连时使用新的TCP端口,保障在网络发生故障恢复时不会中断连接。建议启用该参数。
客户端主机执行命令显示所有
mount文件系统bashmount取消
nfs挂载bashumount /opt/temp