Centos7.x安装NFS文件共享服务,也适用于其他系统

服务端安装

yum -y install nfs-utils rpcbind

配置服务

vi /etc/exports
/nfs 172.27.0.0/24(rw,no_root_squash,no_all_squash,sync)

此配置允许172.27.0.0/24段的IP以root权限读写/nfs目录

开机自启

service rpcbind start
service nfs start
chkconfig --level 2345 rpcbind on
chkconfig --level 2345 nfs on

客户端安装

yum -y install nfs-utils rpcbind
# 创建目录
mkdir /share

查看服务端共享的目录

showmount -e 服务端ip

挂载目录

mount -t nfs 服务端ip:/nfs /share 
# 测试
cd /share && touch a

设置开机自动挂载

vi /etc/fstab
服务端ip:/nfs /share nfs defaults 0 0