NFS配置随手记录

本文记录了在Ubuntu服务器上配置NFS服务的过程,包括安装nfs-kernel-server,编辑/etc/exports文件,重启NFS服务,以及遇到的错误和解决办法。在客户端配置挂载NFS共享时,遇到rpc.statd未运行和portmap防火墙阻塞的问题,通过调整hosts.allow和hosts.deny文件并重启portmap服务解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

apt-get install nfs-kernel-server
在/etc/exports中加入
/usr/nfsshare *(rw,sync,fsid=0,no_root_squash)
wp@MySQL:~$ sudo /etc/init.d/nfs-kernel-server restart
 * Stopping NFS kernel daemon
   ...done.
 * Unexporting directories for NFS kernel daemon...
   ...done.
 * Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/usr/nfsshare".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

   ...done.
 * Starting NFS kernel daemon
   ...done.
wp@MySQL:~$ sudo /etc/init.d/idmapd restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service idmapd restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop idmapd ; start idmapd. The restart(8) utility is also available.
idmapd stop/waiting
idmapd start/running, process 2020

wp@web:~$ sudo mount –a -v
[sudo] password for wp:
mount: can't find –a in /etc/fstab or /etc/mtab
wp@web:~$ df -k
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/web-root 956866228 1257348 907002880   1% /
udev                   1993900       4   1993896   1% /dev
tmpfs                   801380     352    801028   1% /run
none                      5120       0      5120   0% /run/lock
none                   2003444      92   2003352   1% /run/shm
/dev/sda2               234153   27295    194366  13% /boot
/dev/sda1               193784     124    193660   1% /boot/efi


wp@MySQL:~$ sudo exportfs -ra
[sudo] password for wp:
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/usr/nfsshare".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x
nfs版本更新后参数不同
客户端的/etc/fstab <nfs-hostname>:共享目录地址 nfs4 defaults 0 0
nfs服务器的修改/etc/exports 内容如下:共享目录地址 *(rw,sync,no_root_squash,no_subtree_check,fsid=0)
更改后不报错
 

 

wp@web:~$ sudo apt-get install rpcbind nfs-common

wp@web:~$ sudo mount 192.168.1.203:/usr/nfsshare /usr/nfsshare
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

启动日志/var/log/boot.log
rpcbind: Cannot open '/run/rpcbind/rpcbind.xdr' file for reading, errno 2 (No such file or directory)^M
rpcbind: Cannot open '/run/rpcbind/portmap.xdr' file for reading, errno 2 (No such file or directory)^M
/dev/sda2: 215/124992 files (1.9% non-contiguous), 42998/249856 blocks
mountall: fsck /boot [301] terminated with status 1
问题锁定,portmap防火墙受阻
测试要求 按照ubuntu server最佳解决方案部署
在服务器端
/etc/hosts.allow中加入portmap mountd nfsd statd lockd rquotad : 192.168.1.201 192.168.1.203
/etc/hosts.deny加入   portmap mountd nfsd statd lockd rquotad : ALL
sudo /etc/init.d/portmap restart
在客户端
/etc/hosts.deny加入   portmap : ALL
/etc/hosts.allow加入  portmap : 192.168.1.203
sudo /etc/init.d/portmap restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值