centos新版本已经把portmap改成rpcbind了
安装:
需要安装nfs-utils rpcbind
| 启动 | systemctl start rpcbind.service | systemctl start nfs.service |
| 端口/进程 | netstat -lnt (111端口) | ps -ef | grep nfs |
| rpc检查 | rpcinfo -p localhost |
配置文件
NFS默认配置文件/etc/exports存在,但是空文件,有的需要手动创建文件。
/etc/exports 三种方式
| 常用格式 | 共享目录 | 客户端IP或网段(参数,参数,...,....) |
| 方式1 | /share/share | 10.0.0.1/24(rw,sync) |
| 方式2 | /share/share | 10.0.0.0/24(rw,sync.all_squash,anonuid=2000,anongid=2000) |
| 方式3 | /share/share | 10.0.0.0/24(ro) |
备注:
sync 同步写入到内存及硬盘中,影响性能!
方式2是常用的一种方式,适合多人共享,表明所有接入客户都匿名方式.
例如:
[root@localhost ~]# cat > /etc/exports << EOF
> /share/share 172.21.10.0/24(rw,sync)
> EOF
[root@localhost ~]# cat /etc/exports
/share/share 172.21.10.0/24(rw,sync)
客户端篇
linux客户端挂NFS方法showmount -e nfs服务器IP地址
mount -t nfs nfs服务器的ip:/共享目录 /mnt (mnt为客户端的目录)
NFS默认自带参数 /var/lib/nfs/etab
NFS查看挂载用户 /var/lib/nfs/rmtab
开机自启nfs挂载方式
/etc/fstab 一般不放在此,若挂载不成功,引起主机无法开机
/etc/rc.local
卸载umount 本地挂载点
例如:umount /mnt
强制卸载挂载:umount -lf /mnt
原文:http://sadoc.blog.51cto.com/12189157/1909954