nfs配置文件共享分为服务端和客户端
服务端配置
rpm -qa|grep nfs 查看是否安装过nfs服务(如果已安装可忽略安装步骤)
yum search nfs
yum install -y nfs-utils.x86_64
mkdir /sharedata 新建需要共享的目录(根据需要修改目录权限)
然后向/etc/exports文件中添加配置内容如:
/sharedata 192.168.101.157(rw,sync,no_root_squash,no_all_squash)
/sharedata 192.168.101.158(rw,sync,no_root_squash,no_all_squash)
# 以上共享给了两个客户端,一个客户端一条配置记录
service nfs start 启动nfs服务(rpcbind默认启动)
showmount -e localhost 查看本端服务是否可连接
客户端配置
可选择autofs进行配置,本次选择nfs自身配置
rpm -qa|grep nfs
yum search nfs
yum install nfs-utils.x86_64
mkdir /sharedata
chmod 777 sharedata/
mount -t nfs 192.168.101.34:/sharedata -o nolock,nfsvers=3,vers=3
如果不加 -onolock,nfsvers=3 则在挂载目录下的文件属主和组都是nobody,如果指定nfsvers=3则显示root。
如果要解除挂载可使用umount命令解除挂载。
网友评论