Linux NFS server 配置

我用的是centos7

第0步: 关闭防火墙

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

第一步:安装NFS

yum -y install nfs-utils rpcbind
nfs 的配置文件 /etc/expots

第二步:配置

vi /etc/exports
/mnt/share *(rw,async,no_root_squash)
exportfs -rv (这个命令可以验证我们设置的配置文件/etc/exports是否正确

第三步:设置NFS为启动服务

chkconfig --list | grep nfs
chkconfig nfs on
service nfs restart

遇到的问题

[root@localhost ~]# exportfs  -rv
exportfs: /etc/exports:1: syntax error: bad option list
exportfs: No file systems exported!

问题:/mnt/share *(rw,async,no_root_squash) 逗号之间有空格
解决:把,之间的空格取消掉就行了

错误: 客户端无法写入文件
解决: 发现exports目录权限中,有这么一个参数no_root_squash。其作用是:登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!。默认情况使用的是相反参数 root_squash:在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者,通常他的 UID 与 GID 都会变成 nobody 那个身份。
因为我的客户端是使用root登录的,自然权限被压缩为nobody了,难怪无法写入。将配置信息改为: /testfs 10.0.0.0/8(rw,no_root_squash)
据说有点不安全,但问题是解决了。

参考:http://www.2cto.com/os/201304/202056.html
http://www.blogjava.net/gf7/archive/2012/12/12/392843.html

建议:

1.使用NFS,就要使用portmap,NFS严重依赖于portmap,所以不要试图去停止它(portmap)。
2.当不能umount /nfs 分区时,试着使用umount -f /nfs,一般都能成功。
3.当umount -f /nfs不能umount时,可以试试umount -l /nfs. umount -l是最终级的umount。

你可能感兴趣的:(Linux NFS server 配置)