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